• 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

修订版f1809062df463071776378323907d18e58d0aeab (tree)
时间2023-02-22 05:43:10
作者Albert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

(ASIS) split Component into ComponentInterface and ComponentClass

更改概述

差异

diff -r 6e0d853fa598 -r f1809062df46 pytst/writers/CC2Cpy/test_2c_ports.py
--- a/pytst/writers/CC2Cpy/test_2c_ports.py Tue Feb 21 21:37:27 2023 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
1-# (C) Albert Mietus, 2022, 2023. Part of Castle/CCastle project
2-"""
3-Test the supporting types (Enum, dataclasses ect) for CC_B_ComponentInterface, and ...
4-
5-The more relevant test of Component(s) can be found in test_3b_* and test_3c_*"""
6-
7-import logging; logger = logging.getLogger(__name__)
8-import pytest
9-from . import * # CCompare
10-
11-from castle.writers.CC2Cpy.CCbase import *
12-
13-def test_1a_CC_PortDirection():
14- # Test the (int) value -- needed for the generated C code
15- assert CC_PortDirection.Unknown.value == 0
16- assert CC_PortDirection.In.value == 1
17- assert CC_PortDirection.Out.value == 2
18- assert CC_PortDirection.BiDir.value == 3
19- assert CC_PortDirection.Master.value == 4
20- assert CC_PortDirection.Slave.value == 5
21-
22- # Test the long-name & short-name are the same
23- assert CC_PortDirection.Unknown == CC_PortDirection.CC_B_PortDirectionIs_UNKNOWN
24- assert CC_PortDirection.In == CC_PortDirection.CC_B_PortDirectionIs_in
25- assert CC_PortDirection.Out == CC_PortDirection.CC_B_PortDirectionIs_out
26- assert CC_PortDirection.BiDir == CC_PortDirection.CC_B_PortDirectionIs_bidirect
27- assert CC_PortDirection.Master == CC_PortDirection.CC_B_PortDirectionIs_master
28- assert CC_PortDirection.Slave == CC_PortDirection.CC_B_PortDirectionIs_slave
29-
30-def test_1b_portray_PortDirection():
31- assert CCompare('CC_B_PortDirectionIs_UNKNOWN', CC_PortDirection.Unknown.portray_name())
32- assert CCompare('CC_B_PortDirectionIs_in', CC_PortDirection.In.portray_name())
33- assert CCompare('CC_B_PortDirectionIs_out', CC_PortDirection.Out.portray_name())
34- assert CCompare('CC_B_PortDirectionIs_bidirect', CC_PortDirection.BiDir.portray_name())
35- assert CCompare('CC_B_PortDirectionIs_master', CC_PortDirection.Master.portray_name())
36- assert CCompare('CC_B_PortDirectionIs_slave', CC_PortDirection.Slave.portray_name())
37-
38-
39-def test_2a1_Port_defaults():
40- n, t = "defaults", int
41- p1 = CC_Port(name=n, type=t) # Only direction is optional
42- assert p1.name == n
43- assert p1.type is t
44- assert p1.direction == CC_PortDirection.Unknown
45-
46-def test_2a1_Port_full():
47- n, t = "full", float
48- d=CC_PortDirection.In
49- inp = CC_Port(name=n, type=t, direction=d)
50- assert inp.name == n
51- assert inp.type is t
52- assert inp.direction == d
53-
54-
55-def test_2b1_portray_Port_name():
56- port = CC_Port(name="aPort", type="no_relevant")
57- assert CCompare('aPort', port.portray_name())
58-
59-def test_2b2a_portray_Port_NoType():
60- port = CC_Port(name="=NoName", type=None)
61- assert CCompare('NULL', port.portray_typePtr())
62-
63-@pytest.mark.filterwarnings("ignore:Using string .* port.types:DeprecationWarning")
64-def test_2b2b_portray_Port_strtype():
65- port = CC_Port(name="=NoName", type="textType")
66- assert CCompare('&cc_P_textType', port.portray_typePtr())
67-
68-@pytest.mark.filterwarnings("ignore:Using string .* port.types:DeprecationWarning")
69-def test_2b2c_portray_Port_inttype():
70- port = CC_Port(name="=NoName", type=int)
71- assert CCompare('&cc_P_int', port.portray_typePtr())
72-
73-@pytest.mark.filterwarnings("ignore:Using string .* port.types:DeprecationWarning")
74-def test_2b2d_portray_Port_floattype():
75- port = CC_Port(name="=NoName", type=float)
76- assert CCompare('&cc_P_float', port.portray_typePtr())
77-
78-from castle.writers.CC2Cpy.Protocol import * #CC_EventProtocol
79-
80-def test_2b2c_portray_Port_Protocol():
81- proto = CC_EventProtocol("JustAProtocol", events=[], based_on=None)
82- port = CC_Port(name="=NoName", type=proto)
83- # Note: When a Port's type is a Protocol, than the port's portray_type is both
84- ## the string 'cc_P_<xxxx>', and
85- ## the portray_name of that protocol.
86- ## We check both for now.
87- assert CCompare('&cc_P_JustAProtocol', port.portray_typePtr())
88- assert CCompare('&'+proto.portray_name(), port.portray_typePtr())
89-
90-
91-def test_BUG():
92- proto = CC_EventProtocol("JustAProtocol", events=[], based_on=None)
93- port = CC_Port(name="=NoName", type=proto)
94- assert isinstance(port.type, CC_Base)
diff -r 6e0d853fa598 -r f1809062df46 pytst/writers/CC2Cpy/test_3a_CompPorts.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pytst/writers/CC2Cpy/test_3a_CompPorts.py Tue Feb 21 21:43:10 2023 +0100
@@ -0,0 +1,94 @@
1+# (C) Albert Mietus, 2022, 2023. Part of Castle/CCastle project
2+"""
3+Test the supporting types (Enum, dataclasses ect) for CC_B_ComponentInterface, and ...
4+
5+The more relevant test of Component(s) can be found in test_3b_* and test_3c_*"""
6+
7+import logging; logger = logging.getLogger(__name__)
8+import pytest
9+from . import * # CCompare
10+
11+from castle.writers.CC2Cpy.CCbase import *
12+
13+def test_1a_CC_PortDirection():
14+ # Test the (int) value -- needed for the generated C code
15+ assert CC_PortDirection.Unknown.value == 0
16+ assert CC_PortDirection.In.value == 1
17+ assert CC_PortDirection.Out.value == 2
18+ assert CC_PortDirection.BiDir.value == 3
19+ assert CC_PortDirection.Master.value == 4
20+ assert CC_PortDirection.Slave.value == 5
21+
22+ # Test the long-name & short-name are the same
23+ assert CC_PortDirection.Unknown == CC_PortDirection.CC_B_PortDirectionIs_UNKNOWN
24+ assert CC_PortDirection.In == CC_PortDirection.CC_B_PortDirectionIs_in
25+ assert CC_PortDirection.Out == CC_PortDirection.CC_B_PortDirectionIs_out
26+ assert CC_PortDirection.BiDir == CC_PortDirection.CC_B_PortDirectionIs_bidirect
27+ assert CC_PortDirection.Master == CC_PortDirection.CC_B_PortDirectionIs_master
28+ assert CC_PortDirection.Slave == CC_PortDirection.CC_B_PortDirectionIs_slave
29+
30+def test_1b_portray_PortDirection():
31+ assert CCompare('CC_B_PortDirectionIs_UNKNOWN', CC_PortDirection.Unknown.portray_name())
32+ assert CCompare('CC_B_PortDirectionIs_in', CC_PortDirection.In.portray_name())
33+ assert CCompare('CC_B_PortDirectionIs_out', CC_PortDirection.Out.portray_name())
34+ assert CCompare('CC_B_PortDirectionIs_bidirect', CC_PortDirection.BiDir.portray_name())
35+ assert CCompare('CC_B_PortDirectionIs_master', CC_PortDirection.Master.portray_name())
36+ assert CCompare('CC_B_PortDirectionIs_slave', CC_PortDirection.Slave.portray_name())
37+
38+
39+def test_2a1_Port_defaults():
40+ n, t = "defaults", int
41+ p1 = CC_Port(name=n, type=t) # Only direction is optional
42+ assert p1.name == n
43+ assert p1.type is t
44+ assert p1.direction == CC_PortDirection.Unknown
45+
46+def test_2a1_Port_full():
47+ n, t = "full", float
48+ d=CC_PortDirection.In
49+ inp = CC_Port(name=n, type=t, direction=d)
50+ assert inp.name == n
51+ assert inp.type is t
52+ assert inp.direction == d
53+
54+
55+def test_2b1_portray_Port_name():
56+ port = CC_Port(name="aPort", type="no_relevant")
57+ assert CCompare('aPort', port.portray_name())
58+
59+def test_2b2a_portray_Port_NoType():
60+ port = CC_Port(name="=NoName", type=None)
61+ assert CCompare('NULL', port.portray_typePtr())
62+
63+@pytest.mark.filterwarnings("ignore:Using string .* port.types:DeprecationWarning")
64+def test_2b2b_portray_Port_strtype():
65+ port = CC_Port(name="=NoName", type="textType")
66+ assert CCompare('&cc_P_textType', port.portray_typePtr())
67+
68+@pytest.mark.filterwarnings("ignore:Using string .* port.types:DeprecationWarning")
69+def test_2b2c_portray_Port_inttype():
70+ port = CC_Port(name="=NoName", type=int)
71+ assert CCompare('&cc_P_int', port.portray_typePtr())
72+
73+@pytest.mark.filterwarnings("ignore:Using string .* port.types:DeprecationWarning")
74+def test_2b2d_portray_Port_floattype():
75+ port = CC_Port(name="=NoName", type=float)
76+ assert CCompare('&cc_P_float', port.portray_typePtr())
77+
78+from castle.writers.CC2Cpy.Protocol import * #CC_EventProtocol
79+
80+def test_2b2c_portray_Port_Protocol():
81+ proto = CC_EventProtocol("JustAProtocol", events=[], based_on=None)
82+ port = CC_Port(name="=NoName", type=proto)
83+ # Note: When a Port's type is a Protocol, than the port's portray_type is both
84+ ## the string 'cc_P_<xxxx>', and
85+ ## the portray_name of that protocol.
86+ ## We check both for now.
87+ assert CCompare('&cc_P_JustAProtocol', port.portray_typePtr())
88+ assert CCompare('&'+proto.portray_name(), port.portray_typePtr())
89+
90+
91+def test_BUG():
92+ proto = CC_EventProtocol("JustAProtocol", events=[], based_on=None)
93+ port = CC_Port(name="=NoName", type=proto)
94+ assert isinstance(port.type, CC_Base)
diff -r 6e0d853fa598 -r f1809062df46 pytst/writers/CC2Cpy/test_3c_CompClass.py
--- a/pytst/writers/CC2Cpy/test_3c_CompClass.py Tue Feb 21 21:37:27 2023 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
1-# (C) Albert Mietus, 2022, 2023. Part of Castle/CCastle project
2-
3-import logging; logger = logging.getLogger(__name__)
4-import pytest
5-from . import * # CCompare
6-
7-from castle.writers.CC2Cpy.CCbase import *
8-from castle.writers.CC2Cpy.CC_B_ComponentClass import CC_B_ComponentClass
9-
10-
11-from . import common
12-
13-def test_1a_render_empty():
14- compClass = CC_B_ComponentClass(common.emptyComp())
15- assert CCompare(common.ref_emptyClass, compClass.render_Fill_ComponentClass())
16-
17-def test_1a_render_demo2():
18- compClass = CC_B_ComponentClass(common.demo2Comp())
19- assert CCompare(common.ref_demo2Class, compClass.render_Fill_ComponentClass())
20-
21-def test_2_render_whitespace():
22- assert CCompare(common.ref_emptyClass, CC_B_ComponentClass(common.emptyComp()).render_Fill_ComponentClass())
23-
24-def test_3a_indent_empty():
25- verify_indents(common.ref_emptyComp, common.emptyComp().render)
26-
27-def test_3b_indent_demo():
28- verify_indents(common.ref_demo2Comp, common.demo2Comp().render)
29-
30-def test_3c_indent_sub():
31- verify_indents(common.ref_subComp, common.subComp(base=common.demo2Comp()).render)
32-
diff -r 6e0d853fa598 -r f1809062df46 pytst/writers/CC2Cpy/test_3c_CompImpl.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pytst/writers/CC2Cpy/test_3c_CompImpl.py Tue Feb 21 21:43:10 2023 +0100
@@ -0,0 +1,32 @@
1+# (C) Albert Mietus, 2022, 2023. Part of Castle/CCastle project
2+
3+import logging; logger = logging.getLogger(__name__)
4+import pytest
5+from . import * # CCompare
6+
7+from castle.writers.CC2Cpy.CCbase import *
8+from castle.writers.CC2Cpy.CC_B_ComponentClass import CC_B_ComponentClass
9+
10+
11+from . import common
12+
13+def test_1a_render_empty():
14+ compClass = CC_B_ComponentClass(common.emptyComp())
15+ assert CCompare(common.ref_emptyClass, compClass.render_Fill_ComponentClass())
16+
17+def test_1a_render_demo2():
18+ compClass = CC_B_ComponentClass(common.demo2Comp())
19+ assert CCompare(common.ref_demo2Class, compClass.render_Fill_ComponentClass())
20+
21+def test_2_render_whitespace():
22+ assert CCompare(common.ref_emptyClass, CC_B_ComponentClass(common.emptyComp()).render_Fill_ComponentClass())
23+
24+def test_3a_indent_empty():
25+ verify_indents(common.ref_emptyComp, common.emptyComp().render)
26+
27+def test_3b_indent_demo():
28+ verify_indents(common.ref_demo2Comp, common.demo2Comp().render)
29+
30+def test_3c_indent_sub():
31+ verify_indents(common.ref_subComp, common.subComp(base=common.demo2Comp()).render)
32+