clean up test code

This commit is contained in:
XeroOl 2023-05-29 12:21:36 -05:00
parent 74100ad8ec
commit a3f787b008
7 changed files with 12 additions and 29 deletions

View File

@ -1,9 +1,10 @@
# Wishlist of features
([X] = complete, [ ] = planned)
Each subsection is increasingly more of a stretch goal.
My current goal is to work on completions a little bit more.
Here is my feature wishlist. I don't expect to ever get all of this done, but these are the sort of enhancements I am thinking about.
- [X] Able to connect to a client
- [ ] Support for UTF-8 characters that aren't just plain ASCII. (especially `λ`) (perhaps just tell the IDE that I want to communicate with utf-8 offsets)
- [ ] Settings to configure lua / fennel path, allowed globals, etc
@ -26,7 +27,7 @@ My current goal is to work on completions a little bit more.
- [X] table mutation via `fn` special: `(fn obj.new-field [])`
- [ ] macro calls / which macros are in scope
- [ ] setmetatable
- [ ] function arguments / function calls
- [ ] can search through function arguments / function calls / method calls
- [ ] local/table mutation via set/tset
- [ ] .lua files (antifennel decompiler)
- [ ] mutation on aliased tables (difficult)
@ -50,7 +51,7 @@ My current goal is to work on completions a little bit more.
- [ ] Reports linting issues
- [X] Unused locals
- [ ] Discarding results from pcall/xpcall/other functions
- [ ] `unpack` or `values` into an operator special
- [ ] `unpack` or `values` into a special
- [ ] `do`/`values` with only one inner form
- [ ] redundant `do` as the last/only item in a form that accepts a "body"
- [ ] `var` forms that could be `local`
@ -82,4 +83,3 @@ My current goal is to work on completions a little bit more.
- [ ] arbitrary fields (may affect code behavior, may modify other files)
- [ ] formatting with fnlfmt
- [ ] Type annotations? Global type inference?

View File

@ -5,17 +5,15 @@
(local {: ROOT-URI
: create-client} (require :test.mock-client))
(local dispatch (require :fennel-ls.dispatch))
(local message (require :fennel-ls.message))
(local filename (.. ROOT-URI "/imaginary-file.fnl"))
(fn check-completion [body line col expected ?unexpected]
(let [client (doto (create-client)
(: :open-file! filename body))
response (client:completion filename line col)
seen (collect [_ suggestion (ipairs (. response 1 :result))]
suggestion.label suggestion.label)]
[{: result}] (client:completion filename line col)
seen (if result
(collect [_ suggestion (ipairs result)]
suggestion.label suggestion.label))]
(if expected
(each [_ exp (ipairs expected)]
(is (. seen exp) (.. exp " was not suggested, but should be"))))
@ -23,14 +21,6 @@
(each [_ exp (ipairs ?unexpected)]
(is.nil (. seen exp) (.. exp " was suggested, but shouldn't be"))))))
(fn check-no-completion [body line col expected ?unexpected]
(let [client (doto (create-client)
(: :open-file! filename body))
response (client:completion filename line col)]
(is-matching (. response 1)
{:jsonrpc "2.0" :id id :result nil}
"there shouldn't be a result")))
(describe "completions"
(it "suggests globals"
(check-completion "(" 0 1 [:_G :debug :table :io :getmetatable :setmetatable :_VERSION :ipairs :pairs :next]))
@ -74,7 +64,7 @@
(check-completion "(local x {:field (fn [])})\n(x:" 1 3 [:field] [:local]))
(it "doesn't crash with a partially typed multisym contains ::"
(check-no-completion "(local x {:field (fn [])})\n(x::f" 1 3 [:field])))
(check-completion "(local x {:field (fn [])})\n(x::f" 1 3 [])))
;; Functions
(it "suggests function arguments at the top scope of the function"

View File

@ -5,9 +5,6 @@
(local {: ROOT-URI
: create-client} (require :test.mock-client))
(local dispatch (require :fennel-ls.dispatch))
(local message (require :fennel-ls.message))
(macro find [t body ?sentinel]
(assert-compile (not ?sentinel) "you can only have one thing here, put a `(do)`")
(assert-compile (sequence? t) "[] square brackets please")

View File

@ -5,9 +5,6 @@
(local {: ROOT-URI
: create-client} (require :test.mock-client))
(local dispatch (require :fennel-ls.dispatch))
(local message (require :fennel-ls.message))
(describe "jump to definition"
(fn check [request-file line char response-file start-line start-col end-line end-col]

View File

@ -5,9 +5,6 @@
(local {: ROOT-URI
: create-client} (require :test.mock-client))
(local dispatch (require :fennel-ls.dispatch))
(local message (require :fennel-ls.message))
(describe "hover"
(fn check [request-file line char response-string]

View File

@ -11,7 +11,7 @@
result (client:definition (.. ROOT-URI :/test.fnl) 0 12)]
(is-matching
result
[{:result {:range message}}]
[{:result {:range _range}}]
"error message")))
;; (it "can set the path"

View File

@ -64,3 +64,5 @@
"this is the\nold file"
[{:text "And this is the\nnew file"}])
"And this is the\nnew file"))))
;; (it "can substitute multiple ranges")