| 1 |
(local t (require :test.faith)) |
| 2 |
(local fennel (require :fennel)) |
| 3 |
(local linter (fennel.dofile "src/linter.fnl" {:env :_COMPILER :compilerEnv _G})) |
| 4 |
(local options {:plugins [linter]}) |
| 5 |
|
| 6 |
(fn test-used [] |
| 7 |
"A test for the locals shadowing bug described in |
| 8 |
https://todo.sr.ht/~technomancy/fennel/12" |
| 9 |
(let [src "(fn [abc] (let [abc abc] abc))" |
| 10 |
(ok? msg) (pcall fennel.compile-string src options)] |
| 11 |
(t.is ok? msg))) |
| 12 |
|
| 13 |
(fn test-arity-check [] |
| 14 |
(let [src "(let [s (require :test.mod.splice)] (s.myfn 1))" |
| 15 |
ok? (pcall fennel.compile-string src options)] |
| 16 |
(when (not= _VERSION "Lua 5.1") ; debug.getinfo nparams was added in 5.2 |
| 17 |
(t.is (not ok?))))) |
| 18 |
|
| 19 |
(fn test-missing-fn [] |
| 20 |
(let [src "(let [s (require :test.mod.splice)] (s.missing-fn))" |
| 21 |
ok? (pcall fennel.compile-string src options)] |
| 22 |
(t.is (not ok?)))) |
| 23 |
|
| 24 |
(fn test-var-never-set [] |
| 25 |
(t.is (not (pcall fennel.compile-string "(var x 1) (+ x 9)" options))) |
| 26 |
(t.is (pcall fennel.compile-string "(var x 1) (set x 9)" options))) |
| 27 |
|
| 28 |
(fn teardown [] |
| 29 |
(let [utils (require :fennel.utils)] |
| 30 |
(set utils.root.options.plugins {}))) |
| 31 |
|
| 32 |
{: test-used |
| 33 |
: test-arity-check |
| 34 |
: test-missing-fn |
| 35 |
: test-var-never-set |
| 36 |
: teardown} |