From 275fa4bff6d153019b6914fed7127a7d919ca177 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 23 Jul 2026 01:01:03 +0200 Subject: Implement for loop --- testsuite/runnable/for_by.elna | 9 +++++++++ testsuite/runnable/for_loop.elna | 9 +++++++++ testsuite/runnable/slice_equality.elna | 10 ++++++++++ 3 files changed, 28 insertions(+) create mode 100644 testsuite/runnable/for_by.elna create mode 100644 testsuite/runnable/for_loop.elna create mode 100644 testsuite/runnable/slice_equality.elna (limited to 'testsuite/runnable') diff --git a/testsuite/runnable/for_by.elna b/testsuite/runnable/for_by.elna new file mode 100644 index 0000000..b219dc6 --- /dev/null +++ b/testsuite/runnable/for_by.elna @@ -0,0 +1,9 @@ +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_loop.elna b/testsuite/runnable/for_loop.elna new file mode 100644 index 0000000..02db679 --- /dev/null +++ b/testsuite/runnable/for_loop.elna @@ -0,0 +1,9 @@ +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/slice_equality.elna b/testsuite/runnable/slice_equality.elna new file mode 100644 index 0000000..1969088 --- /dev/null +++ b/testsuite/runnable/slice_equality.elna @@ -0,0 +1,10 @@ +var + lhs_payload, rhs_payload: [3]Int := [3]Int{ 2, 4, 6 } + lhs, rhs: []Int + +begin + lhs := lhs_payload.ptr[1 to 3]; + rhs := rhs_payload.ptr[1 to 3]; + + assert(lhs = rhs) +end. -- cgit v1.2.3