Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Révision | 7b4046efaf011309d027334fe0e5c120d7736f47 (tree) |
---|---|
l'heure | 2024-04-10 22:05:34 |
Auteur | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
ASIS/refactored
@@ -4,16 +4,12 @@ | ||
4 | 4 | PYREVERSE_PKGS = castle/aigr castle/aigr.machinery |
5 | 5 | |
6 | 6 | LAST = \ |
7 | - pytst/test_3_namespaces.py \ | |
8 | - pytst/test_2c_GenericProtocols.py \ | |
9 | 7 | # |
10 | 8 | CURRENT = \ |
11 | - pytst/machinery/test_0_dataclass.py \ | |
12 | - pytst/machinery/test_0.py \ | |
13 | 9 | # |
14 | 10 | TODO = \ |
15 | - pytst/test_SpecialiseGenerics.py \ | |
16 | - pytst/test_0_AIGR.py \ | |
11 | + pytst/test_3_namespaces.py \ | |
12 | + pytst/machinery/test_9_todo.py \ | |
17 | 13 | # |
18 | 14 | |
19 | 15 | TOPd=../../ |
@@ -1,72 +0,0 @@ | ||
1 | -# (C) Albert Mietus, 2024. Part of Castle/CCastle project | |
2 | - | |
3 | -"""No functional tests; only testing to instantiate the classes in Machinery""" | |
4 | - | |
5 | -import pytest | |
6 | - | |
7 | -from castle.aigr import machinery | |
8 | - | |
9 | -class Demo_DirectCall(machinery.machinery): | |
10 | - """Just a demo""" | |
11 | - | |
12 | -def test_Abstact_machinery(): | |
13 | - m = machinery.machinery() | |
14 | - assert m.delegate is None | |
15 | - | |
16 | -def test_DC_machinery(): | |
17 | - m = machinery.machinery(delegate=Demo_DirectCall) | |
18 | - assert m.delegate is Demo_DirectCall | |
19 | - | |
20 | -def test_send_proto_OutPort_Dummy(): | |
21 | - o = machinery.send_proto(outport='Dummy') | |
22 | - assert o.outport=='Dummy' | |
23 | - | |
24 | -def test_send_proto_needsOutPort(): | |
25 | - with pytest.raises(TypeError, match="""'outport'"""): | |
26 | - o = machinery.send_proto() | |
27 | - | |
28 | -def test_ToDo__sendStreamd(): | |
29 | - with pytest.raises(NotImplementedError, match='ToDo'): | |
30 | - machinery.sendStream(outport='*') | |
31 | - | |
32 | -def test_ToDo__sendData(): | |
33 | - with pytest.raises(NotImplementedError, match='ToDo'): | |
34 | - machinery.sendData(outport='*') | |
35 | - | |
36 | -def test_sendEvent_CastleCode(): | |
37 | - """ CastleCode (sieve/basic) Generator:: `StartSieve.runTo(max) on .controll` | |
38 | - ``.outlet.input(i);`` | |
39 | - """ | |
40 | - o = machinery.sendEvent(outport='self.outlet', event='input', arguments=('i',)) | |
41 | - assert o.outport == 'self.outlet' | |
42 | - assert o.event == 'input' | |
43 | - assert len(o.arguments)==1 | |
44 | - assert o.arguments[0]=='i' | |
45 | - | |
46 | -def test_connection_CastleCode(): | |
47 | - """CastleCode (sieve/basic) Main:: `init()` | |
48 | - ``.generator.outlet = .finder.newPrime;`` | |
49 | - """ | |
50 | - o = machinery.connection(outport='self.generator.outlet', inport='self.finder.newPrime') | |
51 | - assert o.outport == 'self.generator.outlet' | |
52 | - assert o.inport == 'self.finder.newPrime' | |
53 | - | |
54 | -def test_connection_bothPortsNeeded(): | |
55 | - with pytest.raises(TypeError, match="'inport'"): | |
56 | - machinery.connection(outport='Dummy') | |
57 | - with pytest.raises(TypeError, match="'outport'"): | |
58 | - machinery.connection(inport='Dummy') | |
59 | - with pytest.raises(TypeError, match='2 required keyword-only arguments'): | |
60 | - machinery.connection() | |
61 | - | |
62 | -def test_DispatchTable(): | |
63 | - o = machinery.DispatchTable(handlers=[]) | |
64 | - assert len(o.handlers) == 0 # trivial test -- see eDispatchTable | |
65 | - | |
66 | -def test_eDispatchTable(): | |
67 | - o = machinery.eDispatchTable(handlers=['callable0', 'callable1',]) | |
68 | - assert o.handlers[0] == 'callable0' | |
69 | - assert o.handlers[1] == 'callable1' | |
70 | - assert len(o.handlers) == 2 | |
71 | - | |
72 | - |
@@ -0,0 +1,72 @@ | ||
1 | +# (C) Albert Mietus, 2024. Part of Castle/CCastle project | |
2 | + | |
3 | +"""No functional tests; only testing to instantiate the classes in Machinery""" | |
4 | + | |
5 | +import pytest | |
6 | + | |
7 | +from castle.aigr import machinery | |
8 | + | |
9 | +class Demo_DirectCall(machinery.machinery): | |
10 | + """Just a demo""" | |
11 | + | |
12 | +def test_Abstact_machinery(): | |
13 | + m = machinery.machinery() | |
14 | + assert m.delegate is None | |
15 | + | |
16 | +def test_DC_machinery(): | |
17 | + m = machinery.machinery(delegate=Demo_DirectCall) | |
18 | + assert m.delegate is Demo_DirectCall | |
19 | + | |
20 | +def test_send_proto_OutPort_Dummy(): | |
21 | + o = machinery.send_proto(outport='Dummy') | |
22 | + assert o.outport=='Dummy' | |
23 | + | |
24 | +def test_send_proto_needsOutPort(): | |
25 | + with pytest.raises(TypeError, match="""'outport'"""): | |
26 | + o = machinery.send_proto() | |
27 | + | |
28 | +def test_ToDo__sendStreamd(): | |
29 | + with pytest.raises(NotImplementedError, match='ToDo'): | |
30 | + machinery.sendStream(outport='*') | |
31 | + | |
32 | +def test_ToDo__sendData(): | |
33 | + with pytest.raises(NotImplementedError, match='ToDo'): | |
34 | + machinery.sendData(outport='*') | |
35 | + | |
36 | +def test_sendEvent_CastleCode(): | |
37 | + """ CastleCode (sieve/basic) Generator:: `StartSieve.runTo(max) on .controll` | |
38 | + ``.outlet.input(i);`` | |
39 | + """ | |
40 | + o = machinery.sendEvent(outport='self.outlet', event='input', arguments=('i',)) | |
41 | + assert o.outport == 'self.outlet' | |
42 | + assert o.event == 'input' | |
43 | + assert len(o.arguments)==1 | |
44 | + assert o.arguments[0]=='i' | |
45 | + | |
46 | +def test_connection_CastleCode(): | |
47 | + """CastleCode (sieve/basic) Main:: `init()` | |
48 | + ``.generator.outlet = .finder.newPrime;`` | |
49 | + """ | |
50 | + o = machinery.connection(outport='self.generator.outlet', inport='self.finder.newPrime') | |
51 | + assert o.outport == 'self.generator.outlet' | |
52 | + assert o.inport == 'self.finder.newPrime' | |
53 | + | |
54 | +def test_connection_bothPortsNeeded(): | |
55 | + with pytest.raises(TypeError, match="'inport'"): | |
56 | + machinery.connection(outport='Dummy') | |
57 | + with pytest.raises(TypeError, match="'outport'"): | |
58 | + machinery.connection(inport='Dummy') | |
59 | + with pytest.raises(TypeError, match='2 required keyword-only arguments'): | |
60 | + machinery.connection() | |
61 | + | |
62 | +def test_DispatchTable(): | |
63 | + o = machinery.DispatchTable(handlers=[]) | |
64 | + assert len(o.handlers) == 0 # trivial test -- see eDispatchTable | |
65 | + | |
66 | +def test_eDispatchTable(): | |
67 | + o = machinery.eDispatchTable(handlers=['callable0', 'callable1',]) | |
68 | + assert o.handlers[0] == 'callable0' | |
69 | + assert o.handlers[1] == 'callable1' | |
70 | + assert len(o.handlers) == 2 | |
71 | + | |
72 | + |
@@ -0,0 +1,17 @@ | ||
1 | +# (C) Albert Mietus, 2024. Part of Castle/CCastle project | |
2 | + | |
3 | + | |
4 | +import pytest | |
5 | +from castle.aigr import machinery | |
6 | + | |
7 | + | |
8 | +@pytest.mark.skip("\t sendStream: Other protocol then Event are not planned yet") | |
9 | +def test_sendStream(): | |
10 | + assert False | |
11 | +@pytest.mark.skip("\t sendData: Other protocol then Event are not planned yet") | |
12 | +def test_sendData(): | |
13 | + assert False | |
14 | + | |
15 | +@pytest.mark.skip("\t Handlers in eDispatchTable: The Handler AIGR isn't defined") | |
16 | +def test_DispatchTables_Handlers(): | |
17 | + assert False |