computable-pandoc/tests/test.md

124 lines
3.8 KiB
Markdown
Raw Normal View History

2023-03-08 21:05:42 -06:00
# Test with Markdown
## Function Declarations
Valid declarations:
* A declaration: f1() = (+ 1 2 3). All declarations should be print on `--verbose`.
* f2() = (+ 4 5 6) is another declaration.
* f3() = (+ 7 8 9)
2023-03-09 20:13:01 -06:00
* Two declarations, one in inline code: f4() = (- 9 8) and `f5() = (- 7 6)`.
2023-03-08 21:05:42 -06:00
* Two consecutive declarations: f6() = (- 5 4) f7() = (- 3 2).
* A declaration with one arg: f8(n) = (* #n #n).
* A declaration with two args: f9(a, b) = (* #a #b).
* A declaration with variable number of args: f10(...) = (.. #...).
Not declarations:
* \f11() = (+ 1 2); doesn't starts with `%a`
* f-12() = (+ 1 2); doesn't continue with `%w`
* f 13() = (+ 1 2); starts with `%d`
* f14 () = (+ 1 2); space before `(`
* f15) = (+ 1 2); misses `(`
* f16() = + 1 2); misses `(`
* f17( = (+ 1 2); misses `)`
* f18() = (+ 1 2); misses `)`
* f19 = (+ 1 2); misses `()`
* f20() = + 1 2; misses `()`
* f21() (+ 1 2); misses `=`
Overrides `f1()` with warn: f1() = (+ 2 3 4) and it should fail on `--fail-if-warnings`.
## Functions Calls
Valid calls:
* A common call: f1(). All calls should be print on `--verbose`.
* f2() another common call.
* f3()
2023-03-09 20:13:01 -06:00
* Two calls, one in inline code: f4() and `f5()`.
2023-03-08 21:05:42 -06:00
* Two consecutive calls: f6() f7().
* A call with one arg: f8(2).
* A call with two args: f9(2, 3).
2023-03-09 20:13:01 -06:00
* A call with variable number of args: f10("The popular ", "\"Hello, ", "World!\"").
2023-03-08 21:05:42 -06:00
* A call with args as kwargs: f8(n: 3) and f9(a: 4, b: 5).
Valid calls and data types:
* f10(); no data
* f10(1, 1_000, 1.0); numbers
* f10("string"); string
* f10([]); empty array / list / sequential table
* f10([0 1]); array / list / sequential table
* f10({}); empty dict / table
* f10({"k" 0}); dict / table
Not calls:
* \f11(); doesn't starts with `%a`
* f-12(); doesn't continue with `%w`
* f 13(); starts with `%d`
* f14 (); space before `(`
* f15); misses `(`
* f16(a); invalid data type
* f17(; misses `)`
* f18(a:); misses kwarg value
* f19(1 2); misses comma separator
* f20( ); extra space
* f21({); incomplete data type
Invalid calls:
* f8(); misses arg
* f8(a: 3); wrong kwarg
* f9(1, 2, 3); wrong args number
* f9(1, b: 2); mixed arg and kwarg
* f10(...: 0); `...` can't be kwarg
* f11(); not declared
Invalid calls generate error.
# Function Calls with Reserved Keyword Arguments
Valid calls:
* f1($action: "return"); returns result after call.
* f2($action: "clear"); clears it from source document after call.
* f3($action: "wipe"); wipes it and its declaration after all calls.
* f4($action: "dump"); dumps its declaration after call.
* f4($action: "quote"); dumps its declaration without call.
* f5($eval: "f5.txt", $code: "f5.fnl", $lua: "f5.lua"); writes evaluation results, Lisp code and Lua code.
* f6($eval: "f6-7.txt", $code: "f6-7.fnl", $lua: "f6-7.lua"); writes in same files than below.
* f7($eval: "f6-7.txt", $code: "f6-7.fnl", $lua: "f6-7.lua"); writes in same files than above.
* f8(4, $action: "return")
* f8($action: "return", 5)
* f9(a: 1, b: 2, $action: "return")
* f9($action: "return", a: 1, b: 2)
* f9(a: 1, $action: "return", b: 2)
Invalid calls:
* f1($act: "return"); invalid rkwarg
* f2($action: "clearr"); invalid rkwarg value
* f3($eval: "/path/does/not/exists"); invalid path
* f4($code: "/path/does/not/exists"); invalid path
* f5($lua: "/path/does/not/exists"); invalid path
Invalid calls generate error.
# Function Recursion
Valid recursion:
* A declaration that uses a call inside: f24(x) = (* f1() x), result: f24($action: "return").
* A declaration that uses a call inside with "quote" action: f25(y, z) = (+ f2($action: "quote") y z), result: f25(9, 8, $action: "return").
* A call with other function as arg: f8(f1()).
* A call with other function as kwarg: f9(b: 3, a: f2()).
Invalid recursion:
2023-03-09 20:13:01 -06:00
* f26(i) = (* f11() i); `f11()` not declared.
2023-03-08 21:05:42 -06:00
* f27(j) = (* f27(1) f27(2)); infinite loop.
2023-03-09 20:13:01 -06:00
* f8(n: f11()); `f11()` not declared.
2023-03-08 21:05:42 -06:00
* f8(f8(3)); infinite loop.