• 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

修订版b42f9200ebf94cdb3fb73e1007e1942411261ded (tree)
时间2024-05-27 01:44:26
作者Albert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

BUSY: TESTDOUBLES::sieveCastle::EV, test & then are dummy

更改概述

差异

diff -r c4c7ce3a80cd -r b42f9200ebf9 TestDoubles_packages/TestDoubles-aigr-sieve/castle/TESTDOUBLES/aigr/sieve/basic1/sieveCastle.py
--- a/TestDoubles_packages/TestDoubles-aigr-sieve/castle/TESTDOUBLES/aigr/sieve/basic1/sieveCastle.py Sun May 26 18:24:36 2024 +0200
+++ b/TestDoubles_packages/TestDoubles-aigr-sieve/castle/TESTDOUBLES/aigr/sieve/basic1/sieveCastle.py Sun May 26 18:44:26 2024 +0200
@@ -65,8 +65,14 @@
6565 event=ID('input', context=aigr.Ref()),
6666 port=ID('try', context=aigr.Ref()),
6767 body=aigr.Body(statements=[
68- # XXXX
69- ]))
68+ aigr.If(
69+ test=aigr.Compare(ops=aigr.operators.NotEqual(), values=(
70+ "try % .myPrime",
71+ "0"
72+ )),
73+ body=aigr.Body(statements=[
74+ "XXX"
75+ ]))]))
7076
7177
7278
diff -r c4c7ce3a80cd -r b42f9200ebf9 TestDoubles_packages/TestDoubles-aigr-sieve/pytst/sieve/basic1/test_sieveCastle.py
--- a/TestDoubles_packages/TestDoubles-aigr-sieve/pytst/sieve/basic1/test_sieveCastle.py Sun May 26 18:24:36 2024 +0200
+++ b/TestDoubles_packages/TestDoubles-aigr-sieve/pytst/sieve/basic1/test_sieveCastle.py Sun May 26 18:44:26 2024 +0200
@@ -3,10 +3,8 @@
33 See: http://docideas.mietus.nl/en/default/CCastle/4.Blog/b.TheSieve.html#the-design
44 """
55 import logging; logger = logging.getLogger(__name__)
6-
76 import pytest
87
9-
108 from castle import aigr
119 from castle.aigr_extra.blend import mangle_event_handler
1210
@@ -21,6 +19,17 @@
2119 def comp():
2220 return sieveCastle.Sieve
2321
22+@pytest.fixture
23+def event_handler(comp):
24+ # Notes
25+ ## - event(`input`) -- this protocol has only one event, so its simple
26+ ## - port('try') -- thats the 1ste one. But keep it in sync (CastleCode is leading)
27+ (protocol, event, port) = protocols.SimpleSieve, protocols.SimpleSieve.events[0], components.SieveMoat.ports[0]
28+ handler = find_name_in_body(mangle_event_handler(protocol=protocol.name, event=event.name, port=port.name), comp.body)
29+ assert isinstance(handler, aigr.EventHandler), f"Expected EventHandler, got {handler} (type={type(handler)})" # Not a test, only to check.
30+ logger.debug("Found <%s> as event_handler", handler)
31+ return handler
32+
2433
2534 def test_0a_types(comp):
2635 assert isinstance(comp, aigr.ComponentImplementation)
@@ -35,7 +44,6 @@
3544 def test_0c_noParms(comp):
3645 assert comp.parameters == ()
3746
38-
3947 def test_1_init_has_2lines(comp):
4048 init = find_name_in_body('init', comp.body)
4149 assert isinstance(init, aigr.Method), f"Expected an init method, got {init}"
@@ -48,19 +56,45 @@
4856 assert isinstance(id.context, aigr.Ref), f"found ID '{id}' has not ref"
4957 # XXX ToDo: check the ref -- for now empty is fine
5058
59+def test_2_handler_on_try(event_handler):
60+ verify_IDref(event_handler.protocol, "SimpleSieve")
61+ verify_IDref(event_handler.event, "input")
62+ verify_IDref(event_handler.port, "try")
5163
52-def test_2_handler_on_try(comp):
53- """The event-handler name and the name of protocol/event/port are all text, but ...
54- should match the names of the earlier/elsewere defined protocol/event/port structure.
55- """
56- # Notes
57- #@ - event(`input`) -- this protocol has only one event, so its simple
58- ## - port('try') -- thats the 1ste one. But keep it in sync (CastleCode is leading)
59- (protocol, event, port) = protocols.SimpleSieve, protocols.SimpleSieve.events[0], components.SieveMoat.ports[0]
6064
61- handler = find_name_in_body(mangle_event_handler(protocol=protocol.name, event=event.name, port=port.name), comp.body)
62- assert handler, "No handler found"
65+def test_3a_EH_is_one_statement(event_handler):
66+ "This eventhandler has basically one (multiline) statement: an if an 1 statement inside"
67+ body = event_handler.body
68+ assert isinstance(body, aigr.Body), f"any EH Should have a Body (instance), but found {body} (type={type(body)})"
69+ assert len(body)==1, f"Expected a single (long) statement, but found {len(body)} statement(s)"
6370
64- verify_IDref(handler.protocol, protocol.name)
65- verify_IDref(handler.event, event.name)
66- verify_IDref(handler.port, port.name)
71+
72+def test_3b_EH_is_one_if(event_handler):
73+ if_statement=event_handler.body[0]
74+ assert isinstance(if_statement, aigr.If) # Not a test, only to check.
75+
76+ test = if_statement.test
77+ then = if_statement.body
78+ orelse = if_statement.orelse
79+ logger.debug("if_statement: test=%s, then=%s, orelse=%s", test,then,orelse)
80+
81+ assert isinstance(test, aigr.expressions._expression) # The expressions itself is below
82+ assert isinstance(then, aigr.Body) and len(then)==1 # The statement is tested below
83+ assert orelse is None
84+
85+
86+def test_3c_EH_test_exps(event_handler):
87+ if_statement = event_handler.body[0]
88+ test = if_statement.test
89+
90+ assert False, "ToDo if-expr"
91+
92+
93+def test_3d_EH_then_send(event_handler):
94+ if_statement=event_handler.body[0]
95+ then = if_statement.body
96+ assert len(then) == 1 # Not a test, only to check.
97+ send = then[0]
98+
99+ assert False, "ToDo if-then"
100+