fix string methods, and some tests
This commit is contained in:
parent
1e3edf800d
commit
8a1aa53505
@ -50,8 +50,9 @@
|
|||||||
def (do
|
def (do
|
||||||
(when (or (?. def :metadata :fnl/arglist)
|
(when (or (?. def :metadata :fnl/arglist)
|
||||||
(and (fennel.list? def.definition)
|
(and (fennel.list? def.definition)
|
||||||
(or (fennel.sym? (. def.definition 1) "fn"))
|
;; TODO check that arg is called `self`
|
||||||
(or (fennel.sym? (. def.definition 1) "λ"))))
|
(or (fennel.sym? (. def.definition 1) "fn")
|
||||||
|
(fennel.sym? (. def.definition 1) "λ"))))
|
||||||
(add-completion def (.. name ":" field)))
|
(add-completion def (.. name ":" field)))
|
||||||
(add-completion def (.. name "." field)))
|
(add-completion def (.. name "." field)))
|
||||||
_ (do
|
_ (do
|
||||||
@ -60,7 +61,7 @@
|
|||||||
(when definition.fields
|
(when definition.fields
|
||||||
(each [field value (pairs definition.fields)]
|
(each [field value (pairs definition.fields)]
|
||||||
(when (= (type field) :string)
|
(when (= (type field) :string)
|
||||||
(add-completion value (.. name "." field)))))
|
(add-completion value (.. name ":" field)))))
|
||||||
|
|
||||||
(set (. seen definition) false)))
|
(set (. seen definition) false)))
|
||||||
;; end yield
|
;; end yield
|
||||||
|
|||||||
@ -77,8 +77,8 @@
|
|||||||
(check "#nil\n(" [:_G :debug :table :io :getmetatable :setmetatable
|
(check "#nil\n(" [:_G :debug :table :io :getmetatable :setmetatable
|
||||||
:_VERSION :ipairs :pairs :next] [])
|
:_VERSION :ipairs :pairs :next] [])
|
||||||
(check "(if ge" [:getmetatable] [])
|
(check "(if ge" [:getmetatable] [])
|
||||||
(check "(table.i" [:insert] [])
|
(check "(table.i" [:table.insert] [])
|
||||||
(check "(ins" [:table.insert] [])
|
(check "(tablei" [:table.insert] [])
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
(fn test-local []
|
(fn test-local []
|
||||||
@ -108,7 +108,7 @@
|
|||||||
(check "(let [foo 10
|
(check "(let [foo 10
|
||||||
bar 20
|
bar 20
|
||||||
_ fo|" [:foo :bar] [])
|
_ fo|" [:foo :bar] [])
|
||||||
(check "(local x {:field 100})\n(if x.fi" [:field] [])
|
(check "(local x {:field 100})\n(if x.fi" [:x.field] [])
|
||||||
(check "(let [x 10] (let [x 10] x"
|
(check "(let [x 10] (let [x 10] x"
|
||||||
(fn [completions]
|
(fn [completions]
|
||||||
(faith.= 1 (accumulate [number-of-x 0 _ completion (ipairs completions)]
|
(faith.= 1 (accumulate [number-of-x 0 _ completion (ipairs completions)]
|
||||||
@ -154,13 +154,13 @@
|
|||||||
nil)
|
nil)
|
||||||
|
|
||||||
(fn test-field []
|
(fn test-field []
|
||||||
(check "(local x {:field (fn [])})\n(x:" [:field] [:local])
|
(check "(local x {:field (fn [])})\n(x:" [:x:field] [])
|
||||||
;; regression test for not crashing
|
;; regression test for not crashing
|
||||||
(check "(local x {:field (fn [])})\n(x::f" [] [])
|
(check "(local x {:field (fn [])})\n(x::f" [] [])
|
||||||
(check
|
(check
|
||||||
"(let [my-table {:foo 10 :bar 20}]\n my-table.|)))"
|
"(let [my-table {:foo 10 :bar 20}]\n my-table.|)))"
|
||||||
[:foo :bar]
|
[:foo :bar]
|
||||||
[:_G :local :doto :+]) ;; no globals, specials, macros, or others
|
[:local :doto :+]) ;; no specials or macros because it's not in a head position
|
||||||
(check
|
(check
|
||||||
{:main.fnl "(let [foo (require :fooo)]
|
{:main.fnl "(let [foo (require :fooo)]
|
||||||
foo.|)))"
|
foo.|)))"
|
||||||
@ -247,33 +247,24 @@
|
|||||||
[])
|
[])
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
(local eglot {:client-info {:name "Eglot" :version "1 million"}})
|
|
||||||
|
|
||||||
(fn test-eglot-fields []
|
(fn test-eglot-fields []
|
||||||
"tests for handling Eglot specially"
|
"tests for handling Eglot specially"
|
||||||
(check "(coroutine.y|"
|
(check "(coroutine.y|"
|
||||||
[{:label "yield"
|
[{:label "coroutine.yield"
|
||||||
:filterText "coroutine.yield"
|
:filterText "coroutine.yield"
|
||||||
:insertText "coroutine.yield"
|
|
||||||
:textEdit #(= nil $)
|
|
||||||
:documentation #(and $.value ($.value:find "```fnl\n(coroutine.yield ...)\n```" 1 true))}]
|
:documentation #(and $.value ($.value:find "```fnl\n(coroutine.yield ...)\n```" 1 true))}]
|
||||||
["coroutine" "_G" "do"
|
[])
|
||||||
{:documentation #(= nil $)}]
|
|
||||||
eglot)
|
|
||||||
(check "(local c coroutine)
|
(check "(local c coroutine)
|
||||||
(c.y"
|
(c.y"
|
||||||
[{:label "yield"
|
[{:label "c.yield"
|
||||||
:filterText "c.yield"
|
:filterText "c.yield"
|
||||||
:insertText "c.yield"
|
|
||||||
:textEdit #(= nil $)}]
|
:textEdit #(= nil $)}]
|
||||||
["coroutine" "_G" "do"]
|
[])
|
||||||
eglot)
|
|
||||||
(check "(local x {:field (fn [])})
|
(check "(local x {:field (fn [])})
|
||||||
(x:"
|
(x:"
|
||||||
[:field]
|
[:x:field]
|
||||||
[{:insertText :field}
|
[]))
|
||||||
:local]
|
|
||||||
eglot))
|
|
||||||
|
|
||||||
;; ;; Future tests / features
|
;; ;; Future tests / features
|
||||||
;; ;; Scope Ordering Rules
|
;; ;; Scope Ordering Rules
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user