Fix completion problem in (if) conditions with no body

This commit is contained in:
XeroOl 2024-02-23 23:52:27 -06:00
parent f54ddc6e08
commit a7d6122670
4 changed files with 16 additions and 12 deletions

View File

@ -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"))))

View File

@ -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")

View File

@ -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)})

View File

@ -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 = {