diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index 900db1a..f80f2e5 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -234,6 +234,7 @@ identifiers are declared / referenced in which places." (or (= 1 (msg:find "unknown identifier")) (= 1 (msg:find "expected closing delimiter")) (= 1 (msg:find "expected body expression")) + (= 1 (msg:find "expected condition and body")) (= 1 (msg:find "expected whitespace before opening delimiter")) (= 1 (msg:find "malformed multisym")) (= 1 (msg:find "expected at least one pattern/body pair")))) diff --git a/test/completion-test.fnl b/test/completion-test.fnl index afc4c36..03bc220 100644 --- a/test/completion-test.fnl +++ b/test/completion-test.fnl @@ -219,14 +219,17 @@ (is.same (type completion.label) :string "unlabeled completion") (is.same (type completion.kind) :number (.. completion.label " needs a kind")) (is.same (type completion.documentation) :table (.. completion.label " needs documentation")) - (is.not.same completion.documentation :nil (.. completion.label " needs documentation")))))))) + (is.not.same completion.documentation :nil (.. completion.label " needs documentation"))))))) ;; (it "offers rich information about variable completions") ;; (it "offers rich information about field completions") ;; (it "offers rich information about method completions") ;; (it "offers rich information about module completions") ;; (it "offers rich information about macro-module completions"))) - + (it "completes things in an if statement with no body" + (check-completion "(if ge" 0 6 [:getmetatable] []) + (check-completion "(local x {:field 100})\n(if x.fi" 1 8 [:field] []) + (check-completion "(local x {:field 100})\n(when x.fi" 1 10 [:field] []))) ;; (it "suggests known fn keys when using the `:` special") ;; (it "suggests known keys when using the `.` special") ;; (it "suggests known module names in `require` and `include` and `import-macros` and `require-macros` and friends") diff --git a/test/is.fnl b/test/is.fnl index 6134421..cace418 100644 --- a/test/is.fnl +++ b/test/is.fnl @@ -8,4 +8,4 @@ :not {:nil #(do ((. (expect $1) :to :exist) $2) true) :same #(do ((. (expect $1) :to_not :equal) $2))} :truthy #(do ((. (expect $1) :to :be :truthy)) true)} - {:__call #(do ((. (expect $2) :to :be :truthy)) true)}) + {:__call #(do ((. (expect $2) :to :be :truthy) $3) true)}) diff --git a/test/lust.lua b/test/lust.lua index 1ef5b10..f3b9fd0 100644 --- a/test/lust.lua +++ b/test/lust.lua @@ -126,10 +126,10 @@ local paths = { a = { test = isa }, an = { test = isa }, be = { 'a', 'an', 'truthy', - test = function(v, x) + test = function(v, x, message) return v == x, - 'expected ' .. tostring(v) .. ' and ' .. tostring(x) .. ' to be equal', - 'expected ' .. tostring(v) .. ' and ' .. tostring(x) .. ' to not be equal' + message or 'expected ' .. tostring(v) .. ' and ' .. tostring(x) .. ' to be equal', + message or 'expected ' .. tostring(v) .. ' and ' .. tostring(x) .. ' to not be equal' end }, exist = { @@ -140,10 +140,10 @@ local paths = { end }, truthy = { - test = function(v) + test = function(v, message) return v, - 'expected ' .. tostring(v) .. ' to be truthy', - 'expected ' .. tostring(v) .. ' to not be truthy' + message or 'expected ' .. tostring(v) .. ' to be truthy', + message or 'expected ' .. tostring(v) .. ' to not be truthy' end }, equal = { @@ -154,14 +154,14 @@ local paths = { end }, have = { - test = function(v, x) + test = function(v, x, message) if type(v) ~= 'table' then error('expected ' .. tostring(v) .. ' to be a table') end return has(v, x), - 'expected ' .. tostring(v) .. ' to contain ' .. tostring(x), - 'expected ' .. tostring(v) .. ' to not contain ' .. tostring(x) + message or 'expected ' .. tostring(v) .. ' to contain ' .. tostring(x), + message or 'expected ' .. tostring(v) .. ' to not contain ' .. tostring(x) end }, fail = {