From de4b8a7c1d5f7498bdcfc30a43253fc32f81e493 Mon Sep 17 00:00:00 2001 From: Joey Robichaud Date: Fri, 1 Sep 2023 12:45:25 -0700 Subject: [PATCH 1/2] Add test for casting a method invocation. Related to #125 --- test/expressions.tests.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/expressions.tests.ts b/test/expressions.tests.ts index 49ea9f3..395eea3 100644 --- a/test/expressions.tests.ts +++ b/test/expressions.tests.ts @@ -1669,6 +1669,35 @@ var x = new // comment ]); }); + it("cast of invocation", async () => { + const input = Input.InMethod(` + (int)y.M(); + (int) y.M(); + `); + const tokens = await tokenize(input); + + tokens.should.deep.equal([ + Token.Punctuation.OpenParen, + Token.PrimitiveType.Int, + Token.Punctuation.CloseParen, + Token.Variables.Object("y"), + Token.Punctuation.Accessor, + Token.Identifiers.MethodName("M"), + Token.Punctuation.OpenParen, + Token.Punctuation.CloseParen, + Token.Punctuation.Semicolon, + Token.Punctuation.OpenParen, + Token.PrimitiveType.Int, + Token.Punctuation.CloseParen, + Token.Variables.Object("y"), + Token.Punctuation.Accessor, + Token.Identifiers.MethodName("M"), + Token.Punctuation.OpenParen, + Token.Punctuation.CloseParen, + Token.Punctuation.Semicolon, + ]); + }); + it("as cast of identifier", async () => { const input = Input.InMethod(`var x = o as List>;`); const tokens = await tokenize(input); From 8c1d843da2958730a202f6f98d90d8af66e202a5 Mon Sep 17 00:00:00 2001 From: Joey Robichaud Date: Fri, 1 Sep 2023 12:50:28 -0700 Subject: [PATCH 2/2] Fix test --- test/expressions.tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/expressions.tests.ts b/test/expressions.tests.ts index 395eea3..7cdf754 100644 --- a/test/expressions.tests.ts +++ b/test/expressions.tests.ts @@ -1680,18 +1680,18 @@ var x = new // comment Token.Punctuation.OpenParen, Token.PrimitiveType.Int, Token.Punctuation.CloseParen, - Token.Variables.Object("y"), + Token.Variable.Object("y"), Token.Punctuation.Accessor, - Token.Identifiers.MethodName("M"), + Token.Identifier.MethodName("M"), Token.Punctuation.OpenParen, Token.Punctuation.CloseParen, Token.Punctuation.Semicolon, Token.Punctuation.OpenParen, Token.PrimitiveType.Int, Token.Punctuation.CloseParen, - Token.Variables.Object("y"), + Token.Variable.Object("y"), Token.Punctuation.Accessor, - Token.Identifiers.MethodName("M"), + Token.Identifier.MethodName("M"), Token.Punctuation.OpenParen, Token.Punctuation.CloseParen, Token.Punctuation.Semicolon,