diff --git a/test/bad/linear_causality.ept b/test/bad/linear_causality.ept new file mode 100644 index 0000000..ad7c816 --- /dev/null +++ b/test/bad/linear_causality.ept @@ -0,0 +1,6 @@ +node f(a:int^10 at r) returns (o:int^10 at r) +var u:int^10 at r; +let + u = [a with [0] = 0]; + o = map<<10>> (+)(u, a); +tel \ No newline at end of file diff --git a/test/good/linear.ept b/test/good/linear.ept new file mode 100644 index 0000000..892afba --- /dev/null +++ b/test/good/linear.ept @@ -0,0 +1,35 @@ +const m:int = 3 +const n:int = 100 + +node f(a:int^10 at r) returns (o:int^10 at r) +let + o = [ a with [0]=0 ] +tel + +node g(a:int^10 at r) returns (o:int^10 at r) +let + o = f(a) +tel + +node linplus (a:int at r) returns (u:int at r) +let + u = a +tel + +fun swap<>(i,j:int; a:float^s at r) returns (o:float^s at r) +var u,v:float; a1:float^s at r; +let + u = a.[i] default 0.0; + v = a.[j] default 0.0; + a1 = [ a with [i] = v ]; + o = [ a1 with [j] = v]; +tel + +node shuffle(i_arr, j_arr:int^m; q:int) + returns (v : float) +var t,t_next:float^n at r; +let + t_next = fold<> (swap<>)(i_arr, j_arr, t); + init<> t = (0.0^n) fby t_next; + v = t_next.[q] default 0.0; +tel \ No newline at end of file diff --git a/test/good/linear_automata.ept b/test/good/linear_automata.ept new file mode 100644 index 0000000..86bc2ff --- /dev/null +++ b/test/good/linear_automata.ept @@ -0,0 +1,26 @@ +const n:int = 100 + +fun f(a:int^n at r) returns (o:int^n at r) +let + o = [ a with [0] = 0 ] +tel + +fun g(a:int^n at r) returns (o:int^n at r) +let + o = [ a with [n-1] = 0 ] +tel + +node autom(a:int^n at r) returns (o:int^n at r) +let + automaton + state S1 + do + o = f(a) + until true then S2 + + state S2 + do + o = g(a) + until false then S1 + end +tel \ No newline at end of file diff --git a/test/good/linear_init.ept b/test/good/linear_init.ept new file mode 100644 index 0000000..278d99c --- /dev/null +++ b/test/good/linear_init.ept @@ -0,0 +1,23 @@ +const n:int = 100 + +node pp(x:float) returns(o1,o2:float) +let + o1 = x; + o2 = x +tel + +node f() returns (o:float) +var u,v:float^n at r; +let + init<> u = [1.0^n with [0] = 0.0]; + v = [u with [n-1] = 0.0]; + o = v[28] +tel + +node g() returns (o:float) +var u,v:float^n at r; z:float^n; +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 diff --git a/test/good/linear_split.ept b/test/good/linear_split.ept new file mode 100644 index 0000000..2f4c6e0 --- /dev/null +++ b/test/good/linear_split.ept @@ -0,0 +1,11 @@ +const n:int = 100 + +type st = On | Off + +node f(a:int^n at r; c:st) returns (o:int^n at r) +var u,v,x:int^n at r; +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 diff --git a/test/good/memalloc_record.ept b/test/good/memalloc_record.ept new file mode 100644 index 0000000..b8a0b5a --- /dev/null +++ b/test/good/memalloc_record.ept @@ -0,0 +1,14 @@ +type array = { tab : int^100; size : int } + +fun f(a:array) returns (o:array) +let + o = { a with .size = 0 } +tel + +node g(a:array) returns (o:array) +var v, u : int^100; +let + v = [ a.tab with [0] = 0 ]; + u = [ v with [10] = 99 ]; + o = { a with .tab = u } +tel \ No newline at end of file diff --git a/test/good/memalloc_simple.ept b/test/good/memalloc_simple.ept new file mode 100644 index 0000000..2edd3ee --- /dev/null +++ b/test/good/memalloc_simple.ept @@ -0,0 +1,43 @@ +const n:int = 100 +const m:int = 3 + +fun swap<>(i,j:int; a:float^s) returns (o:float^s) +var u,v:float; a1:float^s; +let + u = a.[i] default 0.0; + v = a.[j] default 0.0; + a1 = [ a with [i] = v ]; + o = [ a1 with [j] = v]; +tel + +node shuffle(i_arr, j_arr:int^m; q:int) + returns (v : float) +var t,t_next:float^n; +let + t_next = fold<> (swap<>)(i_arr, j_arr, t); + t = (0.0^n) fby t_next; + v = t_next.[q] default 0.0; +tel + +node p(a,b:int^n) returns (o:int^n) +var x:int^n; +let + x = map<> (+) (a, b); + o = map<> (-) (x, b) +tel + +fun clocked(x:bool; i,j:int; a:float^n) returns (o:float^n) +var a1,a2:float^n; +let + a1 = [ (a when true(x)) with [i when true(x)] = 0.0 ]; + a2 = [ (a when false(x)) with [j when false(x)] = 0.0 ]; + o = merge x (true -> a1) (false -> a2); +tel + +node clocked_reg(x:bool; i,j:int; a:float^n) returns (o:float^n) +var a1,a2:float^n; +let + o = merge x (true -> a1) (false -> a2); + 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