Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Révision | ee362a7af3ee8a822d276ba285c284084e59073f (tree) |
---|---|
l'heure | 2023-10-05 06:54:55 |
Auteur | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
Improved MuMut coverage
@@ -21,6 +21,7 @@ | ||
21 | 21 | # |
22 | 22 | rPY_CURRENT = \ |
23 | 23 | pytst/aigr/test_2c_GenericProtocols.py \ |
24 | + pytst/aigr/test_0_aid.py \ | |
24 | 25 | # |
25 | 26 | CC2CPy_TODO = \ |
26 | 27 | pytst/writers/RPy/test_999.py \ |
@@ -40,7 +40,7 @@ | ||
40 | 40 | |
41 | 41 | name: str |
42 | 42 | kind: ProtocolKind |
43 | - based_on: PTH.Optional[Protocol]=dc_field(default_factory= lambda :Protocol._BASE) | |
43 | + based_on: PTH.Optional[Protocol]=dc_field(default_factory= lambda :Protocol._BASE) # pragma: no mutate | |
44 | 44 | typedParameters: PTH.Optional[PTH.Sequence[TypedParameter]]=() |
45 | 45 | |
46 | 46 |
@@ -56,15 +56,17 @@ | ||
56 | 56 | @dataclass # pragma: no mutate |
57 | 57 | class StreamProtocol(Protocol): pass ### XXX ToDo (not exported) |
58 | 58 | |
59 | + | |
60 | +marker_kind=object() # pragma: no mutate -- Just an unknown, unique marker | |
59 | 61 | @dataclass # pragma: no mutate |
60 | 62 | class ProtocolWrapper(Protocol): |
61 | 63 | name: str="" |
62 | - kind : ProtocolKind=None | |
64 | + kind : ProtocolKind=marker_kind | |
63 | 65 | _: KW_ONLY |
64 | - arguments: PTH.Sequence[Argument]=() | |
66 | + arguments: PTH.Sequence[Argument] | |
65 | 67 | |
66 | 68 | def __post_init__(self): |
67 | - if not self.kind: | |
69 | + if self.kind is marker_kind: | |
68 | 70 | self.kind = self.based_on.kind |
69 | 71 | if self.name == "": |
70 | 72 | self.name = f"Wrapper for {self.based_on.name}({self.arguments})" |
@@ -0,0 +1,12 @@ | ||
1 | +# (C) Albert Mietus, 2023. Part of Castle/CCastle project | |
2 | + | |
3 | +import logging; logger = logging.getLogger(__name__) | |
4 | +import pytest | |
5 | + | |
6 | +from castle.aigr import aid | |
7 | + | |
8 | +def test_Argument_with_NoName(): | |
9 | + a = aid.Argument(value=1) | |
10 | + | |
11 | + assert a.name == None | |
12 | + assert a.value == 1 |
@@ -65,11 +65,6 @@ | ||
65 | 65 | def sub_b(base): |
66 | 66 | return EventProtocol("Sub_b", events=[], based_on=ProtocolWrapper(based_on=base, arguments=(Argument(value=1),))) |
67 | 67 | |
68 | -@pytest.fixture | |
69 | -def sub_strange(base): | |
70 | - return EventProtocol("SubStrange", events=[], based_on=ProtocolWrapper(name="Strange", kind=42, | |
71 | - based_on=base, arguments=(Argument(value=1),))) | |
72 | - | |
73 | 68 | def assert_GP_kind(base, sub): |
74 | 69 | assert sub.kind == base.kind |
75 | 70 | assert sub.based_on.kind == base.kind |
@@ -94,7 +89,23 @@ | ||
94 | 89 | assert_GP_name(base, sub_b) |
95 | 90 | assert "queue_max" not in sub_b.based_on.name # the argument-name is only in the (a) version |
96 | 91 | |
97 | -def test_strange(sub_strange): | |
92 | + | |
93 | + | |
94 | +def test_strange_1(base): | |
98 | 95 | """This is (very) atypical use -- but it helps to get coverage""" |
96 | + sub_strange = EventProtocol("SubStrange", events=[], based_on=ProtocolWrapper(name="Strange", | |
97 | + kind=42, | |
98 | + based_on=base, | |
99 | + arguments=(Argument(value=1),))) | |
99 | 100 | assert sub_strange.based_on.name == "Strange" |
100 | 101 | assert sub_strange.based_on.kind == 42, "When we set a strange kind-number it should be stored" |
102 | + | |
103 | +def test_strange_2(base): | |
104 | + """This is (very) atypical use -- but it helps to get coverage""" | |
105 | + sub_strange = EventProtocol("SubStrange", events=[], based_on=ProtocolWrapper(name="Strange", | |
106 | + kind=None, | |
107 | + based_on=base, | |
108 | + arguments=(Argument(value=1),))) | |
109 | + | |
110 | + assert sub_strange.based_on.name == "Strange" | |
111 | + |