author | Martin Pihrt <martinpihrt@gmail.com> |
Thu, 29 Feb 2024 09:36:52 +0100 | |
changeset 3902 | 03278d95e58a |
parent 3749 | fda6c1a37662 |
permissions | -rw-r--r-- |
3749
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
1 |
|
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
2 |
# Naive code generator for type convesion function XX_TO_YY testing |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
3 |
|
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
4 |
|
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
5 |
types = [ |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
6 |
("BOOL", "TRUE"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
7 |
("SINT", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
8 |
("USINT", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
9 |
("BYTE", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
10 |
("STRING", "'42'"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
11 |
("INT", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
12 |
("UINT", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
13 |
("WORD", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
14 |
("DINT", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
15 |
("UDINT", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
16 |
("DWORD", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
17 |
("LINT", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
18 |
("ULINT", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
19 |
("LWORD", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
20 |
("REAL", "42.0"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
21 |
("LREAL", "42.0"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
22 |
#("TIME", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
23 |
#("TOD", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
24 |
#("DATE", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
25 |
#("DT", "42"), |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
26 |
] |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
27 |
|
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
28 |
for tsrc, src_literal in types: |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
29 |
for tdest, dest_literal in types: |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
30 |
if tsrc == tdest: continue |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
31 |
s = f""" |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
32 |
RESULT := '{tsrc}_TO_{tdest}'; |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
33 |
IF {tsrc}_TO_{tdest}({tsrc}#{src_literal}) <> {tdest}#{dest_literal} THEN RETURN; END_IF; |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
34 |
""" |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
35 |
print(s) |
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
36 |
|
fda6c1a37662
Tests: Add preliminary IEC-61131 language test, to be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
37 |