Added some tests file

- Arrays, parametrized nodes
- hierarchie.ept is a node with nested automaton
(generated a lot of variables, good test for 
performance)
This commit is contained in:
Cédric Pasteur 2010-07-09 10:35:54 +02:00
parent 3153a8f241
commit 87cb705fcb
5 changed files with 176 additions and 0 deletions

39
test/good/array1.ept Normal file
View file

@ -0,0 +1,39 @@
const n:int = 42
const m:int = 52
node concatenate(a:int^n; b:int^m) returns (o1, o2: int^(n+m))
let
o1 = a @ b;
o2 = b @ a;
tel
(*
node slicing (a:int^n) returns (u1,u2 : int^3)
let
u1 = a[0 .. 2];
u2 = a[3 .. 5];
tel
node elt (a:int^m) returns (o:int^m)
var x : int;
let
x = a[2] + 1;
o = [ a with [1] = x ];
tel
node elt_dyn (a:int^m; i:int) returns (o:int^m)
var x : int;
let
x = a.[i] default 3;
o = [ a with [1] = x ];
tel
node ten (i: int) returns (o:int^m)
let
o = i^m;
tel
node constant(a,b:int) returns (o:int^4)
let
o = [a,b,a,b];
tel
*)

19
test/good/array2.ept Normal file
View file

@ -0,0 +1,19 @@
const n:int = 43
node f(a:int^n; i:int) returns (o:int^n; m:int)
let
m = a.[i] default 0;
o = i^n;
tel
node sumdup (a, acc_in:int) returns (o:int; acc_out:int)
let
acc_out = acc_in + a;
o = acc_out;
tel
node p(a:int^n) returns (o:int^n)
var acc:int;
let
(o, acc) = mapfold sumdup <<n>>(a, 0);
tel

View file

@ -0,0 +1,45 @@
const n:int = 42
node plusone(a:int) returns (o:int)
let
o = a+1;
tel
node g(a:int^n) returns (o:int^n)
let
o = map plusone <<n>>(a);
tel
node sum_acc (a, acc_in:int) returns (acc_out:int)
let
acc_out = acc_in + a;
tel
node h(a:int^n) returns (m:int)
let
m = fold sum_acc <<n>>(a, 0);
tel
node sum_dup (a, acc_in:int) returns (o:int; acc_out:int)
let
acc_out = acc_in + a;
o = acc_out;
tel
node p(a:int^n) returns (o:int^n)
var acc:int;
let
(o, acc) = mapfold sum_dup <<n>>(a, 0);
tel
node k(a,b:int^n) returns (o:int^n)
let
o = map (+) <<n>>(a,b);
tel
node iter_reset(a:int^n; r:bool) returns (o:int^n)
let
reset
o = map plusone <<n>>(a);
every r
tel

43
test/good/hierarchie.ept Normal file
View file

@ -0,0 +1,43 @@
node ssm(i1: bool; i2: bool; i3: bool; i4: bool)
returns (o1: bool; o2: bool; o3: bool; o4: bool)
let
automaton
state State1
do o1 = false; o2 = false; o3 = false; o4 = false
until i1 then TMP12
unless i2 then TMP11
state TMP11
do o1 = false; o2 = true; o3 = false; o4 = false;
until true then State3
state TMP12
do o1 = true; o2 = true; o3 = false; o4 = false;
until true then State2
state State3
var last end1: bool = false; last end2: bool = false;
do o1 = false; o2 = false; o3 = false; o4 = false;
automaton
state State1_1
do until i3 then State2_1
state State2_1
do end1 = true;
end;
automaton
state State1_2
do unless i4 then State2_2
state State2_2
do end2 = true
end
until end1 & end2 then State1
unless i1 then State4
| i2 then State2
state State2
var l1: bool;
do o1 = false; o2 = false; o3 = false; o4 = l1; l1 = true;
until i4 then State4
state State4
var l2: bool;
do o1 = false; o2 = false; o3 = l2; o4 = false; l2 = true;
until i4 then State4
end
tel

30
test/good/parametrize.ept Normal file
View file

@ -0,0 +1,30 @@
const n:int = 42
const l:int = 2
const z:int = n + 3
node f(a:int^z) returns (m:int)
let
m = a[1]
tel
node g<<m:int>>(a:int^m) returns (o:int)
let
o = a[12 - l] + m;
tel
node h(a:int^n; b:int^z) returns (o,m:int)
let
o = g<<n>>(a);
m = g<<z>>(b);
tel
node l<<m:int>>(a:int^m) returns (o:int^m)
let
o = [ a with [11] = 0 ];
tel
node p(a:int^n^n) returns (o:int^n^n)
let
o = map (l<<n>>) <<n>>(a);
tel