diff --git a/packages/compiler/test/expression_parser/parser_spec.ts b/packages/compiler/test/expression_parser/parser_spec.ts index 0c1f33c8f2..91a7de4621 100644 --- a/packages/compiler/test/expression_parser/parser_spec.ts +++ b/packages/compiler/test/expression_parser/parser_spec.ts @@ -128,15 +128,22 @@ describe('parser', () => { }); it('should only allow identifier or keyword as member names', () => { - expectActionError('x.(', 'identifier or keyword'); - expectActionError('x. 1234', 'identifier or keyword'); - expectActionError('x."foo"', 'identifier or keyword'); + checkActionWithError('x.', 'x.', 'identifier or keyword'); + checkActionWithError('x.(', 'x.', 'identifier or keyword'); + checkActionWithError('x. 1234', 'x.', 'identifier or keyword'); + checkActionWithError('x."foo"', 'x.', 'identifier or keyword'); }); it('should parse safe field access', () => { checkAction('a?.a'); checkAction('a.a?.a'); }); + + it('should parse incomplete safe field accesses', () => { + checkActionWithError('a?.a.', 'a?.a.', 'identifier or keyword'); + checkActionWithError('a.a?.a.', 'a.a?.a.', 'identifier or keyword'); + checkActionWithError('a.a?.a?. 1234', 'a.a?.a?.', 'identifier or keyword'); + }); }); describe('method calls', () => { @@ -1013,8 +1020,7 @@ function expectBindingError(text: string, message: string) { } /** - * Check that an malformed action parses to a recovered AST while emitting an - * error. + * Check that a malformed action parses to a recovered AST while emitting an error. */ function checkActionWithError(text: string, expected: string, error: string) { checkAction(text, expected);