• R/O
  • SSH

提交

標籤
無標籤

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

修訂5861d35f51411331f01e9ac4cf7965d3599977b8 (tree)
時間2024-03-02 00:46:50
作者Albert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

ASIS: activated some (ASIDE) TestDoubles/AIGR into TestDoubles-aigr-sieve package (BUSY)

Change Summary

差異

diff -r efdc2cb9cf60 -r 5861d35f5141 ASIDE/TestDoubles/AIGR/base/__init__.py
--- a/ASIDE/TestDoubles/AIGR/base/__init__.py Thu Feb 29 14:34:04 2024 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
1-# (C) Albert Mietus, 2023. Part of Castle/CCastle project
2-
3-""".. Note:: The baseProtocol (instance) is used in aigr.protocols as top of all protocols. So we can import & use it.
4- No such 'top-namespaces' exist, so we have to initiate it here.
5-"""
6-
7-from castle.aigr.protocols import baseProtocol, ID
8-from castle.aigr import NameSpace
9-
10-Protocol = baseProtocol
11-
12-base = NameSpace(ID('base'))
13-base.register(Protocol)
14-
diff -r efdc2cb9cf60 -r 5861d35f5141 ASIDE/TestDoubles/AIGR/sieve/protocols.py
--- a/ASIDE/TestDoubles/AIGR/sieve/protocols.py Thu Feb 29 14:34:04 2024 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
1-# (C) Albert Mietus, 2023. Part of Castle/CCastle project
2-
3-from castle.aigr import EventProtocol, Event, ID
4-from castle.aigr.protocols import ProtocolWrapper
5-from castle.aigr.aid import TypedParameter, Argument
6-
7-
8-StartSieve = EventProtocol(ID('StartSieve'),
9- events=(
10- Event(name=ID('runTo'), return_type=None, typedParameters=(TypedParameter(name='max', type=int),)),
11- Event(name=ID('newMax'), return_type=None, typedParameters=(TypedParameter(name='max', type=int),))))
12-
13-
14-SlowStart = EventProtocol(ID('SlowStart'),
15- typedParameters=(TypedParameter(name='queue_max', type=int),),
16- events=(
17- Event(name=ID('setMax'), return_type=None, typedParameters=(TypedParameter(name='queue_max', type=int),)),))
18-
19-SlowStart_1 = ProtocolWrapper(ID("SlowStart_1"),
20- based_on=SlowStart,
21- #OR: arguments=(Argument(name=queue_max, value=1),))
22- arguments=(Argument(value=1),))
23-
24-SimpleSieve = EventProtocol(ID('SimpleSieve'),
25- based_on=SlowStart_1,
26- events=(
27- Event(name=ID('input'), return_type=None, typedParameters=(TypedParameter(name='try', type=int),)),))
28-
29-
diff -r efdc2cb9cf60 -r 5861d35f5141 ASIDE/TestDoubles/TD_AIGR/test_1_sieve_protocols.py
--- a/ASIDE/TestDoubles/TD_AIGR/test_1_sieve_protocols.py Thu Feb 29 14:34:04 2024 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
1-# (C) Albert Mietus, 2023. Part of Castle/CCastle project
2-"""Test AIGR representation of the TheSieve protocols
3- See: http://docideas.mietus.nl/en/default/CCastle/4.Blog/b.TheSieve.html#the-design
4-"""
5-
6-import pytest
7-
8-import castle.aigr as aigr
9-from TestDoubles.AIGR.sieve import protocols
10-from TestDoubles.AIGR.base import Protocol as base_Protocol
11-
12-
13-def verify_Protocol(p, name, event_names, base=None, no_events=None, cls=None):
14- if base is None:
15- base=base_Protocol
16- if no_events is None:
17- no_events = len(event_names)
18- if cls is None:
19- cls = aigr.EventProtocol
20-
21- assert isinstance(p, cls)
22- assert p.name == name
23- assert p.based_on is base
24- assert p._noEvents() == no_events
25- for no, name in enumerate(event_names):
26- assert p.events[no].name == name
27-
28-
29-
30-def test_StartSieve():
31- p = protocols.StartSieve
32- verify_Protocol(p, name="StartSieve", event_names=('runTo', 'newMax'))
33-
34-def test_SlowStart():
35- p = protocols.SlowStart
36- verify_Protocol(p, name="SlowStart", event_names=['setMax'])
37-
38-def test_SlowStart_1():
39- from castle.aigr.protocols import ProtocolWrapper
40- p = protocols.SlowStart_1
41- verify_Protocol(p, name="SlowStart_1", cls=ProtocolWrapper, base=protocols.SlowStart, event_names=['setMax'])
42-
43-def test_SimpleSieve():
44- p = protocols.SimpleSieve
45- verify_Protocol(p, name="SimpleSieve", base=protocols.SlowStart_1, event_names=['input'])
46-
47-
48-
diff -r efdc2cb9cf60 -r 5861d35f5141 TestDoubles_packages/TestDoubles-aigr-sieve/Makefile
--- a/TestDoubles_packages/TestDoubles-aigr-sieve/Makefile Thu Feb 29 14:34:04 2024 +0100
+++ b/TestDoubles_packages/TestDoubles-aigr-sieve/Makefile Fri Mar 01 16:46:50 2024 +0100
@@ -3,8 +3,10 @@
33 PYREVERSE_PKGS = castle.TESTDOUBLES.aigr.sieve
44
55 LAST = \
6+ pytst/test_0_dummy.py \
67 #
78 CURRENT = \
9+ pytst/test_1_sieve_protocols.py \
810 #
911
1012 TODO = \
diff -r efdc2cb9cf60 -r 5861d35f5141 TestDoubles_packages/TestDoubles-aigr-sieve/castle/TESTDOUBLES/aigr/base/__init__.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestDoubles_packages/TestDoubles-aigr-sieve/castle/TESTDOUBLES/aigr/base/__init__.py Fri Mar 01 16:46:50 2024 +0100
@@ -0,0 +1,14 @@
1+# (C) Albert Mietus, 2023. Part of Castle/CCastle project
2+
3+""".. Note:: The baseProtocol (instance) is used in aigr.protocols as top of all protocols. So we can import & use it.
4+ No such 'top-namespaces' exist, so we have to initiate it here.
5+"""
6+
7+from castle.aigr.protocols import baseProtocol, ID
8+from castle.aigr import NameSpace
9+
10+Protocol = baseProtocol
11+
12+base = NameSpace(ID('base'))
13+base.register(Protocol)
14+
diff -r efdc2cb9cf60 -r 5861d35f5141 TestDoubles_packages/TestDoubles-aigr-sieve/castle/TESTDOUBLES/aigr/sieve/protocols.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestDoubles_packages/TestDoubles-aigr-sieve/castle/TESTDOUBLES/aigr/sieve/protocols.py Fri Mar 01 16:46:50 2024 +0100
@@ -0,0 +1,29 @@
1+# (C) Albert Mietus, 2023. Part of Castle/CCastle project
2+
3+from castle.aigr import EventProtocol, Event, ID
4+from castle.aigr.protocols import ProtocolWrapper
5+from castle.aigr.aid import TypedParameter, Argument
6+
7+
8+StartSieve = EventProtocol(ID('StartSieve'),
9+ events=(
10+ Event(name=ID('runTo'), return_type=None, typedParameters=(TypedParameter(name='max', type=int),)),
11+ Event(name=ID('newMax'), return_type=None, typedParameters=(TypedParameter(name='max', type=int),))))
12+
13+
14+SlowStart = EventProtocol(ID('SlowStart'),
15+ typedParameters=(TypedParameter(name='queue_max', type=int),),
16+ events=(
17+ Event(name=ID('setMax'), return_type=None, typedParameters=(TypedParameter(name='queue_max', type=int),)),))
18+
19+SlowStart_1 = ProtocolWrapper(ID("SlowStart_1"),
20+ based_on=SlowStart,
21+ #OR: arguments=(Argument(name=queue_max, value=1),))
22+ arguments=(Argument(value=1),))
23+
24+SimpleSieve = EventProtocol(ID('SimpleSieve'),
25+ based_on=SlowStart_1,
26+ events=(
27+ Event(name=ID('input'), return_type=None, typedParameters=(TypedParameter(name='try', type=int),)),))
28+
29+
diff -r efdc2cb9cf60 -r 5861d35f5141 TestDoubles_packages/TestDoubles-aigr-sieve/pytst/test_0_dummy.py
--- a/TestDoubles_packages/TestDoubles-aigr-sieve/pytst/test_0_dummy.py Thu Feb 29 14:34:04 2024 +0100
+++ b/TestDoubles_packages/TestDoubles-aigr-sieve/pytst/test_0_dummy.py Fri Mar 01 16:46:50 2024 +0100
@@ -1,2 +1,26 @@
1+# (C) Albert Mietus, 2023,2024 Part of Castle/CCastle project
2+"""Check that the AIGR TestDoubles 'the sieve' are available
3+ See: http://docideas.mietus.nl/en/default/CCastle/4.Blog/b.TheSieve.html#the-design
4+ See 'test_1... (and more) for in-depth tests"
5+"""
6+
7+
8+import pytest
9+
10+import castle.aigr as aigr
11+from castle.TESTDOUBLES.aigr.sieve import protocols
12+from castle.TESTDOUBLES.aigr.base import Protocol as base_Protocol
13+
14+
115 def test_0_Oke():
216 return
17+
18+def test_1_all_sieveProtocols():
19+ for p in (protocols.StartSieve, protocols.SlowStart, protocols.SimpleSieve):
20+ assert isinstance(p, aigr.EventProtocol)
21+
22+ for p in (protocols.SlowStart_1,):
23+ assert isinstance(p, aigr.protocols.ProtocolWrapper) # ProtocolWrapper isn't exported
24+
25+def test_2_baseProtocol():
26+ assert isinstance(base_Protocol, aigr.Protocol)
diff -r efdc2cb9cf60 -r 5861d35f5141 TestDoubles_packages/TestDoubles-aigr-sieve/pytst/test_1_sieve_protocols.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TestDoubles_packages/TestDoubles-aigr-sieve/pytst/test_1_sieve_protocols.py Fri Mar 01 16:46:50 2024 +0100
@@ -0,0 +1,48 @@
1+# (C) Albert Mietus, 2023,2024 Part of Castle/CCastle project
2+"""Test the AIGR TestDoubles of the Sieve protocols
3+ See: http://docideas.mietus.nl/en/default/CCastle/4.Blog/b.TheSieve.html#the-design
4+"""
5+
6+import pytest
7+
8+import castle.aigr as aigr
9+from castle.TESTDOUBLES.aigr.sieve import protocols
10+from castle.TESTDOUBLES.aigr.base import Protocol as base_Protocol
11+
12+
13+def verify_Protocol(p, name, event_names, base=None, no_events=None, cls=None):
14+ if base is None:
15+ base=base_Protocol
16+ if no_events is None:
17+ no_events = len(event_names)
18+ if cls is None:
19+ cls = aigr.EventProtocol
20+
21+ assert isinstance(p, cls)
22+ assert p.name == name
23+ assert p.based_on is base
24+ assert p._noEvents() == no_events
25+ for no, name in enumerate(event_names):
26+ assert p.events[no].name == name
27+
28+
29+
30+def test_StartSieve():
31+ p = protocols.StartSieve
32+ verify_Protocol(p, name="StartSieve", event_names=('runTo', 'newMax'))
33+
34+def test_SlowStart():
35+ p = protocols.SlowStart
36+ verify_Protocol(p, name="SlowStart", event_names=['setMax'])
37+
38+def test_SlowStart_1():
39+ from castle.aigr.protocols import ProtocolWrapper
40+ p = protocols.SlowStart_1
41+ verify_Protocol(p, name="SlowStart_1", cls=ProtocolWrapper, base=protocols.SlowStart, event_names=['setMax'])
42+
43+def test_SimpleSieve():
44+ p = protocols.SimpleSieve
45+ verify_Protocol(p, name="SimpleSieve", base=protocols.SlowStart_1, event_names=['input'])
46+
47+
48+