From 1d6feeef54a05cdca63689c313a031a3d1dacb65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9onard=20G=C3=A9rard?= Date: Mon, 23 May 2011 14:04:11 +0200 Subject: [PATCH] some more tests --- test/async/pipline_a.ept | 2 +- test/async/rapide_lent.ept | 2 +- test/async/rapide_lent_a.ept | 2 +- test/async/tt.ept | 2 +- test/bad/bad_flatten.ept | 2 +- test/bad/t2.ept | 2 +- test/bad/t3.ept | 6 +++--- test/bad/t4.ept | 8 +++---- test/bad/t5.ept | 22 +++++++++---------- test/bad/when_merge1.ept | 2 +- test/good/array2.ept | 6 +++--- test/good/array_fill.ept | 2 +- test/good/autohiera.ept | 2 +- test/good/autohiera2.ept | 2 +- test/good/flatten.ept | 2 +- test/good/or_keep.ept | 18 ++++++++-------- test/good/t.ept | 2 +- test/good/t1.ept | 14 ++++++------ test/good/t15.ept | 2 +- test/good/t16.ept | 2 +- test/good/t2.ept | 4 ++-- test/good/t2open.ept | 2 +- test/good/t3.ept | 6 +++--- test/good/t6.ept | 8 +++---- test/good/tt.ept | 33 ++++++++++++++++++++--------- test/good/ttt.ept | 7 ++++++ test/good/tttt.ept | 6 ++++++ test/good/when_merge1.ept | 2 +- test/image_filters/convolutions.ept | 30 +++++++++++++------------- test/image_filters/pip.ept | 2 +- tools/enforce_style.sh | 2 +- 31 files changed, 115 insertions(+), 89 deletions(-) create mode 100644 test/good/ttt.ept create mode 100644 test/good/tttt.ept diff --git a/test/async/pipline_a.ept b/test/async/pipline_a.ept index 501ad72..0f98593 100644 --- a/test/async/pipline_a.ept +++ b/test/async/pipline_a.ept @@ -27,4 +27,4 @@ let nf = normalized_movie<<100>>(f); r = mean<<100>>(nf) tel - + diff --git a/test/async/rapide_lent.ept b/test/async/rapide_lent.ept index ac0aa53..cf53ad9 100644 --- a/test/async/rapide_lent.ept +++ b/test/async/rapide_lent.ept @@ -13,7 +13,7 @@ let cpt = size fby (if big_step then size else cpt - 1); y = merge big_step (true -> 0 -> (pre (lent(size)))) - (false -> 0 fby y when false(big_step)); + (false -> 0 fby y when false(big_step)); z = do_stuff(1) - y; tel diff --git a/test/async/rapide_lent_a.ept b/test/async/rapide_lent_a.ept index 1c53a99..76bd479 100644 --- a/test/async/rapide_lent_a.ept +++ b/test/async/rapide_lent_a.ept @@ -13,7 +13,7 @@ let cpt = size fby (if big_step then size else cpt - 1); y = merge big_step (true -> 0 -> !(pre (async lent(size)))) - (false -> 0 fby y when false(big_step)); + (false -> 0 fby y when false(big_step)); z = do_stuff(1) - y; tel diff --git a/test/async/tt.ept b/test/async/tt.ept index e77a98c..ea901e8 100644 --- a/test/async/tt.ept +++ b/test/async/tt.ept @@ -9,4 +9,4 @@ let t = async 0 fby async counter(false,true); b = counter(false,true) -1 = !t; tel - + diff --git a/test/bad/bad_flatten.ept b/test/bad/bad_flatten.ept index a3cb584..d6573ba 100644 --- a/test/bad/bad_flatten.ept +++ b/test/bad/bad_flatten.ept @@ -9,4 +9,4 @@ let done; z = t2 tel - + diff --git a/test/bad/t2.ept b/test/bad/t2.ept index a2e4be5..fe9fc52 100644 --- a/test/bad/t2.ept +++ b/test/bad/t2.ept @@ -8,7 +8,7 @@ node h(x,z,m:int) returns (o:int) automaton state S1 var r:int; - do + do k = m + 2; r = k + 3; w = 1 + 2; diff --git a/test/bad/t3.ept b/test/bad/t3.ept index b38e668..ab8a3ce 100644 --- a/test/bad/t3.ept +++ b/test/bad/t3.ept @@ -5,9 +5,9 @@ let automaton state A do y = 2 - until y = 2 then B + until y = 2 then B state B - do y = 3 - until y = 3 then C + do y = 3 + until y = 3 then C end tel diff --git a/test/bad/t4.ept b/test/bad/t4.ept index 4ecf10a..4947625 100644 --- a/test/bad/t4.ept +++ b/test/bad/t4.ept @@ -7,11 +7,11 @@ let state B do y = x until y = 2 then A end; automaton - state C - do z = y + state C + do z = y until z = 3 then D - state D - do z = x + state D + do z = x until z = 4 then A end tel diff --git a/test/bad/t5.ept b/test/bad/t5.ept index 515ed31..9dadde2 100644 --- a/test/bad/t5.ept +++ b/test/bad/t5.ept @@ -1,20 +1,20 @@ node f(x:int) returns (y,z:int) let automaton - state A + state A do y = x; - z = 4; + z = 4; until y = 2 then B - state B + state B do y = x; - automaton - state C - do z = y - until z = 3 then D - state D - do z = x - until z = 4 then A - end + automaton + state C + do z = y + until z = 3 then D + state D + do z = x + until z = 4 then A + end until y = 2 then A end; tel diff --git a/test/bad/when_merge1.ept b/test/bad/when_merge1.ept index 50984f0..8e02bc3 100644 --- a/test/bad/when_merge1.ept +++ b/test/bad/when_merge1.ept @@ -8,4 +8,4 @@ type t = A | B node fusion(x1:int on B(c); x2:int; c:t) returns (y :int) let y = merge c (A -> x1) (B -> x2) - tel + tel diff --git a/test/good/array2.ept b/test/good/array2.ept index 628ad1f..73b334e 100644 --- a/test/good/array2.ept +++ b/test/good/array2.ept @@ -8,12 +8,12 @@ tel node sumdup (a, acc_in:int) returns (o:int; acc_out:int) let - acc_out = acc_in + a; - o = acc_out; + 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 (a, 0); + (o, acc) = mapfold<> sumdup (a, 0); tel diff --git a/test/good/array_fill.ept b/test/good/array_fill.ept index 4078a15..e995185 100644 --- a/test/good/array_fill.ept +++ b/test/good/array_fill.ept @@ -1,7 +1,7 @@ const n : int = 33 node stopbb(shiftenable : bool) returns (dataout : bool^n) -var last dataint : bool^n; f : bool; +var last dataint : bool^n; f : bool; let f = false; dataout = (f^n) fby dataint; diff --git a/test/good/autohiera.ept b/test/good/autohiera.ept index a112692..db2999f 100644 --- a/test/good/autohiera.ept +++ b/test/good/autohiera.ept @@ -19,7 +19,7 @@ let state B do until count() = 3 then A - end + end until count() = 5 then Two state Two do c = x; diff --git a/test/good/autohiera2.ept b/test/good/autohiera2.ept index 4cf134f..a9ef47b 100644 --- a/test/good/autohiera2.ept +++ b/test/good/autohiera2.ept @@ -15,7 +15,7 @@ let state B do c = not(x); until true then A - end + end until true then Two state Two do c = x; diff --git a/test/good/flatten.ept b/test/good/flatten.ept index d78765e..5b42b35 100644 --- a/test/good/flatten.ept +++ b/test/good/flatten.ept @@ -14,4 +14,4 @@ let done; z = t; tel - + diff --git a/test/good/or_keep.ept b/test/good/or_keep.ept index ee40dc9..db46764 100644 --- a/test/good/or_keep.ept +++ b/test/good/or_keep.ept @@ -6,15 +6,15 @@ tel node f<>(i : bool^n) returns (o, b : bool; nat : int) let b = fold<> (or) (i, false); - automaton - state Idle - do o = false; nat = 0; - unless b then Emit - state Emit - do o = true; - nat = nat(); - until nat > 3 then Idle - unless b then Emit + automaton + state Idle + do o = false; nat = 0; + unless b then Emit + state Emit + do o = true; + nat = nat(); + until nat > 3 then Idle + unless b then Emit end tel diff --git a/test/good/t.ept b/test/good/t.ept index 653c662..e7e6b54 100644 --- a/test/good/t.ept +++ b/test/good/t.ept @@ -7,7 +7,7 @@ node main() returns (c : int) let automaton state One - do c = count () + do c = count () until count() = 5 then Two state Two do c = count () diff --git a/test/good/t1.ept b/test/good/t1.ept index a5aec34..dff140e 100644 --- a/test/good/t1.ept +++ b/test/good/t1.ept @@ -65,14 +65,14 @@ node i(x, y: int) returns (o: int) node j(x, y: int) returns (o: int) let automaton - state I + state I var z: int; do o = 1; z = 2 until (o = 2) then J state J do o = 2 until (o = 1) then I - end + end tel node (++)(up, down: int) returns (o: int) @@ -83,13 +83,13 @@ node (++)(up, down: int) returns (o: int) state Init var k : int; do k = 0 -> pre k + 2; - cpt = 0 - until + cpt = 0 + until (up = 1) then Up state Up do cpt = last cpt + 1 until (down = 1) then Down - | (down = 0) then Up + | (down = 0) then Up state Down do cpt = (last cpt) + 1 until (up = 1) then Up @@ -98,7 +98,7 @@ node (++)(up, down: int) returns (o: int) node f(x: bool) returns (y: bool) var z: bool; - let + let y = x or x & x; z = true -> if y then not (pre z) else pre z; tel @@ -117,7 +117,7 @@ modes(v0) = end val gain : int > - modes last o : int when up: int -> int when down: int -> int + modes last o : int when up: int -> int when down: int -> int end with { up # down } let node gain(v0)(up, down) returns (o) diff --git a/test/good/t15.ept b/test/good/t15.ept index ad3287d..4c38dc2 100644 --- a/test/good/t15.ept +++ b/test/good/t15.ept @@ -1,6 +1,6 @@ (* Crashes the pass removing intermediate equations. *) node foo() returns (res:int) - let + let res = if true then 1 else 1; tel diff --git a/test/good/t16.ept b/test/good/t16.ept index ba4aa6f..41f6a23 100644 --- a/test/good/t16.ept +++ b/test/good/t16.ept @@ -2,7 +2,7 @@ node foo() returns (tmt1:int) var v_1:int; tmt2:int; - let + let tmt1 = (1 + tmt2); tmt2 = 0 fby v_1; v_1 = tmt1; diff --git a/test/good/t2.ept b/test/good/t2.ept index d770bb8..e195e48 100644 --- a/test/good/t2.ept +++ b/test/good/t2.ept @@ -49,7 +49,7 @@ node hh(x,z,m:int) returns (o:int) automaton state S1 var r:int; - do + do k = m + 2; r = k + 3; w = 1 + 2; @@ -59,7 +59,7 @@ node hh(x,z,m:int) returns (o:int) state S2 do k = 2; - until (1 = 0) then S2 + until (1 = 0) then S2 end;(* present | (x = 0) do o = pre o + 2 diff --git a/test/good/t2open.ept b/test/good/t2open.ept index 9c44cb9..5e98bb7 100644 --- a/test/good/t2open.ept +++ b/test/good/t2open.ept @@ -18,7 +18,7 @@ node h(x,z,m:int) returns (o:int) automaton state S1 var r:int; - do + do k = m + 2; r = k + 3; w = 1 + 2; diff --git a/test/good/t3.ept b/test/good/t3.ept index a70c31f..b991d3a 100644 --- a/test/good/t3.ept +++ b/test/good/t3.ept @@ -6,9 +6,9 @@ node f(x,z:int) returns (o:int) let r = false; automaton - state Init - do o = 1 + 2 - until (o = 0) then Two + state Init + do o = 1 + 2 + until (o = 0) then Two state Two do o = 2 + 3 until (o = 1) then Two end; automaton diff --git a/test/good/t6.ept b/test/good/t6.ept index 546617a..a248ac7 100644 --- a/test/good/t6.ept +++ b/test/good/t6.ept @@ -5,12 +5,12 @@ node f(x,z:int) returns (o1,o2:int) switch (x = z) | true do o1 = 0 -> pre o1 + 2; - o2 = o4 + 1; - o4 = 3 + o2 = o4 + 1; + o4 = 3 | false do o1 = 4; - o2 = 5; - o4 = 5 + o2 = 5; + o4 = 5 end; tel diff --git a/test/good/tt.ept b/test/good/tt.ept index af9d7cb..e294c39 100644 --- a/test/good/tt.ept +++ b/test/good/tt.ept @@ -1,15 +1,28 @@ - - -node g() returns (o :int) +node f(x:bool;c:bool) returns (o:bool) let - o = 0 fby 1 + automaton + state A + var l:bool; do + l = x when c; + o = merge c (true -> l) (false -> false) + until true then B + state B + do o = false + end tel -node f (i:int) returns (o1,o2,o3:int) + +(* +node clock_on<>(w1, w2 : bool) returns (o : bool) let - reset - o1 = o2 + g(); - every true; - o2 = if true then g() else 0; - o3 = o2 + 4; + automaton + state FirstPeriod + var w2' : bool; do + w2' = w1 when w2; + o = false; + until true then Cruise + state Cruise do + o = true; + end tel +*) diff --git a/test/good/ttt.ept b/test/good/ttt.ept new file mode 100644 index 0000000..960bd77 --- /dev/null +++ b/test/good/ttt.ept @@ -0,0 +1,7 @@ +node f(x:int) returns (y:int on ck; ck,ck2:bool) +let + ck = true; + ck2 = true; + y = (x :: ck2) +tel + diff --git a/test/good/tttt.ept b/test/good/tttt.ept new file mode 100644 index 0000000..03db7a3 --- /dev/null +++ b/test/good/tttt.ept @@ -0,0 +1,6 @@ +node f(c:bool;x:int) returns (o:int) +let + reset + o = merge c (true -> (0 fby x) when c) (false -> 0 fby (o whenot c)); + every true +tel diff --git a/test/good/when_merge1.ept b/test/good/when_merge1.ept index c34d117..c198259 100644 --- a/test/good/when_merge1.ept +++ b/test/good/when_merge1.ept @@ -23,4 +23,4 @@ node filter(x:int; c:t) returns (y:int on A(c)) node fusion(x1:int; x2:int; c:t) returns (y :int) let y = merge c (A -> x1) (B -> x2) - tel + tel diff --git a/test/image_filters/convolutions.ept b/test/image_filters/convolutions.ept index afd1235..a20bbe6 100644 --- a/test/image_filters/convolutions.ept +++ b/test/image_filters/convolutions.ept @@ -1,8 +1,8 @@ (* Deal with matrix of size n*m, apply coeff : - kt - kl k kr - kb - centered on [>i<][>j<]. *) + kt + kl k kr + kb + centered on [>i<][>j<]. *) fun kernel_1 << n,m,k,kl,kt,kr,kb :int>> (t :int^n^m; i,x,j :int) returns (r :int) let r = k*t[>i<][>j<] + kl*t[>i<][>j-1<] + kt*t[>i-1<][>j<] + kr*t[>i<][>j+1<] + kb*t[>i+1<][>j<] @@ -20,19 +20,19 @@ tel (* Deal with matrix of size n*m, apply coeff : - ktt - klt kt ktr - kll kl k kr krr - kbl kb krb - kbb - centered on [>i<][>j<]. *) + ktt + klt kt ktr + kll kl k kr krr + kbl kb krb + kbb + centered on [>i<][>j<]. *) fun kernel_2 <> (t :int^n^m; i,x,j :int) returns (r :int) let - r = ktt*t[>i-2<][>j<]+ - klt*t[>i-1<][>j-1<]+ kt*t[>i-1<][>j<]+ ktr*t[>i-1<][>j+1<]+ - kll*t[>i<][>j-2<]+ kl*t[>i<][>j-1<]+ k*t[>i<][>j<]+ kr*t[>i<][>j+1<]+ krr*t[>i<][>j+2<]+ - kbl*t[>i+1<][>j-1<]+ kb*t[>i+1<][>j<]+ krb*t[>i+1<][>j+1<]+ - kbb*t[>i+2<][>j<]; + r = ktt*t[>i-2<][>j<]+ + klt*t[>i-1<][>j-1<]+ kt*t[>i-1<][>j<]+ ktr*t[>i-1<][>j+1<]+ + kll*t[>i<][>j-2<]+ kl*t[>i<][>j-1<]+ k*t[>i<][>j<]+ kr*t[>i<][>j+1<]+ krr*t[>i<][>j+2<]+ + kbl*t[>i+1<][>j-1<]+ kb*t[>i+1<][>j<]+ krb*t[>i+1<][>j+1<]+ + kbb*t[>i+2<][>j<]; tel fun convol_2_h<> (t:int^n^m; line : int^m; i :int) returns (r :int^m) diff --git a/test/image_filters/pip.ept b/test/image_filters/pip.ept index 87c7c67..c93f11b 100644 --- a/test/image_filters/pip.ept +++ b/test/image_filters/pip.ept @@ -7,7 +7,7 @@ fun pip<> (t1 :int^n1^m1; t2 :int^n2^m2) returns (r :int^n var t12 :int^m1^n2; let t12 = map<> (pip_line<>) (t1[x..x+n2-1], t2); - r = t1[0 .. x-1] @ t12 @ t1[x+n2 .. n1-1]; + r = t1[0 .. x-1] @ t12 @ t1[x+n2 .. n1-1]; tel node main() returns (r :int^10^10) diff --git a/tools/enforce_style.sh b/tools/enforce_style.sh index 155d7c9..fd524ce 100755 --- a/tools/enforce_style.sh +++ b/tools/enforce_style.sh @@ -1,2 +1,2 @@ #!/bin/sh -find . \! -path "*_build*" -and \( -iname "*.ml" -or -iname "*.mli" -or -iname "*.mly" -or -iname "*.mll" \) -exec perl -pi -e 's/( |\t)+$//gi; s/\t/ /g' {} \; +find . \! -path "*_build*" -and \( -iname "*.ml" -or -iname "*.mli" -or -iname "*.mly" -or -iname "*.mll" -or -iname "*.ept" \) -exec perl -pi -e 's/( |\t)+$//gi; s/\t/ /g' {} \;