Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,36 @@ let y = f {|$0|}"""
Diagnostics.acceptAll
(CodeFix.withTitle GenerateAnonRecordStub.title)
"""let f (x: {| A: int |}) = x
let y = f {| A = failwith "Not Implemented" |}""" ])
let y = f {| A = failwith "Not Implemented" |}"""

testCaseAsync "add missing field in type-annotated let binding"
<| CodeFix.check
server
"""let y: {| A: int; B: string |} = {| A$0 = 1 |}"""
Diagnostics.acceptAll
(CodeFix.withTitle GenerateAnonRecordStub.title)
"""let y: {| A: int; B: string |} = {| A = 1; B = failwith "Not Implemented" |}"""

testCaseAsync "add missing field when record has trailing spaces before closing bracket"
<| CodeFix.check
server
"""let f (x: {| A: int; B: string |}) = x
let y = f {| A$0 = 1 |}"""
Diagnostics.acceptAll
(CodeFix.withTitle GenerateAnonRecordStub.title)
"""let f (x: {| A: int; B: string |}) = x
let y = f {| A = 1; B = failwith "Not Implemented" |}"""

testCaseAsync "add missing field when record is in match arm"
<| CodeFix.check
server
"""let f (x: {| A: int; B: string |}) = x
let y =
match 1 with
| _ -> f {| A$0 = 1 |}"""
Diagnostics.acceptAll
(CodeFix.withTitle GenerateAnonRecordStub.title)
"""let f (x: {| A: int; B: string |}) = x
let y =
match 1 with
| _ -> f {| A = 1; B = failwith "Not Implemented" |}""" ])
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,39 @@ let tests state =
Diagnostics.acceptAll
(CodeFix.withTitle (IntroduceMissingBinding.title "myTopLevel"))
"let myTopLevel = failwith \"Not Implemented\"
let x = myTopLevel + 1" ])
let x = myTopLevel + 1"

testCaseAsync "does not apply to qualified names"
<| CodeFix.checkNotApplicable
server
"let x = MyModule.$0missingValue"
Diagnostics.acceptAll
(CodeFix.withTitle (IntroduceMissingBinding.title "missingValue"))

testCaseAsync "introduce binding in deeply nested context"
<| CodeFix.check
server
"let a () =
let b () =
let c () =
deeplyNested$0
c ()
b ()"
Diagnostics.acceptAll
(CodeFix.withTitle (IntroduceMissingBinding.title "deeplyNested"))
"let a () =
let b () =
let c () =
let deeplyNested = failwith \"Not Implemented\"
deeplyNested
c ()
b ()"

testCaseAsync "introduce binding used in expression context"
<| CodeFix.check
server
"let result = missingFn$0 42 + 1"
Diagnostics.acceptAll
(CodeFix.withTitle (IntroduceMissingBinding.title "missingFn"))
"let missingFn = failwith \"Not Implemented\"
let result = missingFn 42 + 1" ])
Loading