Skip to content

Commit 2aa3c28

Browse files
Copilothzhangxyz
andauthored
Add Jest tests for BNF parse/unparse functions (#78)
* Initial plan * Add JavaScript tests for BNF parse/unparse functions with Jest - Created bnf/tests/test_parse_unparse.mjs with 18 test cases - Added Jest configuration in bnf/jest.config.mjs - Updated bnf/package.json to include test script and Jest dependencies - Fixed bug in UnparseVisitor.visitUnary() to use getChild(1) instead of getChild(0) - Updated ANTLR parser generation scripts to use Java jar file - All tests passing Co-authored-by: hzhangxyz <[email protected]> * Remove .gitignore. * Update package.json. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: hzhangxyz <[email protected]> Co-authored-by: Hao Zhang <[email protected]>
1 parent d44d946 commit 2aa3c28

File tree

5 files changed

+7311
-1101
lines changed

5 files changed

+7311
-1101
lines changed

bnf/atsds_bnf/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class UnparseVisitor extends DsVisitor {
9393
}
9494

9595
visitUnary(ctx) {
96-
return `(${ctx.getChild(0).getText()} ${this.visit(ctx.term())})`;
96+
return `(${ctx.getChild(1).getText()} ${this.visit(ctx.term())})`;
9797
}
9898

9999
visitBinary(ctx) {

bnf/jest.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
testMatch: ["<rootDir>/tests/test_*.mjs"],
3+
collectCoverage: true,
4+
};

0 commit comments

Comments
 (0)