• R/O
  • SSH

提交

标签
No 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

修订版0dfb2ffc16682e64de951c74e5f4979c4dbc3033 (tree)
时间2024-02-24 01:39:45
作者Albert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

moved some TestDoubles-test ASIDE

更改概述

差异

diff -r 3faad6a98329 -r 0dfb2ffc1668 ASIDE/TestDoubles/TD_AIGR/test_0_base.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ASIDE/TestDoubles/TD_AIGR/test_0_base.py Fri Feb 23 17:39:45 2024 +0100
@@ -0,0 +1,24 @@
1+# (C) Albert Mietus, 2023. Part of Castle/CCastle project
2+
3+import pytest
4+
5+import castle.aigr as aigr
6+from castle.aigr.protocols import baseProtocol as ref_baseProtocol
7+
8+from TestDoubles.AIGR import base
9+
10+@pytest.fixture
11+def base_NS():
12+ return base.base
13+
14+def test_1a_baseNS(base_NS):
15+ assert isinstance(base_NS, aigr.NameSpace)
16+
17+def test_1b_base_has_Protocol(base_NS):
18+ base_Protocol = base_NS.getID('Protocol')
19+ assert isinstance(base_Protocol, aigr.Protocol)
20+
21+def test_1b_base_is_Protocol(base_NS):
22+ base_Protocol = base_NS.getID('Protocol')
23+ assert base_Protocol is ref_baseProtocol
24+
diff -r 3faad6a98329 -r 0dfb2ffc1668 ASIDE/TestDoubles/TD_AIGR/test_1_sieve_protocols.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ASIDE/TestDoubles/TD_AIGR/test_1_sieve_protocols.py Fri Feb 23 17:39:45 2024 +0100
@@ -0,0 +1,48 @@
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 3faad6a98329 -r 0dfb2ffc1668 ASIDE/TestDoubles/TD_AIGR/test_2_sieve_NS.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ASIDE/TestDoubles/TD_AIGR/test_2_sieve_NS.py Fri Feb 23 17:39:45 2024 +0100
@@ -0,0 +1,49 @@
1+# (C) Albert Mietus, 2023. Part of Castle/CCastle project
2+"""Test AIGR representation of the TheSieve protocols
3+
4+ See file:///Users/albert/work/DocIdeas,hg/__result/html/CCastle/HACK/DocParts/Design/231016_NS.html
5+ (not published yet -- see .../DocParts/Design/231016_NS.rst for source)"""
6+
7+import logging; logger = logging.getLogger(__name__)
8+import pytest
9+
10+import castle.aigr as aigr
11+from TestDoubles.AIGR.sieve import namespaces
12+from TestDoubles.AIGR.base import base as base_ns
13+
14+def verify_NS(ns, name, registered_names, as_name=None):
15+ if as_name is None: as_name=name
16+ assert ns.name == as_name
17+ for n in registered_names:
18+ if isinstance(n, (list, tuple)):
19+ # This is hardly/not used: but .... We support `import n[1] as n[0]`
20+ assert len(n) == 2
21+ name, asName = n[1], n[0]
22+ else:
23+ name, asName = n, n
24+ assert ns.getID(asName).name == name
25+
26+def test_slow_start_has_SlowStart():
27+ ns = namespaces.slow_start
28+ verify_NS(ns, "slow_start", ["SlowStart"])
29+
30+def test_start_sieve_has_StartSieve():
31+ ns = namespaces.start_sieve
32+ verify_NS(ns, "start_sieve", ["StartSieve"])
33+
34+def test_simple_sieve_has_SimpleSieve_and_SpecialiseGeneric():
35+ ns = namespaces.simple_sieve
36+ #verify_NS(ns, "simple_sieve", ["SlowStart_1", "SimpleSieve"])
37+ verify_NS(ns, "simple_sieve", ["SimpleSieve"])
38+
39+
40+def test_top():
41+ ns = namespaces.top
42+ verify_NS(ns, "top", as_name='TheSieve', registered_names=('start_sieve', 'slow_start', 'simple_sieve'))
43+ verify_NS(ns, "top", as_name='TheSieve', registered_names=('base',))
44+
45+
46+def test_all_NS_base_in_start_sieve():
47+ nss = namespaces.start_sieve.all_NS()
48+ for n,ns in nss.items(): print(f'name={n}: {ns.name} // {ns}')
49+ assert nss['base'] is base_ns
diff -r 3faad6a98329 -r 0dfb2ffc1668 pytst/TD_AIGR/test_0_base.py
--- a/pytst/TD_AIGR/test_0_base.py Fri Feb 23 17:33:50 2024 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
1-# (C) Albert Mietus, 2023. Part of Castle/CCastle project
2-
3-import pytest
4-
5-import castle.aigr as aigr
6-from castle.aigr.protocols import baseProtocol as ref_baseProtocol
7-
8-from TestDoubles.AIGR import base
9-
10-@pytest.fixture
11-def base_NS():
12- return base.base
13-
14-def test_1a_baseNS(base_NS):
15- assert isinstance(base_NS, aigr.NameSpace)
16-
17-def test_1b_base_has_Protocol(base_NS):
18- base_Protocol = base_NS.getID('Protocol')
19- assert isinstance(base_Protocol, aigr.Protocol)
20-
21-def test_1b_base_is_Protocol(base_NS):
22- base_Protocol = base_NS.getID('Protocol')
23- assert base_Protocol is ref_baseProtocol
24-
diff -r 3faad6a98329 -r 0dfb2ffc1668 pytst/TD_AIGR/test_1_sieve_protocols.py
--- a/pytst/TD_AIGR/test_1_sieve_protocols.py Fri Feb 23 17:33:50 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 3faad6a98329 -r 0dfb2ffc1668 pytst/TD_AIGR/test_2_sieve_NS.py
--- a/pytst/TD_AIGR/test_2_sieve_NS.py Fri Feb 23 17:33:50 2024 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
1-# (C) Albert Mietus, 2023. Part of Castle/CCastle project
2-"""Test AIGR representation of the TheSieve protocols
3-
4- See file:///Users/albert/work/DocIdeas,hg/__result/html/CCastle/HACK/DocParts/Design/231016_NS.html
5- (not published yet -- see .../DocParts/Design/231016_NS.rst for source)"""
6-
7-import logging; logger = logging.getLogger(__name__)
8-import pytest
9-
10-import castle.aigr as aigr
11-from TestDoubles.AIGR.sieve import namespaces
12-from TestDoubles.AIGR.base import base as base_ns
13-
14-def verify_NS(ns, name, registered_names, as_name=None):
15- if as_name is None: as_name=name
16- assert ns.name == as_name
17- for n in registered_names:
18- if isinstance(n, (list, tuple)):
19- # This is hardly/not used: but .... We support `import n[1] as n[0]`
20- assert len(n) == 2
21- name, asName = n[1], n[0]
22- else:
23- name, asName = n, n
24- assert ns.getID(asName).name == name
25-
26-def test_slow_start_has_SlowStart():
27- ns = namespaces.slow_start
28- verify_NS(ns, "slow_start", ["SlowStart"])
29-
30-def test_start_sieve_has_StartSieve():
31- ns = namespaces.start_sieve
32- verify_NS(ns, "start_sieve", ["StartSieve"])
33-
34-def test_simple_sieve_has_SimpleSieve_and_SpecialiseGeneric():
35- ns = namespaces.simple_sieve
36- #verify_NS(ns, "simple_sieve", ["SlowStart_1", "SimpleSieve"])
37- verify_NS(ns, "simple_sieve", ["SimpleSieve"])
38-
39-
40-def test_top():
41- ns = namespaces.top
42- verify_NS(ns, "top", as_name='TheSieve', registered_names=('start_sieve', 'slow_start', 'simple_sieve'))
43- verify_NS(ns, "top", as_name='TheSieve', registered_names=('base',))
44-
45-
46-def test_all_NS_base_in_start_sieve():
47- nss = namespaces.start_sieve.all_NS()
48- for n,ns in nss.items(): print(f'name={n}: {ns.name} // {ns}')
49- assert nss['base'] is base_ns