smoke: a match with no clauses is offered a clause for each case
A match with no clauses yet, and one whose clauses all have a guard, was offered (_ _). The compiler now offers each case it lacks, and the smoke test checks that both are: ((Circle _) _), ((Square _) _), (Empty _) under the match, and None and (Some _) after the guarded clause. 🤖 Generated with [ECA](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
parent
23b6a0e55c
commit
28341632fd
1 changed files with 30 additions and 0 deletions
|
|
@ -881,6 +881,20 @@ HOLES = """(type (: Shape (Union (: Circle int) (: Square int) Empty)))
|
|||
(defun (main) (println (int->string (total-size (list (default-shape))))) 0)
|
||||
"""
|
||||
|
||||
EMPTY_MATCH = """(type (: Shape (Union (: Circle int) (: Square int) Empty)))
|
||||
|
||||
(: size (-> Shape int))
|
||||
(defun (size s)
|
||||
(match s))
|
||||
|
||||
(: pick (-> (Option Shape) int))
|
||||
(defun (pick o)
|
||||
(match o
|
||||
(x #:when (some? x) 1)))
|
||||
|
||||
(defun (main) (println (int->string (+ (size Empty) (pick None)))) 0)
|
||||
"""
|
||||
|
||||
|
||||
def applied(text, edits):
|
||||
"""`text` with LSP text edits made, the last first."""
|
||||
|
|
@ -956,6 +970,22 @@ def acting(server, tmp):
|
|||
|
||||
expect("actions: nothing is offered away from a hole", actions(uri, HOLES, "(defun (add-size", 8) == [],
|
||||
actions(uri, HOLES, "(defun (add-size", 8))
|
||||
|
||||
# A match with no clauses yet lacks every case, each its own clause, not
|
||||
# one `_`; so does one whose clauses all have a guard.
|
||||
uri, found = open_("empty-match.bjo", EMPTY_MATCH)
|
||||
found = actions(uri, EMPTY_MATCH, "(match s", 1)
|
||||
empty = edit_of(found, "Add the 3 missing clauses", uri)
|
||||
expect("actions: a match with no clauses is offered every case",
|
||||
empty is not None, [a["title"] for a in found])
|
||||
fixed = applied(EMPTY_MATCH, empty or [])
|
||||
expect("actions: each case a clause, under the match",
|
||||
" (match s\n ((Circle _) _)\n ((Square _) _)\n (Empty _)))" in fixed, fixed)
|
||||
found = actions(uri, EMPTY_MATCH, "(match o", 1)
|
||||
guarded = edit_of(found, "Add the 2 missing clauses", uri)
|
||||
fixed = applied(EMPTY_MATCH, guarded or [])
|
||||
expect("actions: clauses that all have a guard cover nothing, so every case is offered",
|
||||
" (x #:when (some? x) 1)\n (None _)\n ((Some _) _)))" in fixed, fixed)
|
||||
server.diagnostics_after("textDocument/didClose", uri)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue