aboutsummaryrefslogtreecommitdiffstats
path: root/progs/tests/loop_for.sy
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-03-10 17:22:18 +0100
committerGitHub <noreply@github.com>2021-03-10 17:22:18 +0100
commite930f7b71ba526f40210f3e89afc79b2288e2e91 (patch)
treed494b8771dc71b52aa56fe948e7e6eab260d216a /progs/tests/loop_for.sy
parent345cb8efef31af3e6fda65357fbab25664d385a2 (diff)
parente61e0a3d3bc015854c91761a70544e74b0478b94 (diff)
downloadsylt-e930f7b71ba526f40210f3e89afc79b2288e2e91.tar.gz
Merge pull request #106 from FredTheDino/move-tests
Diffstat (limited to 'progs/tests/loop_for.sy')
-rw-r--r--progs/tests/loop_for.sy37
1 files changed, 37 insertions, 0 deletions
diff --git a/progs/tests/loop_for.sy b/progs/tests/loop_for.sy
new file mode 100644
index 0000000..f9e27d4
--- /dev/null
+++ b/progs/tests/loop_for.sy
@@ -0,0 +1,37 @@
+start :: fn {
+ a := 0
+ for i := 0, i < 3, i = i + 1 {
+ a = a + i
+ }
+ a <=> 3
+
+ a = 0
+ for i := 0, i <= 3, i = i + 1 {
+ a = a + i
+ }
+ a <=> 6
+
+ a = 0
+ for i := 0, i < 3, i = i + 1 {
+ for j := 0, j < 3, j = j + 1 {
+ a = a + i * j
+ }
+ }
+ a <=> 9
+
+ a = 0
+ for i := 0, i < 10, i = i + 1 {
+ for j := i, j < 10, j = j + 1 {
+ a = a + i * j
+ }
+ }
+ a <=> 1155
+
+ a = 0
+ for i := 0, i < 10, i = i + 1 {
+ for j := 0, j < i, j = j + 1 {
+ a = a + i * j
+ }
+ }
+ a <=> 870
+}