Commit 6eff01a6 authored by dbarbera's avatar dbarbera
Browse files

Added test case for expressions

parent 13a686e1
all: test-ada
test-parse:
../../../opengeode.py expressions.pr system_structure.pr --check
test-ada:
../../../opengeode.py expressions.pr system_structure.pr --check --toAda
asn1.exe -Ada dataview-uniq.asn -typePrefix asn1Scc -equal
asn1.exe -c dataview-uniq.asn -typePrefix asn1Scc
gnatmake -c *.adb
gcc -c test_ada.c
gnatbind -n expressions.ali
gnatlink test_ada.o expressions.ali -lgnat -lm -o testcase
./testcase
clean:
rm -rf *.adb *.ads *.pyc runSpark.sh spark.idx *.o *.ali gnat.cfg examiner \
bin *.wrn *.gpr testcase *.ll *.s dataview-uniq.c dataview-uniq.h real.c xer.c \
ber.c acn.c asn1crt.c asn1crt.h
TASTE-Dataview DEFINITIONS ::=
BEGIN
Boolean ::= BOOLEAN
Integer ::= INTEGER(-9223372036854775808..9223372036854775807)
Real ::= REAL (-100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0 .. 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0)
CharString ::= OCTET STRING (SIZE(0..100))
IntegerFixSeqof ::= SEQUENCE (SIZE(3)) OF Integer
IntegerVarSeqof ::= SEQUENCE (SIZE(0..100)) OF Integer
Seq ::= SEQUENCE {
i Integer,
b Boolean,
f Real,
s CharString
}
NestedSeq ::= SEQUENCE {
a SEQUENCE {
b SEQUENCE {
c SEQUENCE {
d Integer
}
}
}
}
END
/* CIF PROCESS (145, 158), (150, 75) */
PROCESS expressions;
/* CIF TEXT (358, 168), (303, 168) */
DCL i Integer;
DCL f Real;
DCL b Boolean;
DCL s CharString;
DCL fixSeqOf1 IntegerFixSeqof;
DCL fixSeqOf2 IntegerFixSeqof;
DCL varSeqOf1 IntegerVarSeqof;
DCL varSeqOf2 IntegerVarSeqof;
DCL seq Seq;
DCL nestedSeq NestedSeq;
/* CIF ENDTEXT */
/* CIF START (0, 0), (100, 50) */
START;
/* CIF NEXTSTATE (0, 65), (100, 50) */
NEXTSTATE Wait;
/* CIF STATE (0, 65), (100, 50) */
STATE Wait;
/* CIF INPUT (1, 135), (100, 50) */
INPUT run;
/* CIF TASK (-150, 200), (402, 35) */
TASK '------------------------------- Binary expressions -------------------------------';
/* CIF TASK (5, 250), (90, 35) */
TASK b := true;
/* CIF PROCEDURECALL (-75, 300), (253, 35) */
CALL assert(b and true, 'b and true');
/* CIF PROCEDURECALL (-75, 350), (253, 35) */
CALL assert(b or false, 'b or false');
/* CIF PROCEDURECALL (-75, 400), (253, 35) */
CALL assert(b xor false, 'b xor false');
/* CIF TASK (14, 450), (73, 35) */
TASK i := 10;
/* CIF PROCEDURECALL (-50, 500), (203, 35) */
CALL assert(i + 1 = 11, 'i + 1 = 11');
/* CIF PROCEDURECALL (-43, 550), (188, 35) */
CALL assert(i - 1 = 9, 'i - 1 = 9');
/* CIF PROCEDURECALL (-49, 600), (201, 35) */
CALL assert(i * 2 = 20, 'i * 2 = 20');
/* CIF PROCEDURECALL (-43, 650), (188, 35) */
CALL assert(i / 2 = 5, 'i / 2 = 5');
/* CIF PROCEDURECALL (-64, 700), (230, 35) */
CALL assert(i mod 2 = 0, 'i mod 2 = 0');
/* CIF PROCEDURECALL (-61, 750), (224, 35) */
CALL assert(i rem 2 = 0, 'i rem 2 = 0');
/* CIF PROCEDURECALL (-29, 800), (161, 35) */
CALL assert(i < 20, 'i < 20');
/* CIF PROCEDURECALL (-37, 850), (176, 35) */
CALL assert(i <= 10, 'i <= 10');
/* CIF PROCEDURECALL (-37, 900), (176, 35) */
CALL assert(i >= 10, 'i >= 10');
/* CIF PROCEDURECALL (-37, 950), (176, 35) */
CALL assert(i > 5, 'i > 5');
/* CIF PROCEDURECALL (-29, 1000), (161, 35) */
CALL assert(i = 10, 'i = 10');
/* CIF PROCEDURECALL (-27, 1050), (156, 35) */
CALL assert(i /= 9, 'i /= 9');
/* CIF TASK (8, 1100), (85, 35) */
TASK f := 10.0;
/* CIF PROCEDURECALL (-74, 1150), (250, 35) */
CALL assert(f + 1.0 = 11.0, 'f + 1.0 = 11.0');
/* CIF PROCEDURECALL (-63, 1200), (228, 35) */
CALL assert(f - 1.0 = 9.0, 'f - 1.0 = 9.0');
/* CIF PROCEDURECALL (-73, 1250), (248, 35) */
CALL assert(f * 2.0 = 20.0, 'f * 2.0 = 20.0');
/* CIF PROCEDURECALL (-64, 1300), (230, 35) */
CALL assert(f / 2.0 = 5.0, 'f / 2.0 = 5.0');
/* CIF PROCEDURECALL (-49, 1350), (201, 35) */
CALL assert(f < 20.0, 'f < 20.0');
/* CIF PROCEDURECALL (-49, 1400), (201, 35) */
CALL assert(f <= 10.0, 'f <= 10.0');
/* CIF PROCEDURECALL (-49, 1450), (201, 35) */
CALL assert(f >= 10.0, 'f >= 10.0');
/* CIF PROCEDURECALL (-49, 1500), (201, 35) */
CALL assert(f > 5.0, 'f > 5.0');
/* CIF PROCEDURECALL (-42, 1550), (186, 35) */
CALL assert(f = 10.0, 'f = 10.0');
/* CIF PROCEDURECALL (-44, 1600), (191, 35) */
CALL assert(f /= 9.0, 'f /= 9.0');
/* CIF TASK (-29, 1650), (160, 35) */
TASK fixSeqOf1 := {1, 2, 3};
/* CIF TASK (-29, 1700), (160, 35) */
TASK fixSeqOf2 := {3, 4, 5};
/* CIF PROCEDURECALL (-82, 1750), (267, 35) */
CALL assert(2 in fixSeqOf1, '2 in fixSeqOf1');
/* CIF PROCEDURECALL (-112, 1800), (326, 35) */
CALL assert(not(4 in fixSeqOf1), 'not(4 in fixSeqOf1)');
/* CIF PROCEDURECALL (-137, 1850), (377, 35) */
CALL assert(fixSeqOf1 /= fixSeqOf2, 'fixSeqOf1 /= fixSeqOf2');
/* CIF TASK (-29, 1900), (160, 35) */
TASK fixSeqOf2 := {1, 2, 3};
/* CIF PROCEDURECALL (-132, 1950), (367, 35) */
CALL assert(fixSeqOf1 = fixSeqOf2, 'fixSeqOf1 = fixSeqOf2');
/* CIF TASK (-31, 2000), (164, 35) */
TASK varSeqOf1 := {1, 2, 3};
/* CIF TASK (-31, 2050), (164, 35) */
TASK varSeqOf2 := {4, 5, 6};
/* CIF PROCEDURECALL (-86, 2100), (274, 35) */
CALL assert(2 in varSeqOf1, '2 in varSeqOf1');
/* CIF PROCEDURECALL (-115, 2150), (333, 35) */
CALL assert(not(4 in varSeqOf1), 'not(4 in varSeqOf1)');
/* CIF PROCEDURECALL (-144, 2200), (391, 35) */
CALL assert(varSeqOf1 /= varSeqOf2, 'varSeqOf1 /= varSeqOf2');
/* CIF TASK (-80, 2250), (263, 35) */
TASK varSeqOf1 := varSeqOf1 // varSeqOf2;
/* CIF PROCEDURECALL (-130, 2300), (363, 35) */
CALL assert(length(varSeqOf1) = 6, 'lenght(varSeqOf1) = 6');
/* CIF PROCEDURECALL (-99, 2350), (300, 35) */
CALL assert(varSeqOf1(3) = 4, 'varSeqOf1(3) = 4');
/* CIF PROCEDURECALL (-99, 2400), (300, 35) */
CALL assert(varSeqOf1(4) = 5, 'varSeqOf1(4) = 5');
/* CIF PROCEDURECALL (-99, 2450), (300, 35) */
CALL assert(varSeqOf1(5) = 6, 'varSeqOf1(5) = 6');
/* CIF TASK (-32, 2500), (166, 35) */
TASK varSeqOf1 := {1, 2, 3};
/* CIF TASK (-31, 2550), (164, 35) */
TASK varSeqOf2 := {1, 2, 3};
/* CIF PROCEDURECALL (-139, 2600), (381, 35) */
CALL assert(varSeqOf1 = varSeqOf2, 'varSeqOf1 = varSeqOf2');
/* CIF TASK (-3, 2650), (108, 35) */
TASK s := 'HELLO';
/* CIF PROCEDURECALL (-191, 2700), (484, 35) */
CALL assert(s // s // s = 'HELLOHELLOHELLO', 's // s // s = "HELLOHELLOHELLO"');
/* CIF TASK (-148, 2750), (399, 35) */
TASK '------------------------------- Unary expressions -------------------------------';
/* CIF TASK (3, 2800), (95, 35) */
TASK b := false;
/* CIF PROCEDURECALL (-29, 2850), (160, 35) */
CALL assert(not b, 'not b');
/* CIF TASK (14, 2900), (73, 35) */
TASK i := 10;
/* CIF PROCEDURECALL (-37, 2950), (177, 35) */
CALL assert(-i = -10, '-i = -10');
/* CIF TASK (-151, 3000), (405, 35) */
TASK '------------------------------- Primary Expression -------------------------------';
/* CIF PROCEDURECALL (-84, 3050), (271, 35) */
CALL assert(((1 + 1) * 4) = 8, '((1 + 1) * 4) = 8');
/* CIF PROCEDURECALL (-157, 3100), (417, 35) */
CALL assert(if true then 1 else 2 fi = 1, 'if true then 1 else 2 fi = 1');
/* CIF PROCEDURECALL (-183, 3150), (468, 35) */
CALL assert(if false then 1.0 else 2.0 fi = 2.0, 'if false then 1.0 else 2.0 fi = 2.0');
/* CIF PROCEDURECALL (-475, 3200), (1052, 35) */
CALL assert(if false then false else (if true then (if false then false else true fi) else false fi) fi, 'if false then false else (if true then (if false then false else true fi) else false fi) fi');
/* CIF TASK (-183, 3250), (468, 35) */
TASK '------------------------------- Extended Primary Expressions -------------------------------';
/* CIF TASK (-30, 3300), (163, 35) */
TASK fixSeqOf1 := {2, 3, 4};
/* CIF PROCEDURECALL (-95, 3350), (293, 35) */
CALL assert(fixSeqOf1(1) = 3, 'fixSeqOf1(1) = 3');
/* CIF TASK (-31, 3400), (164, 35) */
TASK varSeqOf1 := {2, 3, 4};
/* CIF PROCEDURECALL (-99, 3450), (300, 35) */
CALL assert(varSeqOf1(1) = 3, 'varSeqOf1(1) = 3');
/* CIF TASK (-68, 3500), (239, 35) */
TASK seq := {i 1, b true, f 1.0, s 'HELLO'};
/* CIF PROCEDURECALL (-47, 3550), (196, 35) */
CALL assert(seq!i = 1, 'seq!i = 1');
/* CIF PROCEDURECALL (-69, 3600), (241, 35) */
CALL assert(seq!b = true, 'seq!b = true');
/* CIF PROCEDURECALL (-59, 3650), (221, 35) */
CALL assert(seq!f = 1.0, 'seq!f = 1.0');
/* CIF PROCEDURECALL (-93, 3700), (289, 35) */
CALL assert(seq!s = 'HELLO', 'seq!s = "HELLO"');
/* CIF TASK (-51, 3750), (204, 35) */
TASK nestedSeq := {a {b {c {d 9}}}};
/* CIF PROCEDURECALL (-126, 3800), (354, 35) */
CALL assert(nestedSeq!a!b!c!d = 9, 'nestedSeq!a!b!c!d = 9');
/* CIF NEXTSTATE (1, 3850), (100, 50) */
NEXTSTATE Wait;
ENDSTATE;
ENDPROCESS expressions;
\ No newline at end of file
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM expressions;
SIGNAL run;
PROCEDURE assert;
FPAR
IN res Boolean,
IN msg CharString;
EXTERNAL;
CHANNEL c
FROM ENV TO expressions WITH run;
ENDCHANNEL;
BLOCK expressions;
SIGNALROUTE r
FROM ENV TO expressions WITH run;
CONNECT c and r;
PROCESS expressions REFERENCED;
ENDBLOCK;
ENDSYSTEM;
#include <stdio.h>
#include <stdlib.h>
#include "dataview-uniq.h"
extern void adainit();
extern void expressions_run();
void expressions_RI_assert(asn1SccBoolean *res, asn1SccCharString *msg) {
if (!*res) {
fprintf(stderr, "%.*s\n", (int)msg->nCount, msg->arr);
exit(1);
}
}
int main() {
adainit();
expressions_run();
return 0;
}
......@@ -21,6 +21,7 @@ paths = [
'regression/test12',
'regression/test13',
'regression/test-substrings',
'regression/test-expressions',
]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment