Commit 16716997 authored by dbarbera's avatar dbarbera
Browse files

Added test case for built-in operators

parent 7e7a8e3e
EXAMPLES=test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 \
test11 test12 test-substrings test-expressions test-controlflow
test11 test12 test-substrings test-expressions test-controlflow \
test-operators
coverage:
for v in $(EXAMPLES) ; do make -C $$v coverage && mv $$v/.coverage* . \
......
all: test-ada
edit:
../../../opengeode.py operators.pr system_structure.pr
test-parse:
../../../opengeode.py operators.pr system_structure.pr --check
test-ada:
../../../opengeode.py operators.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 operators.ali
gnatlink test_ada.o operators.ali -lgnat -lm -o testcase
./testcase | diff expected -
test-llvm:
../../../opengeode.py operators.pr system_structure.pr --check --llvm
asn1.exe -c dataview-uniq.asn -typePrefix asn1Scc -equal
llc operators.ll
clang -c operators.s
clang -c dataview-uniq.c
clang -c test_llvm.c
clang operators.o dataview-uniq.o test_llvm.o -o testcase
./testcase | diff expected -
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))
FixSeqof ::= SEQUENCE (SIZE(3)) OF Integer
VarSeqof ::= SEQUENCE (SIZE(0..100)) OF Integer
Enum ::= ENUMERATED { one(12), two(13), three(111) }
Choice ::= CHOICE {
b BOOLEAN,
i Integer,
f Real
}
END
2 2.00000000000000E+00TRUEHELLO
2 2.00000000000000E+00TRUEHELLO
\ No newline at end of file
/* CIF PROCESS (140, 161), (150, 75) */
PROCESS operators;
/* CIF TEXT (286, 21), (303, 152) */
DCL i Integer := 2;
DCL f Real := 2.0;
DCL b Boolean := true;
DCL s CharString := 'HELLO';
DCL e Enum := one;
DCL fixSeqOf FixSeqof := {1, 2, 3};
DCL varSeqOf varSeqOf := {1, 2, 3};
DCL c Choice := i:2;
/* CIF ENDTEXT */
/* CIF START (73, 24), (100, 50) */
START;
/* CIF NEXTSTATE (73, 89), (100, 50) */
NEXTSTATE Wait;
/* CIF STATE (73, 89), (100, 50) */
STATE Wait;
/* CIF INPUT (74, 159), (100, 50) */
INPUT run;
/* CIF PROCEDURECALL (13, 224), (221, 35) */
CALL assert(abs(-i) = i, 'abs(-i) = i');
/* CIF PROCEDURECALL (-8, 274), (264, 35) */
CALL assert(abs(-f) = f, 'abs(-f) = f');
/* CIF PROCEDURECALL (12, 324), (224, 35) */
CALL assert(fix(f) = i, 'fix(f) = i');
/* CIF PROCEDURECALL (-1, 374), (251, 35) */
CALL assert(float(i) = f, 'float(i) = f');
/* CIF PROCEDURECALL (-47, 424), (343, 35) */
CALL assert(length(fixSeqOf) = 3, 'length(fixSeqOf) = 3');
/* CIF PROCEDURECALL (-51, 474), (350, 35) */
CALL assert(length(varSeqOf) = 3, 'length(varSeqOf) = 3');
/* CIF PROCEDURECALL (3, 524), (240, 35) */
CALL assert(num(e) = 12, 'num(e) = 12');
/* CIF PROCEDURECALL (-14, 574), (276, 35) */
CALL assert(power(i, 3) = 8, 'power(i, 3) = 8');
/* CIF PROCEDURECALL (24, 624), (200, 35) */
CALL writeln(i, f, b, s);
/* CIF PROCEDURECALL (24, 674), (200, 35) */
CALL write(i, f, b, s);
/* CIF NEXTSTATE (74, 724), (100, 50) */
NEXTSTATE Wait;
ENDSTATE;
ENDPROCESS operators;
\ No newline at end of file
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM operators;
SIGNAL run;
PROCEDURE assert;
FPAR
IN res Boolean,
IN msg CharString;
EXTERNAL;
CHANNEL c
FROM ENV TO operators WITH run;
ENDCHANNEL;
BLOCK operators;
SIGNALROUTE r
FROM ENV TO operators WITH run;
CONNECT c and r;
PROCESS operators REFERENCED;
ENDBLOCK;
ENDSYSTEM;
#include <stdio.h>
#include <stdlib.h>
#include "dataview-uniq.h"
extern void adainit();
extern void operators_run();
void operators_RI_assert(asn1SccBoolean *res, asn1SccCharString *msg) {
if (!*res) {
fprintf(stderr, "%.*s\n", (int)msg->nCount, msg->arr);
exit(1);
}
}
int main() {
adainit();
operators_run();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include "dataview-uniq.h"
extern void operators_startup();
extern void operators_run();
void operators_RI_assert(asn1SccBoolean *res, asn1SccCharString *msg) {
if (!*res) {
fprintf(stderr, "%.*s\n", (int)msg->nCount, msg->arr);
exit(1);
}
}
int main() {
operators_startup();
operators_run();
return 0;
}
......@@ -19,9 +19,10 @@ paths = [
'regression/test10',
'regression/test11',
'regression/test12',
'regression/test-substrings',
'regression/test-expressions',
'regression/test-controlflow',
'regression/test-expressions',
'regression/test-operators',
'regression/test-substrings',
]
......
Supports Markdown
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