Skip to content

Commit

Permalink
add some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hidetatz committed Jul 30, 2023
1 parent 73abb9b commit 7fc7ebf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/assert.sb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def assert(expected, actual) {
if expected != actual {
print("test failed. expected: ", expected, ", actual: " , actual)
exit(1)
}
}
18 changes: 18 additions & 0 deletions tests/list.sb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import assert

as = assert.assert

as([1, 2], [1] + [2])
as([1, 1], [1] * 2)
as([1, true, "s", [4], 1, true, "s", [4]], [1, true, "s", [4]] * 2)
as(1, [1, 2, 3][0])
as(2, [1, 2, 3][1])
as(3, [1, 2, 3][2])
as([1, 2, 3], [1, 2, 3][0:3])
as([1, 2], [1, 2, 3][0:2])
as([1], [1, 2, 3][0:1])
as([], [1, 2, 3][0:0])
as([2], [1, 2, 3][1:2])
as([2, 3], [1, 2, 3][1:3])

print("list test succeeded")
12 changes: 12 additions & 0 deletions tests/str.sb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import assert

as = assert.assert

as("ab", "a" + "b")
as("aaa", "a" * 3)
as("aaa", 3 * "a")
as("aaaaaaaaa", 3 * "a" * 3)
as("a", "abc"[0])
as("ab", "abc"[0:2])

print("str test succeeded")

0 comments on commit 7fc7ebf

Please sign in to comment.