From c74e9524a8d001869b11048abbc4a0f80c179de9 Mon Sep 17 00:00:00 2001 From: vighnesh153 Date: Mon, 2 Sep 2024 23:56:45 +0530 Subject: [PATCH] fix: parser error --- .../parser-xml/src/XmlParser.test.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nodejs-tools/nodejs-compiler-tools/parser-xml/src/XmlParser.test.ts b/nodejs-tools/nodejs-compiler-tools/parser-xml/src/XmlParser.test.ts index 3776d7e6..99fb9fbe 100644 --- a/nodejs-tools/nodejs-compiler-tools/parser-xml/src/XmlParser.test.ts +++ b/nodejs-tools/nodejs-compiler-tools/parser-xml/src/XmlParser.test.ts @@ -231,17 +231,25 @@ test('should parse tag with children', () => { `); }); -test('should return error if incorrect token position', () => { +test('should render naked text node', () => { const [parser, program] = parseProgram('manifest'); + expect(parser.errors.length).toBe(0); + expect(program.statements.length).toBe(1); + expect(program.toString(0)).toMatchInlineSnapshot(`"manifest"`); +}); + +test('should return error if incorrect token position', () => { + const [parser, program] = parseProgram('?'); + expect(parser.errors.length).toBe(1); expect(parser.errors[0].serialized()).toStrictEqual({ culpritToken: { columnNumber: 1, lineNumber: 1, - tokenLiteral: 'manifest', + tokenLiteral: '?', tokenType: { - value: 'IDENTIFIER', + value: '?', }, }, errorType: 'UNEXPECTED_TOKEN',