From 87f359a6fd945ce40018720f5aaee6bdaf0bba6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwena=EBl=20Delaval?= Date: Tue, 17 Jul 2012 17:57:04 +0200 Subject: [PATCH] Added main to several tests Added main to tests Added dependency statics -> statics2 in scripts --- test/CTestTestfile.cmake | 4 ++-- test/good/counter.ept | 7 ++++++ test/good/current.ept | 22 ++++++++++++++++++ test/good/fbyfby2.ept | 7 +++++- test/good/foldi.ept | 15 +++++++++++- test/good/hierarchie.ept | 20 +++++++++++++++- test/good/itfusion.ept | 10 +++++++- test/good/linear.ept | 31 +++++++++++++++++++++---- test/good/linear_automata.ept | 21 +++++++++++------ test/good/linear_init.ept | 8 ++++++- test/good/linear_split.ept | 10 +++++++- test/good/linear_vars.ept | 13 ++++++++++- test/good/memalloc_clocks.ept | 9 ++++++- test/good/memalloc_record.ept | 7 +++++- test/good/memalloc_simple.ept | 13 ++++++++++- test/good/norm.ept | 5 ++++ test/good/parametrize.ept | 7 +++++- test/good/pre_tuple.ept | 9 ++++++- test/good/reinit.ept | 10 +++++++- test/good/sampling_stateful_output.ept | 11 ++++++++- test/good/sampling_stateful_output2.ept | 12 +++++++++- test/good/side_effet.ept | 15 ++++++++---- test/good/statics.ept | 4 ++++ test/good/statics2.ept | 4 ++++ test/good/t1.ept | 23 ++++++++++++++---- test/scripts/compile_gcc_run | 13 +++++++++++ 26 files changed, 273 insertions(+), 37 deletions(-) diff --git a/test/CTestTestfile.cmake b/test/CTestTestfile.cmake index 7291c71..73dffd5 100644 --- a/test/CTestTestfile.cmake +++ b/test/CTestTestfile.cmake @@ -69,8 +69,8 @@ ADD_TEST(compile_only_reinit "scripts/compile_only" "good/reinit.ept") ADD_TEST(compile_only_sampling_stateful_output2 "scripts/compile_only" "good/sampling_stateful_output2.ept") ADD_TEST(compile_only_sampling_stateful_output "scripts/compile_only" "good/sampling_stateful_output.ept") ADD_TEST(compile_only_side_effet "scripts/compile_only" "good/side_effet.ept") -ADD_TEST(compile_only_statics2 "scripts/compile_only" "good/statics2.ept") ADD_TEST(compile_only_statics "scripts/compile_only" "good/statics.ept") +ADD_TEST(compile_only_statics2 "scripts/compile_only" "good/statics2.ept") ADD_TEST(compile_only_t10 "scripts/compile_only" "good/t10.ept") ADD_TEST(compile_only_t11 "scripts/compile_only" "good/t11.ept") ADD_TEST(compile_only_t12 "scripts/compile_only" "good/t12.ept") @@ -140,8 +140,8 @@ ADD_TEST(compile_gcc_run_reinit "scripts/compile_gcc_run" "good/reinit.ept") ADD_TEST(compile_gcc_run_sampling_stateful_output2 "scripts/compile_gcc_run" "good/sampling_stateful_output2.ept") ADD_TEST(compile_gcc_run_sampling_stateful_output "scripts/compile_gcc_run" "good/sampling_stateful_output.ept") ADD_TEST(compile_gcc_run_side_effet "scripts/compile_gcc_run" "good/side_effet.ept") -ADD_TEST(compile_gcc_run_statics2 "scripts/compile_gcc_run" "good/statics2.ept") ADD_TEST(compile_gcc_run_statics "scripts/compile_gcc_run" "good/statics.ept") +ADD_TEST(compile_gcc_run_statics2 "scripts/compile_gcc_run" "good/statics2.ept") ADD_TEST(compile_gcc_run_t10 "scripts/compile_gcc_run" "good/t10.ept") ADD_TEST(compile_gcc_run_t11 "scripts/compile_gcc_run" "good/t11.ept") ADD_TEST(compile_gcc_run_t12 "scripts/compile_gcc_run" "good/t12.ept") diff --git a/test/good/counter.ept b/test/good/counter.ept index 95147c5..ea55b65 100644 --- a/test/good/counter.ept +++ b/test/good/counter.ept @@ -2,3 +2,10 @@ node counter(res: bool; tick: bool) returns (o: int) let o = if res then 0 else if tick then 1 -> pre o + 1 else 0 -> pre o; tel + +node main() returns (y:int) +var half:bool; +let + y = counter(false fby (y > 35), half); + half = true fby not half +tel diff --git a/test/good/current.ept b/test/good/current.ept index 7a31172..faaf98f 100644 --- a/test/good/current.ept +++ b/test/good/current.ept @@ -19,3 +19,25 @@ let y2 = internal_current(c,x); b = y = y2; tel + +node prod() returns (y:int;b:bool) +var x,y':int;c,b':bool; +let + x = 0 fby x + 1; + c = (x % 10) = 0; + (b',y') = use_current(c,x when c); + y = current(c,y'); + b = merge c b' (true fby b whenot c); +tel + +(* CHECK check *) +node check() returns (b:bool) +var y:int; +let + (y,b) = prod() +tel + +node main() returns (y:int;b:bool) +let + (y,b) = prod() +tel diff --git a/test/good/fbyfby2.ept b/test/good/fbyfby2.ept index 86199ef..126dc78 100644 --- a/test/good/fbyfby2.ept +++ b/test/good/fbyfby2.ept @@ -3,4 +3,9 @@ var x:bool; let o = x; x = true fby false fby x; -tel \ No newline at end of file +tel + +node main() returns (o:bool) +let + o = f(); +tel diff --git a/test/good/foldi.ept b/test/good/foldi.ept index b7d99f5..a7cf485 100644 --- a/test/good/foldi.ept +++ b/test/good/foldi.ept @@ -2,10 +2,23 @@ const n:int=42 fun f(a:bool; i:int; acc_in : bool) returns (acc_out : bool) let - acc_out = if i = 0 then false else (a & acc_in); + acc_out = if i = 0 then true else (a & acc_in); +tel + +fun for(a:bool; i:int; acc_in : bool) returns (acc_out : bool) +let + acc_out = if i = 0 then false else (a or acc_in); tel fun g(a: bool^n) returns (o:bool) let o = foldi<> f (a, true); tel + +node main() returns (o1,o2:bool) +var t:bool^n; +let + t = (true^n) fby (false^n) fby ([ true^n with [5]=false ]) fby ([ false^n with [12]=true ]) fby t; + o1 = g(t); + o2 = foldi<> for (t, true); +tel diff --git a/test/good/hierarchie.ept b/test/good/hierarchie.ept index 53bdd9d..6534b8c 100644 --- a/test/good/hierarchie.ept +++ b/test/good/hierarchie.ept @@ -38,6 +38,24 @@ let state State4 var l2: bool; do o1 = false; o2 = false; o3 = l2; o4 = false; l2 = true; - until i4 then State4 + until i4 then State1 end tel + +(* clock (0^(n-1)1) *) +node counter <>() returns (b:bool) +var c:int; +let + c = 1 fby if b then 1 else c + 1; + b = (c = n); +tel + +node main() returns (o1: bool; o2: bool; o3: bool; o4: bool) +var i1: bool; i2: bool; i3: bool; i4: bool; +let + i1 = counter<<7>>(); + i2 = counter<<9>>(); + i3 = counter<<13>>(); + i4 = counter<<17>>(); + (o1,o2,o3,o4) = ssm(i1,i2,i3,i4) +tel diff --git a/test/good/itfusion.ept b/test/good/itfusion.ept index 2cb714c..7b8fc3b 100644 --- a/test/good/itfusion.ept +++ b/test/good/itfusion.ept @@ -18,4 +18,12 @@ tel fun f3(a,b:int^n) returns (o:int^n) let o = map<> (+) (b, map<> inc (a)); -tel \ No newline at end of file +tel + +node main() returns (o:int^n) +var t1,t2:int^n; +let + t1 = f1 (1^n); + t2 = f2(t1, 2^n); + o = f3(t1,t2); +tel diff --git a/test/good/linear.ept b/test/good/linear.ept index 892afba..47d4b38 100644 --- a/test/good/linear.ept +++ b/test/good/linear.ept @@ -22,14 +22,37 @@ let u = a.[i] default 0.0; v = a.[j] default 0.0; a1 = [ a with [i] = v ]; - o = [ a1 with [j] = v]; + o = [ a1 with [j] = u ]; +tel + +fun plus (a:float;b:float) returns (c:float;d:float) +let + c = a +. b; + d = c; tel node shuffle(i_arr, j_arr:int^m; q:int) returns (v : float) -var t,t_next:float^n at r; +var t,t_next:float^n at r;last t_init:float^n;last d:float; let + automaton + state Init + do (t_init,d) = mapfold<> plus (1.0^n, 1.0) + until true then Noupdate + state Noupdate + do + end; t_next = fold<> (swap<>)(i_arr, j_arr, t); - init<> t = (0.0^n) fby t_next; + init<> t = t_init fby t_next; v = t_next.[q] default 0.0; -tel \ No newline at end of file +tel + +node main() returns (v:float) +var c,q:int;i,j:int^m; +let + c = 0 fby if c = n-6 then 0 else c + 1; + i = [c,c+1,c+2]; + j = [c+3,c+4,c+5]; + v = shuffle(i,j,q); + q = 0 fby if q = n-1 then 0 else q + 1; +tel diff --git a/test/good/linear_automata.ept b/test/good/linear_automata.ept index 57dd8de..5fc69d4 100644 --- a/test/good/linear_automata.ept +++ b/test/good/linear_automata.ept @@ -2,12 +2,12 @@ const n:int = 100 fun f(a:int^n at r) returns (o:int^n at r) let - o = [ a with [0] = 0 ] + o = [ a with [0] = 3 ] tel fun g(a:int^n at r) returns (o:int^n at r) let - o = [ a with [n-1] = 0 ] + o = [ a with [n-1] = 10 ] tel node autom(a:int^n at r) returns (o:int^n at r; u:int) @@ -15,18 +15,18 @@ let automaton state S1 do - o = f(a) + o = g(a) until true then S2 state S2 do - o = g(a) + o = f(a) until false then S1 end; u = a[0] tel -node autom_last() returns (u:int) +node autom_last() returns (u1,u2:int) var last o : int^n at r = 0^n; let automaton @@ -35,9 +35,16 @@ let until true then S2 state S2 + var u:int; do - o = g(last o) + (o,u) = autom(last o) until false then S1 end; - u = o[0] + u1 = o[0]; + u2 = o[n-1]; +tel + +node main() returns (u1,u2:int) +let + (u1,u2) = autom_last() tel diff --git a/test/good/linear_init.ept b/test/good/linear_init.ept index 278d99c..567ea09 100644 --- a/test/good/linear_init.ept +++ b/test/good/linear_init.ept @@ -20,4 +20,10 @@ let (init<> u, z) = map<> pp(0.0^n); v = [u with [n-1] = 0.0]; o = v[28] -tel \ No newline at end of file +tel + +node main() returns (o1,o2:float) +let + o1 = f(); + o2 = g(); +tel diff --git a/test/good/linear_split.ept b/test/good/linear_split.ept index 2f4c6e0..0edbd1a 100644 --- a/test/good/linear_split.ept +++ b/test/good/linear_split.ept @@ -8,4 +8,12 @@ let (u, v) = split c (a); x = [ u with [0] = 0 ]; o = merge c (On -> x) (Off -> v) -tel \ No newline at end of file +tel + +node main() returns (o:int^4) +var c:st;a:int^n at r; +let + o = (f(a,c))[0..3]; + c = Off fby Off fby On fby c; + init<> a = 1^n; +tel diff --git a/test/good/linear_vars.ept b/test/good/linear_vars.ept index c7cbf82..59e6c8b 100644 --- a/test/good/linear_vars.ept +++ b/test/good/linear_vars.ept @@ -22,4 +22,15 @@ var x:int^n at r; let init<> x = 1^n; o = fold<<3>> f2(a, f(f(x))); -tel \ No newline at end of file +tel + +fun plus(a,b:int) returns (c:int) +let c = a + b tel + +node main() returns (o:int^n) +var o1,o2:int^n; +let + o1 = g(); + o2 = lin_fold([13,17,23]); + o = map<> plus(o1,o2); +tel diff --git a/test/good/memalloc_clocks.ept b/test/good/memalloc_clocks.ept index 89ee750..f9c751f 100644 --- a/test/good/memalloc_clocks.ept +++ b/test/good/memalloc_clocks.ept @@ -3,4 +3,11 @@ var last t:int^100 = 1^100; let t = merge c ((last t) when c) ([((last t) whenot c) with [0] = 0]); o = t[0]; -tel \ No newline at end of file +tel + +node main() returns (o:int) +var c:bool; +let + c = true fby true fby false fby c; + o = f(c); +tel diff --git a/test/good/memalloc_record.ept b/test/good/memalloc_record.ept index b8a0b5a..0fb1a1e 100644 --- a/test/good/memalloc_record.ept +++ b/test/good/memalloc_record.ept @@ -11,4 +11,9 @@ let v = [ a.tab with [0] = 0 ]; u = [ v with [10] = 99 ]; o = { a with .tab = u } -tel \ No newline at end of file +tel + +node main() returns (o:array) +let + o = f(g({ tab = 1^100; size = 3 })); +tel diff --git a/test/good/memalloc_simple.ept b/test/good/memalloc_simple.ept index 2edd3ee..15b3451 100644 --- a/test/good/memalloc_simple.ept +++ b/test/good/memalloc_simple.ept @@ -7,7 +7,7 @@ let u = a.[i] default 0.0; v = a.[j] default 0.0; a1 = [ a with [i] = v ]; - o = [ a1 with [j] = v]; + o = [ a1 with [j] = u ]; tel node shuffle(i_arr, j_arr:int^m; q:int) @@ -41,3 +41,14 @@ let a1 = (0.0^n) fby [ a1 with [i when true(x)] = 0.0 ]; a2 = (0.0^n) fby [ a2 with [j when false(x)] = 0.0 ]; tel + +node main() returns (o1,o2:float^n) +var x:bool;i,j:int; +let + o1 = clocked(x,i,j,1.0^n); + o2 = clocked_reg(x,i,j,1.0^n); + x = true fby true fby false fby x; + i = 0 fby if i >= n then 0 else i + 2; + j = 0 fby if j >= n then 0 else i + 1; +tel + diff --git a/test/good/norm.ept b/test/good/norm.ept index 6e4f210..1885b9f 100644 --- a/test/good/norm.ept +++ b/test/good/norm.ept @@ -10,3 +10,8 @@ node m0() returns (o: int) let o = if true then if true then 1 else 2 else 3; tel + +node main() returns (o:int) +let + o = m0(); +tel diff --git a/test/good/parametrize.ept b/test/good/parametrize.ept index 36cc782..8987358 100644 --- a/test/good/parametrize.ept +++ b/test/good/parametrize.ept @@ -15,7 +15,7 @@ tel node h(a:int^n; b:int^z) returns (o,m:int) let o = g<>(a); - m = g<>(b); + m = g<>(b) + f(b); tel node l<>(a:int^m) returns (o:int^m) @@ -28,3 +28,8 @@ let o = map<> (l<>)(a); tel +node main() returns(o,m,v:int) +let + (o,m) = h(1^n, 2^z); + v = (p(3^n^n))[11][11] +tel diff --git a/test/good/pre_tuple.ept b/test/good/pre_tuple.ept index 577d220..98c2bf0 100644 --- a/test/good/pre_tuple.ept +++ b/test/good/pre_tuple.ept @@ -26,10 +26,17 @@ let o = a + x; tel +node main() returns (x,y,z:int) +let + x = f(1 fby if x > 1000 then 1 else x, true); + y = h(1 fby if y > 1000 then 1 else y, true fby false); + z = p(1 fby if z > 1000 then 1 else z, true); +tel + (* (v1, v2, ...) fby (e1, e2, ...) ----> (v1 fby e1, v2 fby e2, ...) -*) \ No newline at end of file +*) diff --git a/test/good/reinit.ept b/test/good/reinit.ept index 29bd844..557f669 100644 --- a/test/good/reinit.ept +++ b/test/good/reinit.ept @@ -6,4 +6,12 @@ var a1, a2:int^n at r; let (a1, a2) = split c (a); o = merge c (true -> reinit (a1, t_0)) (false -> [ a2 with [0] = 0 ]) -tel \ No newline at end of file +tel + +node main() returns (o:int^n) +var c:bool;a:int^n at r; +let + init<> a = 1^n; + c = true fby false fby c; + o = f(a, c) +tel diff --git a/test/good/sampling_stateful_output.ept b/test/good/sampling_stateful_output.ept index 32366a7..3bb9d09 100644 --- a/test/good/sampling_stateful_output.ept +++ b/test/good/sampling_stateful_output.ept @@ -17,4 +17,13 @@ node g(c :bool) returns (y,y2 :int) let y = nn(1) when c; y2 = ff(1) when c -tel \ No newline at end of file +tel + +node main() returns (y,y2:int) +var y',y'2:int;c:bool; +let + c = false fby false fby true fby c; + (y',y'2) = g(c); + (y,y2) = merge c (y',y'2) (0,0) +tel + diff --git a/test/good/sampling_stateful_output2.ept b/test/good/sampling_stateful_output2.ept index 90f0080..9af7816 100644 --- a/test/good/sampling_stateful_output2.ept +++ b/test/good/sampling_stateful_output2.ept @@ -17,4 +17,14 @@ var z :int; y:int; let z = 3; y = (0 fby z) when c; -tel \ No newline at end of file +tel + +node main() returns (x,y:int) +var c:bool; +let + x = f(0); + c = false fby false fby true fby c; + y = merge c (ff(0,c)) 0; + () = fff(0,c); +tel + diff --git a/test/good/side_effet.ept b/test/good/side_effet.ept index f0eb3a9..d071388 100644 --- a/test/good/side_effet.ept +++ b/test/good/side_effet.ept @@ -1,10 +1,15 @@ -node hello() returns (b:bool) -var tmp : bool; +unsafe node hello() returns (b:bool) let - tmp = (*printf("hello")*) true; + () = Iostream.printf("hello\n"); automaton - state A var ttmp :bool; do + state A do b = true; - ttmp = (*printf("hello")*) true; + () = Iostream.printf("hello\n"); end; tel + +unsafe node main() returns () +var b:bool; +let + b = hello(); +tel diff --git a/test/good/statics.ept b/test/good/statics.ept index 2bb07b1..8b2c137 100644 --- a/test/good/statics.ept +++ b/test/good/statics.ept @@ -29,3 +29,7 @@ let y = c + g<>() + i<>(); tel +node main() returns (y:int) +let + y = h() +tel diff --git a/test/good/statics2.ept b/test/good/statics2.ept index fd13fb9..36967d5 100644 --- a/test/good/statics2.ept +++ b/test/good/statics2.ept @@ -30,3 +30,7 @@ let y2 = c2 + Statics.g<>() + Statics.i<>(); tel +node main() returns (y,y2:int) +let + (y,y2) = h() +tel diff --git a/test/good/t1.ept b/test/good/t1.ept index dff140e..b09f2f8 100644 --- a/test/good/t1.ept +++ b/test/good/t1.ept @@ -34,10 +34,10 @@ node m(x: int) returns (o: int) let automaton state I - do o2 = 1 + do o2 = 2 unless (last o2 = 2) then J state J - do o2 = 3 + do o2 = 1 unless (last o2 = 1) then I end; o = o2; @@ -46,7 +46,7 @@ node m(x: int) returns (o: int) node h(z: int; x, y: int) returns (o2: int) var o1, o: int; let - (o1, o2) = if z<0 then (1, 2) else (3, 4); + (o1, o2) = if z<0 then (1, o) else (o, 4); o = 0 -> pre o + 2 tel @@ -91,7 +91,7 @@ node (++)(up, down: int) returns (o: int) until (down = 1) then Down | (down = 0) then Up state Down - do cpt = (last cpt) + 1 + do cpt = (last cpt) - 1 until (up = 1) then Up end; tel @@ -103,6 +103,21 @@ node f(x: bool) returns (y: bool) z = true -> if y then not (pre z) else pre z; tel +node main() returns (o1,o2,o3,o4,o5,o6,o7,o8,o9:int) +var x:int; +let + x = -10 fby if x = 10 then -10 else x + 1; + o1 = m0(); + o2 = mm(x); + o3 = mmm(0); + o4 = m(0); + o5 = h(x,0,0); + o6 = i(0,x); + o7 = j(0,0); + o8 = (++)((0 fby 1),(0 fby o9)); + o9 = if (f(false fby true)) then 13 else 17; +tel + (* let increasing(x) returns (o) do true -> x >= pre(x) + 1 done diff --git a/test/scripts/compile_gcc_run b/test/scripts/compile_gcc_run index ecf6476..e01ab01 100755 --- a/test/scripts/compile_gcc_run +++ b/test/scripts/compile_gcc_run @@ -36,6 +36,19 @@ if [[ ($heptroot == "t2") || ($heptroot == "t2open") ]]; then LD="$LD ../t1_c/[^_]*.o" fi +# Special case: statics2 needs statics + +if [[ ($heptroot == "statics") ]]; then + coption="$coption -c" +fi + +if [[ ($heptroot == "statics2") ]]; then + CC="$CC -I ../statics_c" + LD="$LD ../statics_c/[^_]*.o" +fi + + + echo $HEPTC $coption $heptprog if $HEPTC $coption $heptprog; then pushd ${heptroot}_c > /dev/null