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

Test priority handling in nested states

parent a3c79eb8
include ../shared.mk
all: test-ada test-llvm
edit:
$(OPENGEODE) challenge.pr system_structure.pr
test-parse:
$(OPENGEODE) challenge.pr system_structure.pr --check
test-ada: challenge.ali dataview-uniq.o | test_ada.o
$(GNATBIND) -n challenge.ali
$(GNATLINK) -o test_ada test_ada.o challenge.ali -lgnat -lm
./test_ada | diff expected -
test-c: challenge.c test_c.o dataview-uniq.o
$(CC) challenge.c -c -o challenge.o
$(CC) test_c.o dataview-uniq.o challenge.o -lm -o test_c
./test_c
./test_c | diff expected -
test-llvm: challenge.o dataview-uniq.o | test_llvm.o
$(CC) challenge.o dataview-uniq.o test_llvm.o -o test_llvm -lm
./test_llvm | diff expected -
test-vhdl : test-c
bambu challenge.c test_c.c --experimental-setup=BAMBU
coverage:
coverage run -p $(OPENGEODE) challenge.pr system_structure.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage
/* CIF PROCESS (150, 150), (150, 75) */
PROCESS challenge;
STATE nested;
SUBSTRUCTURE
STATE nested_1;
SUBSTRUCTURE
/* CIF PROCEDURE (104, 101), (70, 35) */
PROCEDURE exit;
/* CIF START (198, 116), (70, 35) */
START;
/* CIF PROCEDURECALL (142, 166), (181, 35) */
CALL writeln('exit nested_1');
/* CIF RETURN (215, 216), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF PROCEDURE (110, 183), (74, 35) */
PROCEDURE entry;
/* CIF START (105, 54), (70, 35) */
START;
/* CIF PROCEDURECALL (34, 104), (210, 35) */
CALL writeln('entering nested_1');
/* CIF RETURN (122, 154), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF START (245, 55), (70, 35) */
START;
/* CIF NEXTSTATE (233, 105), (93, 35) */
NEXTSTATE nested_2;
/* CIF STATE (276, 165), (93, 35) */
STATE nested_2;
/* CIF INPUT (287, 220), (70, 35) */
INPUT run;
/* CIF PROCEDURECALL (263, 270), (118, 35) */
CALL writeln('OK');
/* CIF NEXTSTATE (287, 320), (70, 35) */
NEXTSTATE -;
ENDSTATE;
ENDSUBSTRUCTURE;
/* CIF PROCEDURE (334, 58), (70, 35) */
PROCEDURE exit;
/* CIF START (76, 53), (70, 35) */
START;
/* CIF PROCEDURECALL (27, 103), (167, 35) */
CALL writeln('exit nested');
/* CIF RETURN (93, 153), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF PROCEDURE (340, 134), (74, 35) */
PROCEDURE entry;
/* CIF START (121, 85), (70, 35) */
START;
/* CIF PROCEDURECALL (57, 135), (196, 35) */
CALL writeln('entering nested');
/* CIF RETURN (138, 185), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF START (136, 68), (70, 35) */
START;
/* CIF NEXTSTATE (124, 118), (93, 35) */
NEXTSTATE nested_1;
/* CIF STATE (124, 118), (93, 35) */
STATE nested_1;
/* CIF INPUT (130, 173), (80, 35) */
INPUT go_off;
/* CIF RETURN (152, 223), (35, 35) */
RETURN ;
ENDSTATE;
ENDSUBSTRUCTURE;
/* CIF START (92, 76), (68, 37) */
START;
/* CIF NEXTSTATE (86, 128), (79, 35) */
NEXTSTATE nested;
/* CIF STATE (389, 131), (70, 35) */
STATE well;
ENDSTATE;
/* CIF STATE (86, 128), (79, 35) */
STATE nested;
/* CIF INPUT (145, 183), (70, 35) */
INPUT run;
/* CIF PROCEDURECALL (105, 233), (149, 35) */
CALL writeln('FAIL');
/* CIF NEXTSTATE (145, 283), (70, 35) */
NEXTSTATE -;
/* CIF CONNECT (51, 183), (0, 35) */
CONNECT ;
/* CIF NEXTSTATE (12, 233), (78, 35) */
NEXTSTATE well;
ENDSTATE;
ENDPROCESS challenge;
\ No newline at end of file
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
-- Set of TASTE predefined basic types
T-Int32 ::= INTEGER (-2147483648 .. 2147483647)
T-UInt32 ::= INTEGER (0 .. 4294967295)
T-Int8 ::= INTEGER (-128 .. 127)
T-UInt8 ::= INTEGER (0 .. 255)
T-Boolean ::= BOOLEAN
BitString ::= BIT STRING (SIZE(32))
OctString ::= OCTET STRING (SIZE(4))
SeqBit ::= SEQUENCE (SIZE(32)) OF BOOLEAN
SeqBit2 ::= SEQUENCE (SIZE(1..32)) OF BOOLEAN
END
TASTE-Dataview DEFINITIONS ::=
BEGIN
IMPORTS T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean FROM TASTE-BasicTypes;
-- A few simple types to start with ASN.1
challenge T-UInt32 ::= 18
bound T-UInt32 ::= 1000000
nb-bit T-UInt32 ::= 20
val-max T-UInt32 ::= 1048575
count-max T-UInt32 ::= 524288
exceed-nb T-UInt32 ::= 48575
CountTab ::= SEQUENCE (SIZE(nb-bit)) OF T-UInt32
END
entering nested
entering nested_1
exit nested_1
exit nested
entering nested
entering nested_1
exit nested_1
exit nested
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM challenge;
PROCEDURE pow COMMENT '#c_predef';
FPAR
IN a T_UInt32,
IN b T_UInt32,
IN/OUT res T_UInt32;
EXTERNAL;
SIGNAL run;
SIGNAL go_off;
SIGNAL any_one;
signal any_two;
CHANNEL c
FROM ENV TO challenge WITH run, go_off, any_one, any_two;
ENDCHANNEL;
BLOCK challenge;
SIGNALROUTE r
FROM ENV TO challenge WITH run, go_off, any_one, any_two;
CONNECT c and r;
PROCESS challenge REFERENCED;
ENDBLOCK;
ENDSYSTEM;
#include <math.h>
#include <stdio.h>
/* Ada code external interface */
extern void challenge_run();
extern void challenge_go_off();
extern int adainit();
//extern long long l_result;
/* Provide code called by the Ada state machine as external procedure */
void challenge_RI_pow(long long *a, long long *b, long long *res)
{
*res = (long long)pow((double)*a, (double)*b);
}
int main()
{
adainit();
challenge_run();
challenge_go_off();
return 0;
}
int main()
{
// CInit();
runTransition(0);
run();
go_off();
return 0;
}
#include <math.h>
#include <stdio.h>
/* Ada code external interface */
extern void challenge_run();
extern void challenge_go_off();
extern int challenge_startup();
//extern long long l_result;
/* Provide code called by the Ada state machine as external procedure */
void challenge_RI_pow(long long *a, long long *b, long long *res)
{
*res = (long long)pow((double)*a, (double)*b);
}
int main()
{
challenge_startup();
challenge_run();
challenge_go_off();
return 0;
}
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