2022-04-05 10:55:32 +08:00
|
|
|
|
|
|
|
## TODO: add more test of built in functions.
|
|
|
|
|
2022-05-28 03:07:58 +08:00
|
|
|
assert("append" in dir([]))
|
|
|
|
assert("_repr" in dir(null))
|
|
|
|
|
2022-04-05 10:55:32 +08:00
|
|
|
assert(list_join([1, 2, 3]) == "123")
|
|
|
|
assert(list_join(["hello", " world"]) == "hello world")
|
|
|
|
assert(list_join([[], []]) == "[][]")
|
|
|
|
|
2022-06-01 01:23:12 +08:00
|
|
|
assert(min(-1, 2) == -1)
|
|
|
|
assert(max(100, -200) == 100)
|
|
|
|
|
|
|
|
class N
|
|
|
|
def _init(n)
|
|
|
|
self.n = n
|
|
|
|
end
|
|
|
|
def < (other)
|
|
|
|
return self.n < other.n
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
n1 = N(1)
|
|
|
|
n2 = N(2)
|
|
|
|
assert(min(n1, n2) == n1)
|
|
|
|
assert(max(n1, n2) == n2)
|
|
|
|
|
2022-05-08 18:02:51 +08:00
|
|
|
## If we got here, that means all test were passed.
|
|
|
|
print('All TESTS PASSED')
|