goto module definition tested
This commit is contained in:
parent
11c4af5ae1
commit
07e8239216
@ -56,7 +56,6 @@ identifiers are declared / referenced in which places."
|
||||
position (utils.pos->position file.text line byte server.position-encoding)]
|
||||
{:start position :end position}))
|
||||
|
||||
|
||||
(λ compile [{:configuration {: macro-path} :root-uri ?root-uri &as server} file]
|
||||
"Compile the file, and record all the useful information from the compiler into the file object"
|
||||
;; The useful information being recorded:
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
;; "|" is the cursor
|
||||
;; "==" is the definition that should be found
|
||||
(fn test-basics []
|
||||
(fn test-local []
|
||||
(check "(fn ==x== []) x|")
|
||||
|
||||
(check "(local ==x== 10)
|
||||
@ -77,7 +77,7 @@
|
||||
(check "==(fn foo| [] nil)==")
|
||||
nil)
|
||||
|
||||
(fn test-indirection []
|
||||
(fn test-fields []
|
||||
(check "(fn ==target== [] nil)
|
||||
(local obstacle {: target})
|
||||
(obstacle.tar|get)")
|
||||
@ -131,6 +131,19 @@
|
||||
(local (a b) (values {:x y : y} {: x : y}))
|
||||
(print b.x| a)")
|
||||
|
||||
(check "(local a {:b {:c =={:d #\"hi\"}==}})
|
||||
(a.b.|c.d)")
|
||||
|
||||
(check "(local a {:b {:c =={:d #\"hi\"}==}})
|
||||
(a.b.c|.d)")
|
||||
|
||||
;; finds fn declarations
|
||||
(check "(local M {})
|
||||
(fn ==M.my-function== [] nil)
|
||||
(M.my-function|)")
|
||||
nil)
|
||||
|
||||
(fn test-thru-require []
|
||||
(check
|
||||
{:foo.fnl "(fn ==target== []
|
||||
nil)
|
||||
@ -175,23 +188,22 @@
|
||||
; :main.fnl "(local {: target} (require :f|oo))
|
||||
; (target)"}))
|
||||
|
||||
(check "(local a {:b {:c =={:d #\"hi\"}==}})
|
||||
(a.b.|c.d)")
|
||||
|
||||
(check "(local a {:b {:c =={:d #\"hi\"}==}})
|
||||
(a.b.c|.d)")
|
||||
|
||||
|
||||
|
||||
nil)
|
||||
|
||||
; (fn test-macro []
|
||||
; (check "(macro ==my-macro== [] `nil)
|
||||
; (my-mac|ro)")
|
||||
; (check {:m.fnl ";; fennel-ls: macro-file
|
||||
; (fn ==my-macro== [] `nil)
|
||||
; {: my-macro}"
|
||||
; :main.fnl "(import-macros m :m)
|
||||
; (m.my-macro|)"}))
|
||||
|
||||
(fn test-no-crash []
|
||||
|
||||
(check "(macro cool [a b] `(let [,b 10] ,a))\n(cool |x ==x==)")
|
||||
(check "(macro cool [a b] `(let [,b 10] ,a))\n(cool x x|)")
|
||||
|
||||
(check "|#$..."))
|
||||
(check "|#$...")
|
||||
nil)
|
||||
|
||||
; ;; (it "can go to a destructured function argument")
|
||||
; ;; (it "can go through more than one file")
|
||||
@ -202,13 +214,13 @@
|
||||
; ;; (it "can follow import-macros (namespaced)")
|
||||
; ;; (it "can go to the definition in a lua file")
|
||||
; ;; (it "finds (set a.b) definitions")
|
||||
; (it "finds (fn a.b [] ...) declarations"
|
||||
; ;; (it "finds (tset a :b) definitions")
|
||||
; ;; (it "finds (setmetatable a {:__index {:b def}) definitions")
|
||||
; ;; (it "finds definitions into a function (fn foo [] (local x 10) {: x}) (let [result (foo)] (print result.x)) finds result.x")
|
||||
; ;; (it "finds definitions through a function (fn foo [{: y}] {:x y}) (let [result (foo {:y {}})] (print result.x)) finds result.x")
|
||||
; ;; (it "finds through setmetatable with an :__index function")
|
||||
|
||||
{: test-basics
|
||||
: test-indirection
|
||||
{: test-local
|
||||
: test-fields
|
||||
: test-thru-require
|
||||
: test-no-crash}
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
(local faith (require :faith))
|
||||
(local fennel (require :fennel))
|
||||
|
||||
(faith.run
|
||||
[:test.json-rpc
|
||||
:test.string-processing
|
||||
:test.capabilities
|
||||
:test.settings
|
||||
:test.diagnostic
|
||||
:test.goto-definition
|
||||
:test.hover
|
||||
:test.completion
|
||||
:test.references
|
||||
:test.lint
|
||||
:test.code-action
|
||||
:test.rename
|
||||
:test.misc
|
||||
:test.check])
|
||||
(case (os.getenv "FAITH_TEST")
|
||||
target (let [(module function) (target:match "([^ ]+) ([^ ]+)")]
|
||||
(xpcall (. (require module) function) #(print ($:tostring target))))
|
||||
_ (faith.run
|
||||
[:test.json-rpc
|
||||
:test.string-processing
|
||||
:test.capabilities
|
||||
:test.settings
|
||||
:test.diagnostic
|
||||
:test.goto-definition
|
||||
:test.hover
|
||||
:test.completion
|
||||
:test.references
|
||||
:test.lint
|
||||
:test.code-action
|
||||
:test.rename
|
||||
:test.misc
|
||||
:test.check]))
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
(local dispatch (require :fennel-ls.dispatch))
|
||||
(local message (require :fennel-ls.message))
|
||||
|
||||
(local ROOT-PATH
|
||||
(-> (io.popen "pwd")
|
||||
(: :read :*a)
|
||||
(: :sub 1 -2) ;; take off newline
|
||||
(.. "/test/test-project")))
|
||||
(local ROOT-PATH "/path/to/test/project")
|
||||
|
||||
(local ROOT-URI
|
||||
(.. "file://" ROOT-PATH))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user