Add Jest tests for BNF parse/unparse functions - #78
Merged
Conversation
- 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 <11623447+hzhangxyz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add JavaScript tests using Jest configuration
Add Jest tests for BNF parse/unparse functions
Dec 9, 2025
hzhangxyz
force-pushed
the
copilot/add-js-tests-using-jest
branch
from
December 9, 2025 03:46
7f674d1 to
d7a7fd3
Compare
hzhangxyz
marked this pull request as ready for review
December 9, 2025 03:47
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive JavaScript test suite for the BNF parse/unparse functions, mirroring the existing Python tests. The implementation includes a bug fix in the UnparseVisitor.visitUnary() method that was discovered during test development. The Jest configuration follows the same pattern as the root package.json, ensuring consistency across the codebase.
- Adds 18 Jest test cases covering parse, unparse, and roundtrip operations for various BNF grammar constructs
- Configures Jest with test pattern matching and coverage collection
- Fixes a bug in
UnparseVisitor.visitUnary()where the operator was being extracted from the wrong child index
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| bnf/tests/test_parse_unparse.mjs | New JavaScript test suite with 18 tests mirroring Python tests, covering parsing, unparsing, and roundtrip conversions for all grammar constructs |
| bnf/jest.config.mjs | Jest configuration for test discovery and coverage collection, consistent with root config pattern |
| bnf/package.json | Added test script, Jest dependencies (@types/jest, jest, cross-env), and "all" script to run build+test |
| bnf/atsds_bnf/index.mjs | Fixed UnparseVisitor.visitUnary() to use getChild(1) instead of getChild(0) to correctly extract the operator from the Ds grammar AST |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds JavaScript test suite for BNF package mirroring the existing Python tests in
bnf/tests/test_parse_unparse.py.Changes
bnf/tests/test_parse_unparse.mjswith 18 test cases covering parse/unparse operations and roundtrip conversionsjest.config.mjswith test pattern matching and coverage collectionjest,cross-env, and@types/jesttopackage.jsondevDependenciesUnparseVisitor.visitUnary()to usectx.getChild(1)instead ofctx.getChild(0)for operator extractionTest Coverage
All 18 tests pass:
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
www.antlr.org/usr/bin/wget wget -q REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.