mirror of
https://github.com/zekexiao/pocketlang.git
synced 2025-03-04 13:15:55 +08:00

- cJSON library was added to thirdparty for json module - json module added and json.parse() function implemented - thirdparty library sources are directly imported - io.readfile() function added - less than function fix (wasn't returning boolean) - min, max functions added - map check values equal implemented
30 lines
545 B
Plaintext
30 lines
545 B
Plaintext
|
|
## TODO: add more test of built in functions.
|
|
|
|
assert("append" in dir([]))
|
|
assert("_repr" in dir(null))
|
|
|
|
assert(list_join([1, 2, 3]) == "123")
|
|
assert(list_join(["hello", " world"]) == "hello world")
|
|
assert(list_join([[], []]) == "[][]")
|
|
|
|
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)
|
|
|
|
## If we got here, that means all test were passed.
|
|
print('All TESTS PASSED')
|