This commit is contained in:
igor
2026-02-18 16:05:48 +01:00
parent cd1df4b18d
commit f3de51f5d8
16 changed files with 302 additions and 5 deletions

View File

@@ -21,4 +21,19 @@
6
7
8
9
9
1
2
3
3
1
2
1
2
3
4
6
9
4
9
6

View File

@@ -56,4 +56,44 @@ word main
# free list allocation: bytes = (len + 1) * 8
dup @ 1 + 8 * free
# dyn_arr_sorted (copy) should not mutate source
5 arr_new
3 swap arr_push
1 swap arr_push
2 swap arr_push
dup dyn_arr_sorted
dup 0 swap arr_get puti cr
dup 1 swap arr_get puti cr
dup 2 swap arr_get puti cr
arr_free
dup 0 swap arr_get puti cr
dup 1 swap arr_get puti cr
dup 2 swap arr_get puti cr
# dyn_arr_sort (alias) sorts in place
dyn_arr_sort
dup 0 swap arr_get puti cr
dup 1 swap arr_get puti cr
dup 2 swap arr_get puti cr
arr_free
# dyn_arr_sorted (alias) returns a sorted copy
5 arr_new
4 swap arr_push
9 swap arr_push
6 swap arr_push
dup dyn_arr_sorted
dup 0 swap arr_get puti cr
dup 1 swap arr_get puti cr
dup 2 swap arr_get puti cr
arr_free
dup 0 swap arr_get puti cr
dup 1 swap arr_get puti cr
dup 2 swap arr_get puti cr
arr_free
end

View File

@@ -0,0 +1,10 @@
1
2
3
4
5
7
9
9
5
7

29
tests/arr_static_sort.sl Normal file
View File

@@ -0,0 +1,29 @@
import ../stdlib/stdlib.sl
import ../stdlib/io.sl
import ../stdlib/arr.sl
word free_static
dup @ 1 + 8 * free
end
word main
[ 4 1 3 2 ] dup arr_sort
dup 0 swap arr_get_static puti cr
dup 1 swap arr_get_static puti cr
dup 2 swap arr_get_static puti cr
dup 3 swap arr_get_static puti cr
free_static
[ 9 5 7 ] dup arr_sorted
dup 0 swap arr_get_static puti cr
dup 1 swap arr_get_static puti cr
dup 2 swap arr_get_static puti cr
swap
dup 0 swap arr_get_static puti cr
dup 1 swap arr_get_static puti cr
dup 2 swap arr_get_static puti cr
free_static
free_static
end

View File

View File

@@ -0,0 +1,3 @@
{
"expected_exit": 1
}

6
tests/assert_msg_fail.sl Normal file
View File

@@ -0,0 +1,6 @@
import stdlib/debug.sl
word main
"boom msg" 0 assert_msg
0
end

View File

@@ -0,0 +1 @@
boom msg

View File

@@ -0,0 +1,2 @@
debug assert ok
assert_msg ok

10
tests/debug_assert.sl Normal file
View File

@@ -0,0 +1,10 @@
import stdlib/debug.sl
import stdlib/io.sl
word main
1 assert
2 2 == assert
"should not print" 1 assert_msg
"debug assert ok" puts
"assert_msg ok" puts
end

View File

@@ -0,0 +1 @@
static assert ok

12
tests/static_assert.sl Normal file
View File

@@ -0,0 +1,12 @@
import stdlib/debug.sl
import stdlib/io.sl
word ct_checks
1 static_assert
2 3 < static_assert
end
compile-time ct_checks
word main
"static assert ok" puts
end