• R/O
  • SSH

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2


Commit MetaInfo

Revisionb2432bdd5231ad6a709d3dd967f7161ba52df9cd (tree)
Zeit2023-09-26 23:20:00
AutorAlbert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

MockEvent & MockProtocol are gone from the tests now

Ändern Zusammenfassung

Diff

diff -r cc731cbbbeab -r b2432bdd5231 Makefile
--- a/Makefile Tue Sep 26 16:18:23 2023 +0200
+++ b/Makefile Tue Sep 26 16:20:00 2023 +0200
@@ -8,16 +8,17 @@
88 # CURRENT: The now current test, in TDD phase
99 # TODO: Some test that are needed soon
1010 rPY_LAST = \
11- pytst/writers/RPy/test_0_templating.py \
1211 pytst/aigr/test_0_AIGR.py \
1312 pytst/aigr/test_1_events.py \
1413 pytst/aigr/test_2a_protocolKind.py \
1514 pytst/aigr/test_2b_protocol.py \
15+ pytst/aigr/test_2b_protocol.py \
16+ pytst/writers/RPy/test_0_templating.py \
1617 pytst/writers/RPy/test_1_EventIndexes.py \
18+ pytst/writers/RPy/test_2_ProtocolDataStructures.py \
1719 #
1820 rPY_CURRENT = \
19- pytst/aigr/test_2b_protocol.py \
20- pytst/writers/RPy/test_2_ProtocolDataStructures.py \
21+ pytst/writers/RPy/test_1_EventIndexes.py \
2122 #
2223 CC2CPy_TODO = \
2324 pytst/writers/RPy/test_99_StartSieve.py \
diff -r cc731cbbbeab -r b2432bdd5231 pytst/writers/RPy/__init__.py
--- a/pytst/writers/RPy/__init__.py Tue Sep 26 16:18:23 2023 +0200
+++ b/pytst/writers/RPy/__init__.py Tue Sep 26 16:20:00 2023 +0200
@@ -10,13 +10,6 @@
1010 from castle.aigr import Event, Protocol
1111 from castle.writers import RPy
1212
13-@dataclass
14-class MockEvent(Event):
15- indexNo: int
16-
17-@dataclass
18-class MockProtocol():
19- name: str
2013
2114 @pytest.fixture
2215 def T_Protocol():
@@ -32,10 +25,13 @@
3225
3326
3427
35-def assert_marker(marker, txt, need, msg=None):
28+def assert_marker(marker, txt, need=None, msg=None):
3629 lines = txt.splitlines()
3730 c = sum(1 if (marker in line) else 0 for line in lines)
38- assert c == need, f"Needed {need} lines with '{marker}'-markers, found {c} -- in {len(lines)} lines" + ((+ ' ' + msg) if msg else "")
31+ if need is None:
32+ assert c > 0, f"Expected lines with '{marker}'-marker, found nothing in:\n----\n{txt}\n----"
33+ else:
34+ assert c == need, f"Needed {need} lines with '{marker}'-markers, found {c} -- in {len(lines)} lines" + ((+ ' ' + msg) if msg else "")
3935
4036
4137 def get_dirPath_of_file(f=__file__):
diff -r cc731cbbbeab -r b2432bdd5231 pytst/writers/RPy/test_1_EventIndexes.py
--- a/pytst/writers/RPy/test_1_EventIndexes.py Tue Sep 26 16:18:23 2023 +0200
+++ b/pytst/writers/RPy/test_1_EventIndexes.py Tue Sep 26 16:20:00 2023 +0200
@@ -5,9 +5,8 @@
55
66 from castle.aigr.types import TypedParameter
77
8-from castle.aigr import EventProtocol
8+from castle.aigr import EventProtocol, Event
99 from . import T_EventIndexes
10-from . import MockEvent
1110 from . import T_Protocol
1211 from . import assert_marker
1312
@@ -15,10 +14,6 @@
1514 EventIndex_PreFix = "CC_P_" #Keep in sync with implementation
1615
1716
18-@pytest.mark.skip("XXX ToDo:: The MockEvent should go")
19-def test_ToDo(): pass
20-
21-
2217 def test_template_0_NoEvent(T_EventIndexes):
2318 p = EventProtocol("NoEventsMOCK", events=[])
2419 out=T_EventIndexes.render(protocol=p, events=p.events)
@@ -29,29 +24,29 @@
2924
3025
3126 def test_template_1_event(T_EventIndexes):
32- p = EventProtocol("MOCK", events=[MockEvent("input", indexNo=-7, typedParameters=[TypedParameter(name='event', type=int)])])
27+ p = EventProtocol("MOCK", events=[Event("input", typedParameters=[TypedParameter(name='event', type=int)])])
3328 out=T_EventIndexes.render(protocol=p, events=p.events)
3429 logger.debug("out::\n%s", out)
3530
3631 assert_marker(EventIndex_PreFix, out, 1)
37- assert_marker('=', out, 1)
32+ assert_marker('= 0', out)
3833
3934
4035 def test_template_2_SomeEvent(T_EventIndexes):
41- p = EventProtocol("MOCK", events=\
42- [ MockEvent("one", indexNo=1),
43- MockEvent("two", indexNo=2),
44- MockEvent("three",indexNo=3),
45- MockEvent("four", indexNo=4)])
36+ p = EventProtocol("MOCK", events= [Event("one"), Event("two"), Event("three"), Event("four")])
4637 out=T_EventIndexes.render(protocol=p, events=p.events)
4738 logger.debug("out::\n%s", out)
4839
4940 assert_marker(EventIndex_PreFix, out, 4)
50- assert_marker('=', out, 4)
41+ assert_marker('= 0', out)
42+ assert_marker('= 1', out)
43+ assert_marker('= 2', out)
44+ assert_marker('= 3', out)
45+
5146
5247
5348 def test_EventIndexes_In_protocol(T_Protocol):
54- out=T_Protocol.render(protocols=[EventProtocol(name="MOCK", events=[MockEvent("input", indexNo=-7)])])
49+ out=T_Protocol.render(protocols=[EventProtocol(name="MOCK", events=[Event("input")])])
5550 logger.info("\n---------- out:: ------------------------\n%s\n--------------------------------", out)
5651 assert True, "No assert (not maintainable) only check it runs"
5752
diff -r cc731cbbbeab -r b2432bdd5231 pytst/writers/RPy/test_2_ProtocolDataStructures.py
--- a/pytst/writers/RPy/test_2_ProtocolDataStructures.py Tue Sep 26 16:18:23 2023 +0200
+++ b/pytst/writers/RPy/test_2_ProtocolDataStructures.py Tue Sep 26 16:20:00 2023 +0200
@@ -3,11 +3,10 @@
33 import logging; logger = logging.getLogger(__name__)
44 import pytest
55
6-from castle.aigr import Event, EventProtocol
6+from castle.aigr import EventProtocol, Event
77 from castle.aigr.types import TypedParameter
88
99 from . import T_ProtocolDataStructures
10-from . import MockEvent
1110 from . import T_Protocol
1211 from . import assert_marker
1312
@@ -19,14 +18,14 @@
1918 @pytest.fixture
2019 def p_1e():
2120 "Protocol with 1 event"
22- p = EventProtocol(name="P1", events=(MockEvent(name="e1", indexNo=101),))
21+ p = EventProtocol(name="P1", events=(Event(name="e1"),))
2322 logger.debug("%s", p)
2423 return p
2524
2625 @pytest.fixture
2726 def p_2e_1i(p_1e):
2827 "Protocol with 2 events, and 1 inherited; so 3 in total"
29- p = EventProtocol(name="P2", events=(MockEvent(name="e2", indexNo=102), MockEvent(name="e3", indexNo=103)), based_on=p_1e)
28+ p = EventProtocol(name="P2", events=(Event(name="e2"), Event(name="e3")), based_on=p_1e)
3029 logger.debug("%s", p)
3130 return p
3231
diff -r cc731cbbbeab -r b2432bdd5231 pytst/writers/RPy/test_99_StartSieve.py
--- a/pytst/writers/RPy/test_99_StartSieve.py Tue Sep 26 16:18:23 2023 +0200
+++ b/pytst/writers/RPy/test_99_StartSieve.py Tue Sep 26 16:20:00 2023 +0200
@@ -1,20 +1,15 @@
11 # (C) Albert Mietus, 2023. Part of Castle/CCastle project
22
33 import logging; logger = logging.getLogger(__name__)
4+
45 import pytest
56
6-from castle.aigr.types import TypedParameter
7+from pytst.TestDoubles.protocols import StartSieve #XXX
78
89 from . import T_Protocol
9-from . import MockEvent, MockProtocol
1010
1111 @pytest.mark.xfail
1212 def test_99_StartSieve(T_Protocol):
13- out = T_Protocol.render(
14- protocol=MockProtocol("StartSieve"),
15- events=[
16- MockEvent("runTo", indexNo=7, typedParameters=[TypedParameter(name='max', type=int)]),
17- MockEvent("newMax", indexNo=8, typedParameters=[TypedParameter(name='max', type=int)]),
18- ])
13+ out = T_Protocol.render(protocols=[StartSieve,])
1914 logger.info("\n---------- out:: ------------------------\n%s\n--------------------------------", out)
2015 assert False