aboutsummaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-07-24 03:11:32 +0200
committerEugen Wissner <belka@caraus.de>2026-07-24 03:11:32 +0200
commitbb4f474cb2247e0e314beab5d7d72e673ff4e8b6 (patch)
tree4809b414bffa8d422ef8c1b6fe65dcdd4dce65d8 /testsuite
parent275fa4bff6d153019b6914fed7127a7d919ca177 (diff)
downloadelna-bb4f474cb2247e0e314beab5d7d72e673ff4e8b6.tar.gz
Implement a repeat loop
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/runnable/for_by.elna9
-rw-r--r--testsuite/runnable/for_each_array.elna12
-rw-r--r--testsuite/runnable/for_each_slice.elna15
-rw-r--r--testsuite/runnable/for_loop.elna9
-rw-r--r--testsuite/runnable/for_with.elna9
-rw-r--r--testsuite/runnable/repeat_loop.elna11
6 files changed, 47 insertions, 18 deletions
diff --git a/testsuite/runnable/for_by.elna b/testsuite/runnable/for_by.elna
deleted file mode 100644
index b219dc6..0000000
--- a/testsuite/runnable/for_by.elna
+++ /dev/null
@@ -1,9 +0,0 @@
-var
- actual: [4]Word := [4]Word{}
-
-begin
- for i := 1u to 4u by 2u do
- actual[i] := i
- end;
- assert(actual = [4]Word{ 1u, 0u, 3u, 0u })
-end.
diff --git a/testsuite/runnable/for_each_array.elna b/testsuite/runnable/for_each_array.elna
new file mode 100644
index 0000000..bf5733d
--- /dev/null
+++ b/testsuite/runnable/for_each_array.elna
@@ -0,0 +1,12 @@
+var
+ actual: [4]Word := [4]Word{}
+ input: [4]Word := [4]Word{ 2u, 4u, 6u, 8u }
+ i: Word := 1u
+
+begin
+ for element of input do
+ actual[i] := element^ * 2u;
+ i := i + 1u
+ end;
+ assert(actual = [4]Word{ 4u, 8u, 12u, 16u })
+end.
diff --git a/testsuite/runnable/for_each_slice.elna b/testsuite/runnable/for_each_slice.elna
new file mode 100644
index 0000000..efdf961
--- /dev/null
+++ b/testsuite/runnable/for_each_slice.elna
@@ -0,0 +1,15 @@
+var
+ actual: [4]Word := [4]Word{}
+ input: [4]Word := [4]Word{ 2u, 4u, 6u, 8u }
+ slice: []Word
+ i: Word := 1u
+
+begin
+ slice := input[1u to input.length];
+
+ for element of slice do
+ actual[i] := element^ * 2u;
+ i := i + 1u
+ end;
+ assert(actual = [4]Word{ 4u, 8u, 12u, 16u })
+end.
diff --git a/testsuite/runnable/for_loop.elna b/testsuite/runnable/for_loop.elna
deleted file mode 100644
index 02db679..0000000
--- a/testsuite/runnable/for_loop.elna
+++ /dev/null
@@ -1,9 +0,0 @@
-var
- actual: [4]Word := [4]Word{}
-
-begin
- for i := 1u to 4u do
- actual[i] := i * 2u
- end;
- assert(actual = [4]Word{ 2u, 4u, 6u, 8u })
-end.
diff --git a/testsuite/runnable/for_with.elna b/testsuite/runnable/for_with.elna
new file mode 100644
index 0000000..cfec5c0
--- /dev/null
+++ b/testsuite/runnable/for_with.elna
@@ -0,0 +1,9 @@
+var
+ actual: [3]Word := [3]Word{}
+
+begin
+ for element of [3]Word{ 1u, 2u, 3u } with i do
+ actual[i] := i * element^
+ end;
+ assert(actual = [3]Word{ 1u, 4u, 9u })
+end.
diff --git a/testsuite/runnable/repeat_loop.elna b/testsuite/runnable/repeat_loop.elna
new file mode 100644
index 0000000..5faaeab
--- /dev/null
+++ b/testsuite/runnable/repeat_loop.elna
@@ -0,0 +1,11 @@
+var
+ actual: [4]Word := [4]Word{}
+ i: Word := 0u
+
+begin
+ repeat
+ i := i + 1u;
+ actual[i] := i
+ until i = 4u;
+ assert(actual = [4]Word{ 1u, 2u, 3u, 4u })
+end.