Skip to content

Commit 04c63dc

Browse files
CopilotT-Gro
andcommitted
Add tokenizer test for optional parameters - tokenization works correctly
Co-authored-by: T-Gro <[email protected]>
1 parent 72b1ecf commit 04c63dc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/FSharp.Compiler.Service.Tests/TokenizerTests.fs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,26 @@ let ``Unfinished idents``() =
223223
["IDENT", "```"]]
224224

225225
actual |> Assert.shouldBe expected
226+
227+
[<Fact>]
228+
let ``Tokenizer test - optional parameters with question mark``() =
229+
let tokenizedLines =
230+
tokenizeLines
231+
[| "member _.memb(?optional:string) = optional" |]
232+
233+
let actual =
234+
[ for lineNo, lineToks in tokenizedLines do
235+
yield lineNo, [ for str, info in lineToks do yield info.TokenName, str ] ]
236+
237+
let expected =
238+
[(0,
239+
[("MEMBER", "member"); ("WHITESPACE", " "); ("UNDERSCORE", "_"); ("DOT", ".");
240+
("IDENT", "memb"); ("LPAREN", "("); ("QMARK", "?");
241+
("IDENT", "optional"); ("COLON", ":"); ("IDENT", "string");
242+
("RPAREN", ")"); ("WHITESPACE", " "); ("EQUALS", "="); ("WHITESPACE", " ");
243+
("IDENT", "optional")])]
244+
245+
if actual <> expected then
246+
printfn "actual = %A" actual
247+
printfn "expected = %A" expected
248+
actual |> Assert.shouldBeEqualWith expected (sprintf "actual and expected did not match,actual =\n%A\nexpected=\n%A\n" actual expected)

0 commit comments

Comments
 (0)