Commit ad11aa98 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Test shortcircuit operator (test6)

parent 994c2754
...@@ -7,6 +7,11 @@ test-ada: ...@@ -7,6 +7,11 @@ test-ada:
../../../opengeode.py --toAda myfunction.pr system_structure.pr ../../../opengeode.py --toAda myfunction.pr system_structure.pr
asn1.exe -Ada dataview-uniq.asn -typePrefix asn1Scc -equal asn1.exe -Ada dataview-uniq.asn -typePrefix asn1Scc -equal
gnatmake -c myfunction.adb gnatmake -c myfunction.adb
gcc -c test.c
gnatbind -n myfunction.ali
gnatlink -o testcase test.o myfunction.ali -lgnat
./testcase
./testcase | diff expected -
coverage: coverage:
coverage run -p ../../../opengeode.py myfunction.pr system_structure.pr --toAda coverage run -p ../../../opengeode.py myfunction.pr system_structure.pr --toAda
......
[C Code] Running test
OK
...@@ -22,7 +22,7 @@ dcl someInt t_uInt8 := 2; ...@@ -22,7 +22,7 @@ dcl someInt t_uInt8 := 2;
-- To test 'op_not' -- To test 'op_not'
dcl opnot T_boolean := not true; dcl opnot T_boolean := not true;
/* CIF ENDTEXT */ /* CIF ENDTEXT */
/* CIF PROCEDURE (891, 490), (91, 35) */ /* CIF PROCEDURE (982, 490), (91, 35) */
PROCEDURE factorial; PROCEDURE factorial;
/* CIF TEXT (29, 42), (215, 48) */ /* CIF TEXT (29, 42), (215, 48) */
fpar in N MyInteger, fpar in N MyInteger,
...@@ -41,52 +41,61 @@ endfor; ...@@ -41,52 +41,61 @@ endfor;
ENDPROCEDURE; ENDPROCEDURE;
/* CIF START (591, 0), (100, 50) */ /* CIF START (591, 0), (100, 50) */
START; START;
/* CIF DECISION (516, 65), (250, 50) */ /* CIF TASK (586, 65), (110, 35) */
DECISION someint = 5 and then somereal=1.1 TASK someInt := 0;
or else someint = 6; /* CIF DECISION (504, 115), (273, 87) */
/* CIF ANSWER (561, 135), (70, 23) */ DECISION someint /=0 and then (10 / someInt > 0)
or else someint = 0
/* CIF COMMENT (793, 124), (179, 68) */
COMMENT 'Using "and else" is the
short-circuit form. The
second part should not
be evaluated.';
/* CIF ANSWER (561, 222), (70, 23) */
(true): (true):
/* CIF ANSWER (651, 135), (70, 23) */ /* CIF TASK (541, 260), (110, 35) */
TASK someInt := 5;
/* CIF PROCEDURECALL (537, 310), (117, 38) */
CALL writeln('OK');
/* CIF ANSWER (664, 222), (70, 23) */
(false): (false):
ENDDECISION; ENDDECISION;
/* CIF NEXTSTATE (591, 183), (100, 50) */ /* CIF NEXTSTATE (591, 363), (100, 50) */
NEXTSTATE Wait; NEXTSTATE Wait;
/* CIF STATE (591, 183), (100, 50) */ /* CIF STATE (591, 363), (100, 50) */
STATE Wait; STATE Wait;
/* CIF INPUT (810, 253), (100, 50) */ /* CIF INPUT (810, 433), (100, 50) */
INPUT mytimer; INPUT mytimer;
/* CIF PROCEDURECALL (792, 318), (135, 50) */ /* CIF PROCEDURECALL (769, 498), (182, 50) */
CALL writeln CALL writeln('timer expired');
('timer expired'); /* CIF PROCEDURECALL (780, 563), (160, 35) */
/* CIF PROCEDURECALL (780, 383), (160, 35) */
CALL factorial(3, someint); CALL factorial(3, someint);
/* CIF NEXTSTATE (810, 433), (100, 50) */ /* CIF NEXTSTATE (810, 613), (100, 50) */
NEXTSTATE Wait; NEXTSTATE Wait;
/* CIF INPUT (450, 253), (198, 50) */ /* CIF INPUT (450, 433), (198, 50) */
INPUT start_something (toto); INPUT start_something (toto);
/* CIF OUTPUT (414, 318), (270, 50) */ /* CIF OUTPUT (414, 498), (270, 50) */
OUTPUT result_data((toto+1) mod 2147483647); OUTPUT result_data((toto+1) mod 2147483647);
/* CIF PROCEDURECALL (474, 383), (150, 50) */ /* CIF PROCEDURECALL (474, 563), (150, 50) */
CALL writeln CALL writeln
('Hello Toto', toto); ('Hello Toto', toto);
/* CIF PROCEDURECALL (483, 448), (132, 50) */ /* CIF PROCEDURECALL (451, 628), (196, 50) */
CALL set_timer CALL set_timer(1000, myTimer);
(1000, myTimer); /* CIF TASK (391, 693), (316, 35) */
/* CIF TASK (391, 513), (316, 35) */
TASK someReal := power(someReal, someInt mod 1); TASK someReal := power(someReal, someInt mod 1);
/* CIF PROCEDURECALL (379, 563), (340, 35) */ /* CIF PROCEDURECALL (379, 743), (340, 35) */
CALL writeln('1.5 ** 2 == ', someReal, ' (should be 2.25 )'); CALL writeln('1.5 ** 2 == ', someReal, ' (should be 2.25 )');
/* CIF TASK (448, 613), (201, 35) */ /* CIF TASK (448, 793), (201, 35) */
TASK someReal := float(someInt); TASK someReal := float(someInt);
/* CIF TASK (428, 663), (241, 35) */ /* CIF TASK (428, 843), (241, 35) */
TASK someInt := fix(someReal) mod 255; TASK someInt := fix(someReal) mod 255;
/* CIF TASK (473, 713), (152, 35) */ /* CIF TASK (473, 893), (152, 35) */
TASK opnot := not opnot; TASK opnot := not opnot;
/* CIF TASK (470, 763), (157, 35) */ /* CIF TASK (470, 943), (157, 35) */
TASK someint := -someint; TASK someint := -someint;
/* CIF TASK (467, 813), (164, 35) */ /* CIF TASK (467, 993), (164, 35) */
TASK someint := (-8) mod 5; TASK someint := (-8) mod 5;
/* CIF NEXTSTATE (498, 863), (102, 50) */ /* CIF NEXTSTATE (498, 1043), (102, 50) */
NEXTSTATE wait; NEXTSTATE wait;
ENDSTATE; ENDSTATE;
ENDPROCESS myfunction; ENDPROCESS myfunction;
\ No newline at end of file
#include <math.h>
#include <stdio.h>
extern void adainit();
void myfunction_RI_result_data(long long *val)
{
printf("[C] result_data: %lld\n", *val);
}
void myfunction_RI_set_mytimer(long long *val)
{
printf("[C] SET MyTimer: %lld\n", *val);
}
void myfunction_RI_reset_mytimer()
{
printf("RESET MyTimer\n");
}
int main()
{
printf("[C Code] Running test\n");
adainit();
return 0;
}
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