mirror of
https://github.com/zekexiao/pocketlang.git
synced 2025-02-06 12:46:53 +08:00
![Thakee Nathees](/assets/img/avatar_default.png)
functions and classes are moved to constant buffer, and forward names are resolved for globals.
22 lines
759 B
Plaintext
22 lines
759 B
Plaintext
|
|
## Function Tests.
|
|
|
|
def f1 return 'f1' end assert(f1() == 'f1')
|
|
def f2() return 'f2' end assert(f2() == 'f2')
|
|
def f3(a, b, c, d) return c end
|
|
assert(f3('a', 'b', 'c', 'd') == 'c')
|
|
|
|
## Chain call tests. (concatenative programming)
|
|
## Chain call no more supported (unnecessary feature).
|
|
#def fn1(data) return '[fn1:' + data + ']' end
|
|
#def fn2(data, suffix) return '[fn2:' + data + '|' + suffix + ']' end
|
|
#def fn3(data) return '[fn3:' + data + ']' end
|
|
#result = 'data' -> fn1 -> fn2{'suff'} -> fn3
|
|
#assert(result == '[fn3:[fn2:[fn1:data]|suff]]')
|
|
# str_lower(s) function refactored to s.lower attribute.
|
|
#result = ' tEST+InG ' -> str_strip -> str_lower
|
|
#assert(result == 'test+ing')
|
|
|
|
# If we got here, that means all test were passed.
|
|
print('All TESTS PASSED')
|