Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Revision | 04f1dce1fca35bb7625037eea84b26fff235f1de (tree) |
---|---|
Time | 2023-10-05 06:01:53 |
Author | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
Added a few atypical cases to the tests, to get coverage
@@ -13,6 +13,10 @@ | ||
13 | 13 | return EventProtocol("EMPTY", events=[], based_on=None) |
14 | 14 | |
15 | 15 | @pytest.fixture |
16 | +def emptyProtocol_baseNotSet(): | |
17 | + return Protocol("VeryEmpty", kind=ProtocolKind.Unknown) | |
18 | + | |
19 | +@pytest.fixture | |
16 | 20 | def anEvent(): |
17 | 21 | return Event("input", typedParameters=[TypedParameter(name='event', type=int)]) |
18 | 22 |
@@ -27,10 +31,14 @@ | ||
27 | 31 | assert simpleSieve.kind == ProtocolKind.Event |
28 | 32 | |
29 | 33 | |
30 | -def test_2_based_onRoot(emptyProtocol): | |
34 | +def test_2a_based_onRoot(emptyProtocol): | |
31 | 35 | import castle.aigr.protocols |
32 | 36 | emptyProtocol.based_on is castle.aigr.protocols._RootProtocol |
33 | 37 | |
38 | +def test_2b_based_onRoot_notSet(emptyProtocol_baseNotSet): | |
39 | + import castle.aigr.protocols | |
40 | + emptyProtocol_baseNotSet.based_on is castle.aigr.protocols._RootProtocol | |
41 | + | |
34 | 42 | |
35 | 43 | def test_3a_eventIndex_empty(emptyProtocol, anEvent): |
36 | 44 | assert emptyProtocol._noEvents() == 0 |
@@ -65,16 +65,20 @@ | ||
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 | + | |
68 | 73 | def assert_GP_kind(base, sub): |
69 | 74 | assert sub.kind == base.kind |
70 | 75 | assert sub.based_on.kind == base.kind |
71 | 76 | assert sub.based_on.based_on is base |
72 | 77 | |
73 | - | |
74 | 78 | def test_GenericProtocol_kind_a(base, sub_a): |
75 | 79 | assert_GP_kind(base, sub_a) |
76 | 80 | |
77 | -def test_GenericProtocol_kind_a(base, sub_b): | |
81 | +def test_GenericProtocol_kind_b(base, sub_b): | |
78 | 82 | assert_GP_kind(base, sub_b) |
79 | 83 | |
80 | 84 |
@@ -82,9 +86,15 @@ | ||
82 | 86 | assert "Wrapper" in sub.based_on.name |
83 | 87 | assert "Base" in sub.based_on.name |
84 | 88 | |
85 | -def test_GenericProtocol_name(base, sub_a): | |
89 | +def test_GenericProtocol_name_a(base, sub_a): | |
86 | 90 | assert_GP_name(base, sub_a) |
87 | - assert "queue_max" in sub.based_on.name | |
91 | + assert "queue_max" in sub_a.based_on.name # the argument-name is only in the (a) version | |
88 | 92 | |
89 | -def test_GenericProtocol_name(base, sub_b): | |
93 | +def test_GenericProtocol_name_b(base, sub_b): | |
90 | 94 | assert_GP_name(base, sub_b) |
95 | + assert "queue_max" not in sub_b.based_on.name # the argument-name is only in the (a) version | |
96 | + | |
97 | +def test_strange(sub_strange): | |
98 | + """This is (very) atypical use -- but it helps to get coverage""" | |
99 | + assert sub_strange.based_on.name == "Strange" | |
100 | + assert sub_strange.based_on.kind == 42, "When we set a strange kind-number it should be stored" |