Skip to content

Commit

Permalink
Add test for block-commented json attributes (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbush authored May 20, 2022
1 parent 0116a75 commit 734b7be
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/bluehawk/parser/visitor/jsonAttributeList.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,29 @@ describe("JSON attribute lists", () => {
});
});

it("allows block comments around JSON attribute list", () => {
// Note that end tag must be similarly commented and the comment tokens must
// be on the same line
const tokens = lexer.tokenize(`/* :a-tag-start: {
"att1": 1,
"att2": 2
} */
/* :a-tag-end: */
`);
expect(tokens.errors).toStrictEqual([]);
parser.input = tokens.tokens;
const cst = parser.annotatedText();
expect(parser.errors).toStrictEqual([]);
const visitor = makeCstVisitor(parser);
const result = visitor.visit(cst, source);
expect(result.errors).toStrictEqual([]);
expect(result.tagNodes[0].attributes).toStrictEqual({
att1: 1,
att2: 2,
});
});

it("does not strip line comments in strings", () => {
const tokens = lexer.tokenize(`// :A-tag-start: {
// "a": "//",
Expand Down

0 comments on commit 734b7be

Please sign in to comment.