Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Dec 25, 2023
1 parent 95f92bf commit a279e45
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/valid/src/for_stmt.ri
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ test "`for` statement with dynamic array" {
@assert(sum == 55);
}

test "`for` statement with slice" {
mut sum := 0;
for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10][:] {
sum += i;
}
@assert(sum == 55);
}

test "`for` statement with `string.as_bytes()`" {
mut sum := 0;
for b in "Hello World!".as_bytes() {
Expand Down
17 changes: 17 additions & 0 deletions tests/valid/src/slices.ri
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
test "creating slices from arrays" {
arr := [1, 2, 3, 4];
slice := arr[:];
@assert(slice[0] == 1);
@assert(slice[1] == 2);
@assert(slice[2] == 3);
@assert(slice[3] == 4);
}

test "creating slices from dynamic arrays" {
arr := +[1, 2, 3, 4];
slice := arr[:];
@assert(slice[0] == 1);
@assert(slice[1] == 2);
@assert(slice[2] == 3);
@assert(slice[3] == 4);
}

0 comments on commit a279e45

Please sign in to comment.