Skip to content

Commit

Permalink
add some validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Azpillaga Aldalur committed Nov 28, 2023
1 parent 70287e4 commit 5200bca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/test/typescript/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ test("antlr", () =>
let tokens = new CommonTokenStream(lexer);
let parser = new JSONParser(tokens);
let tree = parser.json();
console.log(tree.value().obj().pair());
assert(tree.value().obj().pair().length === 6);
});
23 changes: 23 additions & 0 deletions src/test/typescript/validation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { test } from "mocha";
import { JSONASTParser } from "../../main/typescript/ast/parser";
import { readFileSync } from "fs";
import assert from "assert";

test("comprehensive is invalid configuration", () =>
{
let code = readFileSync(`${__dirname}/../resources/comprehensive.json`).toString();
let parser = new JSONASTParser();
let ast = parser.parse(code);

assert(!ast.correct);
});


test("configuration is valid configuration", () =>
{
let code = readFileSync(`${__dirname}/../resources/configuration.json`).toString();
let parser = new JSONASTParser();
let ast = parser.parse(code);

assert(ast.correct);
});

0 comments on commit 5200bca

Please sign in to comment.