diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 13 | ||||
-rw-r--r-- | tests/count.scade | 36 | ||||
-rw-r--r-- | tests/merge.scade | 22 | ||||
-rw-r--r-- | tests/result/limiter.out | 31 | ||||
-rw-r--r-- | tests/result/limitera.out | 31 | ||||
-rw-r--r-- | tests/result/locals.out | 13 | ||||
-rw-r--r-- | tests/result/test0.out | 6 | ||||
-rw-r--r-- | tests/result/test1.out | 6 | ||||
-rw-r--r-- | tests/result/test2.out | 6 | ||||
-rw-r--r-- | tests/result/test3.out | 6 | ||||
-rw-r--r-- | tests/result/test4.out | 6 | ||||
-rw-r--r-- | tests/result/test5.out | 11 | ||||
-rw-r--r-- | tests/result/test6.out | 6 | ||||
-rw-r--r-- | tests/result/test7.out | 6 | ||||
-rw-r--r-- | tests/result/testc.out | 1 | ||||
-rw-r--r-- | tests/result/train.out | 101 | ||||
-rw-r--r-- | tests/result/updown.out | 31 | ||||
-rw-r--r-- | tests/source/limiter.scade (renamed from tests/limiter.scade) | 0 | ||||
-rw-r--r-- | tests/source/limitera.scade (renamed from tests/limitera.scade) | 0 | ||||
-rw-r--r-- | tests/source/locals.scade | 20 | ||||
-rw-r--r-- | tests/source/test0.scade | 7 | ||||
-rw-r--r-- | tests/source/test1.scade (renamed from tests/tests/test1.scade) | 2 | ||||
-rw-r--r-- | tests/source/test2.scade (renamed from tests/tests/test2.scade) | 2 | ||||
-rw-r--r-- | tests/source/test3.scade (renamed from tests/tests/test3.scade) | 2 | ||||
-rw-r--r-- | tests/source/test4.scade (renamed from tests/tests/test4.scade) | 0 | ||||
-rw-r--r-- | tests/source/test5.scade (renamed from tests/tests/test5.scade) | 0 | ||||
-rw-r--r-- | tests/source/test6.scade (renamed from tests/tests/test6.scade) | 2 | ||||
-rw-r--r-- | tests/source/test7.scade (renamed from tests/tests/test7.scade) | 0 | ||||
-rw-r--r-- | tests/source/testc.scade (renamed from tests/tests/testc.scade) | 4 | ||||
-rw-r--r-- | tests/source/train.scade (renamed from tests/train.scade) | 14 | ||||
-rw-r--r-- | tests/source/updown.scade (renamed from tests/updown.scade) | 0 | ||||
-rw-r--r-- | tests/tests/test0.scade | 7 |
32 files changed, 313 insertions, 79 deletions
diff --git a/tests/Makefile b/tests/Makefile index 4073cad..d306161 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,4 +1,15 @@ -%.test: %.scade test.c +ALL_OUT=result/limiter.out result/limitera.out result/locals.out \ + result/test4.out result/test5.out result/test7.out \ + result/train.out result/updown.out \ + result/test0.out result/test1.out result/test2.out result/test3.out \ + result/test6.out result/testc.out + +bin/%.test: source/%.scade test.c rm kcg/* kcg64 -target C -node test $< gcc -o $@ test.c kcg/*.c -I./kcg + +result/%.out: bin/%.test + $< > $@ + +all: $(ALL_OUT) diff --git a/tests/count.scade b/tests/count.scade deleted file mode 100644 index c5ce47d..0000000 --- a/tests/count.scade +++ /dev/null @@ -1,36 +0,0 @@ -node count() returns (c: int) -let - c = 0 -> (1 + pre c); -tel - -node resettable_count (r: bool) returns (c: int) -let - c = (restart count every r)(); -tel - -node nat() returns (s: int) s = 1 -> (1 + pre s); - -node rst_clk(rst: bool; clock h: bool) - returns (s: int; t: int) -let - s = (restart nat every rst) (); - t = merge(h; ((restart nat every rst) (() when h)); 0 when not h); -tel - -node even_times(c: bool; i: int) returns (o: int) -let - automaton - initial state EVEN - unless if c resume ODD; - let - o = i+1; - tel - - state ODD - unless if c resume EVEN; - let - o = -2 * i; - tel - returns o; -tel - diff --git a/tests/merge.scade b/tests/merge.scade deleted file mode 100644 index 9e666a1..0000000 --- a/tests/merge.scade +++ /dev/null @@ -1,22 +0,0 @@ -type t1 = enum { True, False, Error }; - -node #pragma kcg expand #end - mm(clock clk: t1; v: int when (clk match True)) returns(r: int) -var lr: int; -let - lr = 0 -> pre r; - r = merge(clk; - v; - lr when (clk match False); - -1 when (clk match Error)); -tel - -node test(i: int) returns (a, b, c: int; exit: bool) -var clock clk: t1; -let - exit = i >= 30; - clk = if i mod 5 = 0 then True else if i mod 9 = 8 then Error else False; - a = mm(clk, i when (clk match True)); - b = if clk = True then 1 else 0; - c = if clk = Error then 1 else 0; -tel diff --git a/tests/result/limiter.out b/tests/result/limiter.out new file mode 100644 index 0000000..1851c7d --- /dev/null +++ b/tests/result/limiter.out @@ -0,0 +1,31 @@ +0. -6 16 -6 +1. 15 16 10 +2. 36 16 26 +3. 57 16 42 +4. 78 16 58 +5. 99 16 74 +6. 120 16 90 +7. -115 16 74 +8. -94 16 58 +9. -73 16 42 +10. -52 16 26 +11. -31 16 10 +12. -10 16 -6 +13. 11 16 10 +14. 32 16 26 +15. 53 16 42 +16. 74 16 58 +17. 95 16 74 +18. 116 16 90 +19. -119 16 74 +20. -98 16 58 +21. -77 16 42 +22. -56 16 26 +23. -35 16 10 +24. -14 16 -6 +25. 7 16 7 +26. 28 16 23 +27. 49 16 39 +28. 70 16 55 +29. 91 16 71 +30. 112 16 87 diff --git a/tests/result/limitera.out b/tests/result/limitera.out new file mode 100644 index 0000000..1851c7d --- /dev/null +++ b/tests/result/limitera.out @@ -0,0 +1,31 @@ +0. -6 16 -6 +1. 15 16 10 +2. 36 16 26 +3. 57 16 42 +4. 78 16 58 +5. 99 16 74 +6. 120 16 90 +7. -115 16 74 +8. -94 16 58 +9. -73 16 42 +10. -52 16 26 +11. -31 16 10 +12. -10 16 -6 +13. 11 16 10 +14. 32 16 26 +15. 53 16 42 +16. 74 16 58 +17. 95 16 74 +18. 116 16 90 +19. -119 16 74 +20. -98 16 58 +21. -77 16 42 +22. -56 16 26 +23. -35 16 10 +24. -14 16 -6 +25. 7 16 7 +26. 28 16 23 +27. 49 16 39 +28. 70 16 55 +29. 91 16 71 +30. 112 16 87 diff --git a/tests/result/locals.out b/tests/result/locals.out new file mode 100644 index 0000000..e111948 --- /dev/null +++ b/tests/result/locals.out @@ -0,0 +1,13 @@ +0. 0 0 0 +1. 0 0 0 +2. 1 0 0 +3. 2 0 0 +4. 3 0 0 +5. 5 0 0 +6. 4 0 0 +7. 6 0 0 +8. 7 0 0 +9. 8 0 0 +10. 10 0 0 +11. 9 0 0 +12. 11 0 0 diff --git a/tests/result/test0.out b/tests/result/test0.out new file mode 100644 index 0000000..fa316b4 --- /dev/null +++ b/tests/result/test0.out @@ -0,0 +1,6 @@ +0. 0 0 0 +1. 1 0 0 +2. 2 0 0 +3. 3 0 0 +4. 4 0 0 +5. 5 0 0 diff --git a/tests/result/test1.out b/tests/result/test1.out new file mode 100644 index 0000000..fa316b4 --- /dev/null +++ b/tests/result/test1.out @@ -0,0 +1,6 @@ +0. 0 0 0 +1. 1 0 0 +2. 2 0 0 +3. 3 0 0 +4. 4 0 0 +5. 5 0 0 diff --git a/tests/result/test2.out b/tests/result/test2.out new file mode 100644 index 0000000..d080f21 --- /dev/null +++ b/tests/result/test2.out @@ -0,0 +1,6 @@ +0. 12 0 0 +1. 12 0 0 +2. 12 0 0 +3. 12 0 0 +4. 12 0 0 +5. 12 0 0 diff --git a/tests/result/test3.out b/tests/result/test3.out new file mode 100644 index 0000000..fa316b4 --- /dev/null +++ b/tests/result/test3.out @@ -0,0 +1,6 @@ +0. 0 0 0 +1. 1 0 0 +2. 2 0 0 +3. 3 0 0 +4. 4 0 0 +5. 5 0 0 diff --git a/tests/result/test4.out b/tests/result/test4.out new file mode 100644 index 0000000..f5ad578 --- /dev/null +++ b/tests/result/test4.out @@ -0,0 +1,6 @@ +0. 0 0 0 +1. 1 0 0 +2. 2 1 0 +3. 3 2 0 +4. 4 3 0 +5. 5 4 0 diff --git a/tests/result/test5.out b/tests/result/test5.out new file mode 100644 index 0000000..388c744 --- /dev/null +++ b/tests/result/test5.out @@ -0,0 +1,11 @@ +0. 1 0 0 +1. 2 1 0 +2. 3 2 0 +3. 4 3 0 +4. 5 4 0 +5. 0 5 0 +6. 1 0 0 +7. 2 1 0 +8. 3 2 0 +9. 4 3 0 +10. 5 4 0 diff --git a/tests/result/test6.out b/tests/result/test6.out new file mode 100644 index 0000000..fa316b4 --- /dev/null +++ b/tests/result/test6.out @@ -0,0 +1,6 @@ +0. 0 0 0 +1. 1 0 0 +2. 2 0 0 +3. 3 0 0 +4. 4 0 0 +5. 5 0 0 diff --git a/tests/result/test7.out b/tests/result/test7.out new file mode 100644 index 0000000..90ae696 --- /dev/null +++ b/tests/result/test7.out @@ -0,0 +1,6 @@ +0. 0 0 0 +1. 0 0 1 +2. 0 0 2 +3. 0 0 3 +4. 0 0 4 +5. 0 0 5 diff --git a/tests/result/testc.out b/tests/result/testc.out new file mode 100644 index 0000000..5553419 --- /dev/null +++ b/tests/result/testc.out @@ -0,0 +1 @@ +0. 12 27 24 diff --git a/tests/result/train.out b/tests/result/train.out new file mode 100644 index 0000000..4af78b5 --- /dev/null +++ b/tests/result/train.out @@ -0,0 +1,101 @@ +0. 0 0 0 +1. 0 0 0 +2. 0 0 0 +3. 0 0 0 +4. 0 0 0 +5. 0 0 0 +6. 0 0 0 +7. 0 0 0 +8. 0 0 0 +9. 0 0 0 +10. 0 0 0 +11. 0 0 0 +12. 0 0 0 +13. 0 0 0 +14. 0 0 0 +15. 0 0 0 +16. 0 0 0 +17. 0 0 0 +18. 0 0 0 +19. 0 0 0 +20. 0 0 0 +21. 0 0 0 +22. 0 0 0 +23. 0 0 0 +24. 0 0 0 +25. 0 0 0 +26. 0 0 0 +27. 0 0 0 +28. 0 0 0 +29. 0 0 0 +30. 0 0 0 +31. 0 0 0 +32. 0 0 0 +33. 0 0 0 +34. 0 0 0 +35. 0 0 0 +36. 0 0 0 +37. 0 0 0 +38. 0 0 0 +39. 0 0 0 +40. 0 0 0 +41. 0 0 0 +42. 0 0 0 +43. 0 0 0 +44. 0 0 0 +45. 0 0 0 +46. 0 0 0 +47. 0 0 0 +48. 0 0 0 +49. 0 0 0 +50. 0 0 0 +51. 0 0 0 +52. 0 0 0 +53. 0 0 0 +54. 0 0 0 +55. 0 0 0 +56. 0 0 0 +57. 0 0 0 +58. 0 0 0 +59. 0 0 0 +60. 1 0 0 +61. 1 0 0 +62. 1 0 0 +63. 1 0 0 +64. 1 0 0 +65. 1 0 0 +66. 1 0 0 +67. 1 0 0 +68. 1 0 0 +69. 1 0 0 +70. 1 0 0 +71. 1 0 0 +72. 1 0 0 +73. 1 0 0 +74. 1 0 0 +75. 1 0 0 +76. 1 0 0 +77. 1 0 0 +78. 1 0 0 +79. 1 0 0 +80. 1 0 0 +81. 1 0 0 +82. 1 0 0 +83. 1 0 0 +84. 1 0 0 +85. 1 0 0 +86. 1 0 0 +87. 1 0 0 +88. 1 0 0 +89. 1 0 0 +90. 1 0 0 +91. 1 0 0 +92. 1 0 0 +93. 1 0 0 +94. 1 0 0 +95. 1 0 0 +96. 1 0 0 +97. 1 0 0 +98. 1 0 0 +99. 1 0 0 +100. 1 0 0 diff --git a/tests/result/updown.out b/tests/result/updown.out new file mode 100644 index 0000000..89e38ca --- /dev/null +++ b/tests/result/updown.out @@ -0,0 +1,31 @@ +0. 1 0 0 +1. 2 0 0 +2. 3 0 0 +3. 4 0 0 +4. 5 0 0 +5. 6 0 0 +6. 7 0 0 +7. 6 0 0 +8. 5 0 0 +9. 4 0 0 +10. 3 0 0 +11. 2 0 0 +12. 1 0 0 +13. 0 0 0 +14. -1 0 0 +15. -2 0 0 +16. -3 0 0 +17. -4 0 0 +18. -5 0 0 +19. -6 0 0 +20. -7 0 0 +21. -6 0 0 +22. -5 0 0 +23. -4 0 0 +24. -3 0 0 +25. -2 0 0 +26. -1 0 0 +27. 0 0 0 +28. 1 0 0 +29. 2 0 0 +30. 3 0 0 diff --git a/tests/limiter.scade b/tests/source/limiter.scade index a611d98..a611d98 100644 --- a/tests/limiter.scade +++ b/tests/source/limiter.scade diff --git a/tests/limitera.scade b/tests/source/limitera.scade index 1e4927e..1e4927e 100644 --- a/tests/limitera.scade +++ b/tests/source/limitera.scade diff --git a/tests/source/locals.scade b/tests/source/locals.scade new file mode 100644 index 0000000..379cbde --- /dev/null +++ b/tests/source/locals.scade @@ -0,0 +1,20 @@ +node test(i: int) returns(a, b, c: int; exit: bool) +let + activate + if i mod 5 = 0 then + var x: int; + let + x = i; + a = x; + tel + else + var x: int; + let + x = (0 -> pre i); + a = x; + tel + returns a; + b = 0; + c = 0; + exit = i >= 12; +tel diff --git a/tests/source/test0.scade b/tests/source/test0.scade new file mode 100644 index 0000000..65a5331 --- /dev/null +++ b/tests/source/test0.scade @@ -0,0 +1,7 @@ +function test(i: int) returns(probe a, b, c: int; exit: bool) +let + exit = i >= 5; + a = i; + b = 0; + c = 0; +tel diff --git a/tests/tests/test1.scade b/tests/source/test1.scade index 350b920..f247a57 100644 --- a/tests/tests/test1.scade +++ b/tests/source/test1.scade @@ -1,4 +1,4 @@ -node test(i: int) returns(probe a, b, c: int; exit: bool) +function test(i: int) returns(probe a, b, c: int; exit: bool) let assume i_pos : i >= 0; exit = i >= 5; diff --git a/tests/tests/test2.scade b/tests/source/test2.scade index 1777689..28a3e2d 100644 --- a/tests/tests/test2.scade +++ b/tests/source/test2.scade @@ -1,4 +1,4 @@ -node test(i: int) returns(probe a, b, c: int; exit: bool) +function test(i: int) returns(probe a, b, c: int; exit: bool) let assume i_pos : i >= 0; exit = i >= 5; diff --git a/tests/tests/test3.scade b/tests/source/test3.scade index 9380a49..541b9f5 100644 --- a/tests/tests/test3.scade +++ b/tests/source/test3.scade @@ -1,4 +1,4 @@ -node test(i: int) returns(probe a, b, c: int; exit: bool) +function test(i: int) returns(probe a, b, c: int; exit: bool) let exit = i >= 5; a = if i < 0 then -i else i; diff --git a/tests/tests/test4.scade b/tests/source/test4.scade index c66a56f..c66a56f 100644 --- a/tests/tests/test4.scade +++ b/tests/source/test4.scade diff --git a/tests/tests/test5.scade b/tests/source/test5.scade index 1de390d..1de390d 100644 --- a/tests/tests/test5.scade +++ b/tests/source/test5.scade diff --git a/tests/tests/test6.scade b/tests/source/test6.scade index 574e271..e3257cc 100644 --- a/tests/tests/test6.scade +++ b/tests/source/test6.scade @@ -1,4 +1,4 @@ -node test(probe i: int) returns(probe a, b, c: int; exit: bool) +function test(probe i: int) returns(probe a, b, c: int; exit: bool) let assume i_bounded : i >= -10 and i <= 10; a = i; diff --git a/tests/tests/test7.scade b/tests/source/test7.scade index c756a9e..c756a9e 100644 --- a/tests/tests/test7.scade +++ b/tests/source/test7.scade diff --git a/tests/tests/testc.scade b/tests/source/testc.scade index 7c99b32..40a04d3 100644 --- a/tests/tests/testc.scade +++ b/tests/source/testc.scade @@ -2,9 +2,9 @@ const x : int = 12; const y : int = z + 3; const z : int = x * 2; -node test(i: int) returns (a, b, c: int; exit: bool) +function test(i: int) returns (a, b, c: int; exit: bool) let - exit = true; + exit = i >= 0; a = x; b = y; c = z; diff --git a/tests/train.scade b/tests/source/train.scade index d91df01..c51971e 100644 --- a/tests/train.scade +++ b/tests/source/train.scade @@ -16,22 +16,22 @@ let automaton initial state NotEarly - unless if advance > 10 resume Early; let early = false; tel + until if advance >= 10 resume Early; state Early - unless if advance = 0 resume NotEarly; let early = true; tel + until if advance = 0 resume NotEarly; returns early; automaton initial state NotLate - unless if advance < -10 resume Late; let late = false; tel + until if advance <= -10 resume Late; state Late - unless if advance = 0 resume NotLate; let late = true; tel + until if advance = 0 resume NotLate; returns late; tel @@ -41,12 +41,12 @@ let ontime = not (late or early); automaton initial state Ok - unless if early resume Early; let alarm = false; tel + until if early resume Early; state Early - unless if ontime resume Ok; - let alarm = late; tel + let alarm = late and not early; tel + until if ontime resume Ok; returns alarm; tel diff --git a/tests/updown.scade b/tests/source/updown.scade index 089293a..089293a 100644 --- a/tests/updown.scade +++ b/tests/source/updown.scade diff --git a/tests/tests/test0.scade b/tests/tests/test0.scade deleted file mode 100644 index 3d03be5..0000000 --- a/tests/tests/test0.scade +++ /dev/null @@ -1,7 +0,0 @@ -node test(i: int) returns(probe a, b, c: int; exit: bool) -let - exit = i >= 5; - a = i; - b = 0; - c = 0; -tel |