diff --git a/tests/fail.lit.complex.md b/tests/fail.lit.complex.md new file mode 100644 index 0000000..f10d637 --- /dev/null +++ b/tests/fail.lit.complex.md @@ -0,0 +1,23 @@ +# Declarations + + -- fn1(x) + #x + 2 + 3 + +# Invalid Declarations + + -- fn0 not declared: fn3(x) + #fn0 * #x + + -- infinite loop: fn3(x) + #fn3(1) * #x + +# Invalid Calls + +* fn1(1, $stdout: "true") has invalid rkwarg value +* fn1(1, $act: "return") has invalid rkwarg +* fn1(1, $eval: "/path/does/not/exists") has invalid path +* fn1(1, $code: "/path/does/not/exists") has invalid path +* fn1(1, $lua: "/path/does/not/exists") has invalid path +* fn1(fn4()); `fn4()` is not declared + +Invalid calls and declarations generate and collects errors. diff --git a/tests/fail.lit.simple.md b/tests/fail.lit.simple.md new file mode 100644 index 0000000..17b3294 --- /dev/null +++ b/tests/fail.lit.simple.md @@ -0,0 +1,38 @@ +# Declarations + + -- fn1() + 1 + 2 + 3 + + -- fn2(n) + #n .. " " .. #n) + + -- fn3(a, b) + #a * #b + +# Invalid Declarations + + -- misses end: fn4( + 1 + 2 + 3 + + -- fn5(invalid arg) + 4 + 5 + 6 + + -- misses arg: fn6() + #n .. " " .. #n + + -- misses separator: fn7(a b) + #a * #b + +# Invalid Calls + +* fn1(1) adds arg +* fn1( never end +* fn1(invalid arg) +* fn2() misses arg +* fn2(a: 3) wrong kwarg +* fn3(1 2) misses separator +* fn3(1, 2, 3) wrong args number +* fn3(1, b: 2) mixed arg and kwarg +* fn4() fn5() not declared + +Invalid calls and declarations generate and collects errors. diff --git a/tests/pass.lit.complex.md b/tests/pass.lit.complex.md new file mode 100644 index 0000000..3c96619 --- /dev/null +++ b/tests/pass.lit.complex.md @@ -0,0 +1,46 @@ +# Declarations + + -- fn1() + print("I am in stdout") + "Wipes it" + + -- fn2() + 1 + 2 + 3 + + -- fn3(n) + #n .. " " .. #n + + -- fn4(a, b) + #a * #b + +# Recursive Declarations + + -- fn5(x) + #fn2() * x + + -- fn6(y, z) + #y + #fn2($action: "quote") + #z + + -- fn7(a) + #a + #fn4(#a, #fn2()) + +# Calls + +Valid calls: + +* fn1($stdout: true) gets stdout instead of evaluation result. +* fn1($action: "wipe") wipes calls and declarations of this function from source document after all calls. +* fn2($action: "return") returns result after call. +* fn2($action: "hide") hides call from source document after call. +* fn2($action: "quote") quotes it without call. +* fn2($eval: "fn2.txt", $code: "fn2.fnl", $lua: "fn2.lua") writes evaluation results, Fennel code and Lua code. +* fn3(4, $action: "return") has arg and rkwarg. +* fn3($action: "return", 5) has rkwarg and arg. +* fn3($eval: "fn3-4.txt", $code: "fn3-4.fnl", $lua: "fn3-4.lua") writes in same files than below. +* fn4(a: 1, b: 2, $action: "return") has kwargs and rkwarg. +* fn4($action: "return", a: 1, b: 2) has rkwarg and kwargs. +* fn4(a: 1, $action: "return", b: 2) has kwarg, rkwarg and kwarg. +* fn4($eval: "fn3-4.txt", $code: "fn3-4.fnl", $lua: "fn3-4.lua") writes in same files than above. +* fn5(10) calls another function inside. +* fn6(9, 8) calls another quoted function inside. +* fn7(fn7(1)) calls several functions. diff --git a/tests/pass.lit.ignored.md b/tests/pass.lit.ignored.md new file mode 100644 index 0000000..f90b0e3 --- /dev/null +++ b/tests/pass.lit.ignored.md @@ -0,0 +1,29 @@ +# Not declarations + + -- doesn't starts with `%a`: \fn1() + 1 + 2 + + -- doesn't starts with `%a` because of the space: fn 2() + 1 + 2 + + -- doesn't continue with `%w`: fn-3() + 1 + 2 + + -- space before `(`: fn4 () + 1 + 2 + + -- misses `(`: fn5) + 1 + 2 + + -- misses `()`: fn6 + 1 + 2 + +# Not calls + +* \fn1() doesn't starts with `%a` +* fn 2() doesn't starts with `%a` because of the space +* fn-3() doesn't continue with `%w` +* fn4 () space before `(` +* fn5) misses `(` +* fn6 misses `()` +* `fn1()` as inline code diff --git a/tests/pass.lit.simple.md b/tests/pass.lit.simple.md new file mode 100644 index 0000000..5f9f2df --- /dev/null +++ b/tests/pass.lit.simple.md @@ -0,0 +1,69 @@ +# Calls Before Declarations + +* A common call: fn1(). All calls results should be print on `--verbose`. +* fn1() another common call. +* fn1() +* Two calls: fn1() and fn1(). +* Two consecutive calls: fn1() fn1(). +* A call with one arg: fn2(1). +* A call with two args: fn3(2, 3). +* A call with args as kwargs: fn2(n: 2) and fn3(b: 4, a: 5). + +# Declarations + +A declaration: + + -- fn1() + 1 + 2 + 3 + +All declarations should be print on `--verbose`. + +A declaration with one arg: + + -- Also valid, Lua is the default: fn2(n) + #n .. " " .. #n + +A declaration with two args: + + ; Changed lang and no space:fn3(a, b) -> fennel + (* #a #b) + +A declaration with lang options: + + # fn4(n) -> python -E -X utf8 + #n * #n + +A declaration with arg and scaped: + + -- fn5(x) + #x .. "\#x" + +# Calls and Data Types + +* fn2(3); integer +* fn2(1_000); integer with separator +* fn4(1.0); float +* fn5("str"); string +* fn5(true) +* fn5(false) +* fn2([]); empty array / list / sequential table +* fn2([0, 1]); array / list / sequential table +* fn2({}); empty dict / table +* fn2({"k1": 1, "k2": 2}); dict / table + +# Messy Calls + +* fn1( ) +* fn2( 4) +* fn2(5 ) +* fn2( 6 ) +* fn2( n: 7) +* fn2(n: 8 ) +* fn2( n: 9 ) +* fn2(n:10) +* fn3( a: 6, b: 7) +* fn3( a: 8 , b: 9) +* fn3( a: 10 , b: 11) +* fn3( a: 12 , b: 13) +* fn3( a: 14 , b: 15 ) +* fn3(a:16,b:17) diff --git a/tests/pass.lit.warns.md b/tests/pass.lit.warns.md new file mode 100644 index 0000000..7fd9b82 --- /dev/null +++ b/tests/pass.lit.warns.md @@ -0,0 +1,22 @@ +# Declaration Override + + -- fn1() + 1 + 2 + 3 + + -- fn1() + 4 + 5 + 6 + +# Unused Declaration + + -- fn2(n) + #n .. " " .. #n + +# Declaration with Unused Argument + + -- fn3(a) + 7 + 8 + 9 + +# Calls + +* fn1() +* fn3(1) diff --git a/tests/test.md b/tests/test.md deleted file mode 100644 index ee4b217..0000000 --- a/tests/test.md +++ /dev/null @@ -1,133 +0,0 @@ -# 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) -* Two declarations, one in inline code: f4() = (- 9 8) and `f5() = (- 7 6)`. -* 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 `=` -* `f22() = (+ 1 2)`; inline code is ignored - -Block code is ignored: - - f23() = (+ 1 2) - -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() -* Two calls, one in inline code: f4() and `f5()`. -* Two consecutive calls: f6() f7(). -* A call with one arg: f8(2). -* A call with two args: f9(2, 3). -* A call with variable number of args: f10("The popular ", "\"Hello, ", "World!\""). -* 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 -* `f22()`; inline code is ignored - -Block code is ignored: - - f23() - -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: - -* f26(i) = (* f11() i); `f11()` not declared. -* f27(j) = (* f27(1) f27(2)); infinite loop. -* f8(n: f11()); `f11()` not declared. -* f8(f8(3)); infinite loop. diff --git a/tests/test.org b/tests/test.org deleted file mode 100644 index 71ee52c..0000000 --- a/tests/test.org +++ /dev/null @@ -1 +0,0 @@ -* Test with Org Mode diff --git a/tests/test.rst b/tests/test.rst deleted file mode 100644 index eddab86..0000000 --- a/tests/test.rst +++ /dev/null @@ -1,2 +0,0 @@ -Test with reStructuredText -==========================