Compare commits
3 Commits
37eb069a1b
...
30100855cf
Author | SHA1 | Date |
---|---|---|
perro tuerto | 30100855cf | |
perro tuerto | e7db4df984 | |
perro tuerto | 328cca695b |
14
README.md
14
README.md
|
@ -28,7 +28,7 @@ For example, if `DOC` is `source.md` and the output `FORMAT` is HTML, do:
|
||||||
|
|
||||||
Learn how to do LiNP [here].
|
Learn how to do LiNP [here].
|
||||||
|
|
||||||
## Test
|
## Develop
|
||||||
|
|
||||||
Clone this repo:
|
Clone this repo:
|
||||||
|
|
||||||
|
@ -38,17 +38,15 @@ Enter the repo:
|
||||||
|
|
||||||
cd literate-pandoc
|
cd literate-pandoc
|
||||||
|
|
||||||
Inside, do:
|
Inside, do the tests:
|
||||||
|
|
||||||
sh scripts/test.sh FORMAT1 FORMAT2
|
sh scripts/test.sh
|
||||||
|
|
||||||
For example, if `FORMAT1` is Markdwon and `FORMAT2` is HTML, do:
|
For other kind of tests, do:
|
||||||
|
|
||||||
sh tests/test.sh markdown html
|
sh scripts/test.sh -h
|
||||||
|
|
||||||
For distribution tests, do:
|
Contribute!
|
||||||
|
|
||||||
sh scripts/test.sh FORMAT1 FORMAT2
|
|
||||||
|
|
||||||
## Acknowledgments
|
## Acknowledgments
|
||||||
|
|
||||||
|
|
|
@ -6352,7 +6352,7 @@ return {
|
||||||
if is_chosen(block) then
|
if is_chosen(block) then
|
||||||
raw = sanitize(block.content)
|
raw = sanitize(block.content)
|
||||||
doc = lit.parse(raw)
|
doc = lit.parse(raw)
|
||||||
print(doc)
|
-- print(doc)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,52 @@
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
FILTER=dist/linp.lua
|
FILTER=dist/linp.lua
|
||||||
|
FILES="tests/*.md"
|
||||||
|
VERBOSE=false
|
||||||
|
CMD="sh $0"
|
||||||
|
|
||||||
# Checks args
|
# Prints help
|
||||||
if [ -z "$@" ]; then
|
echo_help () {
|
||||||
echo "ERROR: At least one argument is needed. For example:"
|
echo "Usage:"
|
||||||
echo " sh $0 native"
|
echo " $CMD [-vh] [FILES]"
|
||||||
echo " sh $0 native markdown"
|
echo "Examples:"
|
||||||
exit 1
|
echo " $CMD Tests with 'tests/*.md'"
|
||||||
|
echo " $CMD -v Verbose tests with 'tests/*.md'"
|
||||||
|
echo " $CMD tests/fail* Tests with 'tests/fail*'"
|
||||||
|
echo " $CMD -v tests/fail* Verbose tests with 'tests/fail*'"
|
||||||
|
echo " $CMD -h Display this help"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# Obtains result as "pass" | "fail" | "diff" (AST doesn't match)
|
||||||
|
get_result () {
|
||||||
|
result=$([[ $1 -eq 0 ]] && echo "pass" || echo "fail")
|
||||||
|
if [ -f $2.json ]; then
|
||||||
|
diff1=$(cat tmp.json | jq)
|
||||||
|
diff2=$(cat $2.json | jq)
|
||||||
|
difference=$(diff <( printf '%s\n' "$diff1" ) <( printf '%s\n' "$diff2" ))
|
||||||
|
result=$([[ $? -eq 0 ]] && echo "pass" || echo "diff")
|
||||||
|
fi
|
||||||
|
echo $result
|
||||||
|
}
|
||||||
|
|
||||||
|
# Checks options
|
||||||
|
while getopts ':vh' opt; do
|
||||||
|
case "$opt" in
|
||||||
|
v) VERBOSE=true ; shift ;;
|
||||||
|
h) echo_help ;;
|
||||||
|
?) echo "ERROR: only -v or -h is allowed" ; exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Checks for files
|
||||||
|
if [ $# -ne 0 ]; then
|
||||||
|
for file in $*; do
|
||||||
|
if [ ! -f $file ]; then
|
||||||
|
echo "ERROR: '$file' is not a file; do '$CMD -h' for more info" ; exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
FILES=$*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Makes distribution bundle
|
# Makes distribution bundle
|
||||||
|
@ -16,10 +55,15 @@ sh scripts/make_dist.sh
|
||||||
|
|
||||||
# Does tests
|
# Does tests
|
||||||
clear && echo "🐾 Starting tests"
|
clear && echo "🐾 Starting tests"
|
||||||
for arg in "$@"; do
|
for testfile in $FILES; do
|
||||||
echo && echo "⚗️ Test in '$arg' format:"
|
echo "⚗️ $testfile:"
|
||||||
mds=$'\n\n'`(pandoc -t markdown tests/*.md)`
|
expectation=${testfile:6:4}
|
||||||
rst=$'\n\n'`(pandoc -t markdown tests/*.rst)`
|
ast=$(pandoc -L $FILTER -t json -o tmp.json $testfile)
|
||||||
org=$'\n\n'`(pandoc -t markdown tests/*.org)`
|
result=$(get_result $? $testfile)
|
||||||
echo "$mds" "$rst" "$org" | pandoc -L $FILTER -t $arg
|
echo " Expect: $expectation"
|
||||||
|
echo " Result: $result"
|
||||||
|
if [ "$VERBOSE" = true ]; then
|
||||||
|
pandoc -L $FILTER -t native $testfile
|
||||||
|
fi
|
||||||
|
rm tmp.json
|
||||||
done
|
done
|
||||||
|
|
|
@ -26,7 +26,7 @@ return {
|
||||||
if is_chosen(block) then
|
if is_chosen(block) then
|
||||||
raw = sanitize(block.content)
|
raw = sanitize(block.content)
|
||||||
doc = lit.parse(raw)
|
doc = lit.parse(raw)
|
||||||
print(doc)
|
-- print(doc)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
|
@ -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.
|
|
@ -0,0 +1,50 @@
|
||||||
|
# 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.
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,29 @@
|
||||||
|
# Not declarations
|
||||||
|
|
||||||
|
-- skipped: \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() skipped
|
||||||
|
- 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
|
|
@ -0,0 +1 @@
|
||||||
|
{"pandoc-api-version":[1,23],"meta":{},"blocks":[{"t":"Header","c":[1,["not-declarations",[],[]],[{"t":"Str","c":"Not"},{"t":"Space"},{"t":"Str","c":"declarations"}]]},{"t":"CodeBlock","c":[["",[],[]],"-- skipped: \\fn1()\n1 + 2\n\n-- doesn't starts with `%a` because of the space: fn 2()\n1 + 2\n\n-- doesn't continue with `%w`: fn-3()\n1 + 2\n\n-- space before `(`: fn4 ()\n1 + 2\n\n-- misses `(`: fn5) \n1 + 2\n\n-- misses `()`: fn6 \n1 + 2"]},{"t":"Header","c":[1,["not-calls",[],[]],[{"t":"Str","c":"Not"},{"t":"Space"},{"t":"Str","c":"calls"}]]},{"t":"BulletList","c":[[{"t":"Plain","c":[{"t":"RawInline","c":["tex","\\fn1"]},{"t":"Str","c":"()"},{"t":"Space"},{"t":"Str","c":"skipped"}]}],[{"t":"Plain","c":[{"t":"Str","c":"fn"},{"t":"Space"},{"t":"Str","c":"2()"},{"t":"Space"},{"t":"Str","c":"doesn’t"},{"t":"Space"},{"t":"Str","c":"starts"},{"t":"Space"},{"t":"Str","c":"with"},{"t":"Space"},{"t":"Code","c":[["",[],[]],"%a"]},{"t":"Space"},{"t":"Str","c":"because"},{"t":"Space"},{"t":"Str","c":"of"},{"t":"Space"},{"t":"Str","c":"the"},{"t":"Space"},{"t":"Str","c":"space"}]}],[{"t":"Plain","c":[{"t":"Str","c":"fn-3()"},{"t":"Space"},{"t":"Str","c":"doesn’t"},{"t":"Space"},{"t":"Str","c":"continue"},{"t":"Space"},{"t":"Str","c":"with"},{"t":"Space"},{"t":"Code","c":[["",[],[]],"%w"]}]}],[{"t":"Plain","c":[{"t":"Str","c":"fn4"},{"t":"Space"},{"t":"Str","c":"()"},{"t":"Space"},{"t":"Str","c":"space"},{"t":"Space"},{"t":"Str","c":"before"},{"t":"Space"},{"t":"Code","c":[["",[],[]],"("]}]}],[{"t":"Plain","c":[{"t":"Str","c":"fn5)"},{"t":"Space"},{"t":"Str","c":"misses"},{"t":"Space"},{"t":"Code","c":[["",[],[]],"("]}]}],[{"t":"Plain","c":[{"t":"Str","c":"fn6"},{"t":"Space"},{"t":"Str","c":"misses"},{"t":"Space"},{"t":"Code","c":[["",[],[]],"()"]}]}],[{"t":"Plain","c":[{"t":"Code","c":[["",[],[]],"fn1()"]},{"t":"Space"},{"t":"Str","c":"as"},{"t":"Space"},{"t":"Str","c":"inline"},{"t":"Space"},{"t":"Str","c":"code"}]}]]}]}
|
|
@ -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)
|
File diff suppressed because one or more lines are too long
|
@ -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)
|
|
@ -0,0 +1 @@
|
||||||
|
{"pandoc-api-version":[1,23],"meta":{},"blocks":[{"t":"Header","c":[1,["declaration-override",[],[]],[{"t":"Str","c":"Declaration"},{"t":"Space"},{"t":"Str","c":"Override"}]]},{"t":"CodeBlock","c":[["",[],[]],"-- fn1()\n1 + 2 + 3\n\n-- fn1()\n4 + 5 + 6"]},{"t":"Header","c":[1,["unused-declaration",[],[]],[{"t":"Str","c":"Unused"},{"t":"Space"},{"t":"Str","c":"Declaration"}]]},{"t":"CodeBlock","c":[["",[],[]],"-- fn2(n)\n#n .. \" \" .. #n"]},{"t":"Header","c":[1,["declaration-with-unused-argument",[],[]],[{"t":"Str","c":"Declaration"},{"t":"Space"},{"t":"Str","c":"with"},{"t":"Space"},{"t":"Str","c":"Unused"},{"t":"Space"},{"t":"Str","c":"Argument"}]]},{"t":"CodeBlock","c":[["",[],[]],"-- fn3(a)\n7 + 8 + 9"]},{"t":"Header","c":[1,["calls",[],[]],[{"t":"Str","c":"Calls"}]]},{"t":"BulletList","c":[[{"t":"Plain","c":[{"t":"Str","c":"fn1()"}]}],[{"t":"Plain","c":[{"t":"Str","c":"fn3(1)"}]}]]}]}
|
133
tests/test.md
133
tests/test.md
|
@ -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.
|
|
|
@ -1 +0,0 @@
|
||||||
* Test with Org Mode
|
|
|
@ -1,2 +0,0 @@
|
||||||
Test with reStructuredText
|
|
||||||
==========================
|
|
Loading…
Reference in New Issue