Skip to content

Commit de2149b

Browse files
committed
add more cases to tests
1 parent 27de032 commit de2149b

File tree

2 files changed

+45
-20
lines changed

2 files changed

+45
-20
lines changed

analysis/tests/src/CompletionFunctionArguments.res

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ let _ = someFn(
2525
},
2626
)
2727

28-
let someOtherFn = (includeName, age) => {
29-
"Hello" ++ (includeName ? " Some Name" : "") ++ ", you are age " ++ Belt.Int.toString(age)
28+
let someOtherFn = (includeName, age, includeAge) => {
29+
"Hello" ++
30+
(includeName ? " Some Name" : "") ++
31+
", you are age " ++
32+
Belt.Int.toString(includeAge ? age : 0)
3033
}
3134

3235
// let _ = someOtherFn(f)
@@ -58,6 +61,14 @@ let someFnTakingVariant = (
5861
// let _ = someFnTakingVariant(~configOpt2=O)
5962
// ^com
6063

64+
// --- UNIMPLEMENTED CASES ---
65+
// The following two cases does not complete to a values because of ambiguity - should it complete for a value, or for a named argument? We don't know whether the function has args or not when deciding, since we're just in the AST at that point. Can potentially be fixed in the future.
66+
// let _ = someOtherFn()
67+
// ^com
68+
// let _ = someOtherFn(1, 2, )
69+
// ^com
70+
71+
// --- BROKEN PARSER CASES ---
6172
// This below demonstrates an issue when what you're completing is the _last_ labelled argument, and there's a unit application after it. The parser wrongly merges the unit argument as the expression of the labelled argument assignment, where is should really let the trailing unit argument be, and set a %rescript.exprhole as the expression of the assignment, just like it normally does.
6273
// let _ = someFn(~isOff=, ())
6374
// ^com

analysis/tests/src/expected/CompletionFunctionArguments.res.txt

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ Completable: Value[someFn](~isOn)
7474
"documentation": null
7575
}]
7676

77-
Complete src/CompletionFunctionArguments.res 31:24
78-
posCursor:[31:24] posNoWhite:[31:23] Found expr:[31:11->31:25]
79-
Pexp_apply ...[31:11->31:22] (...[31:23->31:24])
77+
Complete src/CompletionFunctionArguments.res 34:24
78+
posCursor:[34:24] posNoWhite:[34:23] Found expr:[34:11->34:25]
79+
Pexp_apply ...[34:11->34:22] (...[34:23->34:24])
8080
Completable: Value[someOtherFn]($0=f)
8181
[{
8282
"label": "false",
@@ -86,9 +86,9 @@ Completable: Value[someOtherFn]($0=f)
8686
"documentation": null
8787
}]
8888

89-
Complete src/CompletionFunctionArguments.res 48:39
90-
posCursor:[48:39] posNoWhite:[48:38] Found expr:[48:11->48:40]
91-
Pexp_apply ...[48:11->48:30] (~config48:32->48:38=...__ghost__[0:-1->0:-1])
89+
Complete src/CompletionFunctionArguments.res 51:39
90+
posCursor:[51:39] posNoWhite:[51:38] Found expr:[51:11->51:40]
91+
Pexp_apply ...[51:11->51:30] (~config51:32->51:38=...__ghost__[0:-1->0:-1])
9292
Completable: Value[someFnTakingVariant](~config)
9393
[{
9494
"label": "One",
@@ -110,9 +110,9 @@ Completable: Value[someFnTakingVariant](~config)
110110
"documentation": null
111111
}]
112112

113-
Complete src/CompletionFunctionArguments.res 51:40
114-
posCursor:[51:40] posNoWhite:[51:39] Found expr:[51:11->51:41]
115-
Pexp_apply ...[51:11->51:30] (~config51:32->51:38=...[51:39->51:40])
113+
Complete src/CompletionFunctionArguments.res 54:40
114+
posCursor:[54:40] posNoWhite:[54:39] Found expr:[54:11->54:41]
115+
Pexp_apply ...[54:11->54:30] (~config54:32->54:38=...[54:39->54:40])
116116
Completable: Value[someFnTakingVariant](~config=O)
117117
[{
118118
"label": "One",
@@ -128,9 +128,9 @@ Completable: Value[someFnTakingVariant](~config=O)
128128
"documentation": null
129129
}]
130130

131-
Complete src/CompletionFunctionArguments.res 54:32
132-
posCursor:[54:32] posNoWhite:[54:31] Found expr:[54:11->54:33]
133-
Pexp_apply ...[54:11->54:30] (...[54:31->54:32])
131+
Complete src/CompletionFunctionArguments.res 57:32
132+
posCursor:[57:32] posNoWhite:[57:31] Found expr:[57:11->57:33]
133+
Pexp_apply ...[57:11->57:30] (...[57:31->57:32])
134134
Completable: Value[someFnTakingVariant]($0=S)
135135
[{
136136
"label": "Some(_)",
@@ -140,9 +140,9 @@ Completable: Value[someFnTakingVariant]($0=S)
140140
"documentation": null
141141
}]
142142

143-
Complete src/CompletionFunctionArguments.res 57:44
144-
posCursor:[57:44] posNoWhite:[57:43] Found expr:[57:11->57:45]
145-
Pexp_apply ...[57:11->57:30] (~configOpt257:32->57:42=...[57:43->57:44])
143+
Complete src/CompletionFunctionArguments.res 60:44
144+
posCursor:[60:44] posNoWhite:[60:43] Found expr:[60:11->60:45]
145+
Pexp_apply ...[60:11->60:30] (~configOpt260:32->60:42=...[60:43->60:44])
146146
Completable: Value[someFnTakingVariant](~configOpt2=O)
147147
[{
148148
"label": "One",
@@ -158,9 +158,23 @@ Completable: Value[someFnTakingVariant](~configOpt2=O)
158158
"documentation": null
159159
}]
160160

161-
Complete src/CompletionFunctionArguments.res 61:25
162-
posCursor:[61:25] posNoWhite:[61:24] Found expr:[61:11->61:30]
163-
Pexp_apply ...[61:11->61:17] (~isOff61:19->61:24=...[61:27->61:29])
161+
Complete src/CompletionFunctionArguments.res 65:23
162+
posCursor:[65:23] posNoWhite:[65:22] Found expr:[65:11->65:24]
163+
Pexp_apply ...[65:11->65:22] (...[65:23->65:24])
164+
Completable: CnamedArg(Value[someOtherFn], "", [])
165+
Found type for function (bool, int, bool) => string
166+
[]
167+
168+
Complete src/CompletionFunctionArguments.res 67:28
169+
posCursor:[67:28] posNoWhite:[67:27] Found expr:[67:11->67:30]
170+
Pexp_apply ...[67:11->67:22] (...[67:23->67:24], ...[67:26->67:27])
171+
Completable: CnamedArg(Value[someOtherFn], "", [])
172+
Found type for function (bool, int, bool) => string
173+
[]
174+
175+
Complete src/CompletionFunctionArguments.res 72:25
176+
posCursor:[72:25] posNoWhite:[72:24] Found expr:[72:11->72:30]
177+
Pexp_apply ...[72:11->72:17] (~isOff72:19->72:24=...[72:27->72:29])
164178
Completable: CnamedArg(Value[someFn], "", [isOff])
165179
Found type for function (~isOn: bool, ~isOff: bool=?, unit) => string
166180
[{

0 commit comments

Comments
 (0)