Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

Adds JavaScript test suite for BNF package mirroring the existing Python tests in bnf/tests/test_parse_unparse.py.

Changes

  • Test suite: Created bnf/tests/test_parse_unparse.mjs with 18 test cases covering parse/unparse operations and roundtrip conversions
  • Jest config: Added jest.config.mjs with test pattern matching and coverage collection
  • Dependencies: Added jest, cross-env, and @types/jest to package.json devDependencies
  • ANTLR generation: Updated parser generation scripts to use ANTLR 4.13.2 jar (older npm packages use incompatible versions 4.5/4.8)
  • Bug fix: Corrected UnparseVisitor.visitUnary() to use ctx.getChild(1) instead of ctx.getChild(0) for operator extraction

Test Coverage

All 18 tests pass:

  • Parse: simple rules, axioms, functions, subscripts, operators, multiple rules, complex expressions
  • Unparse: same categories
  • Roundtrip: bidirectional conversion validation
test("parse_simple_rule", () => {
    const dsp_input = "a, b -> c";
    const ds_output = parse(dsp_input);
    expect(ds_output).toBe("a\nb\n----\nc");
});

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
    • Triggering command: /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

This section details on the original issue you should resolve

<issue_title>需要模仿bnf/tests中的python 测试写一下 js的测试, jest的配置可以参考repo root的那个package.json</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- 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]>
Copilot AI changed the title [WIP] Add JavaScript tests using Jest configuration Add Jest tests for BNF parse/unparse functions Dec 9, 2025
Copilot AI requested a review from hzhangxyz December 9, 2025 03:42
@hzhangxyz hzhangxyz force-pushed the copilot/add-js-tests-using-jest branch from 7f674d1 to d7a7fd3 Compare December 9, 2025 03:46
@hzhangxyz hzhangxyz marked this pull request as ready for review December 9, 2025 03:47
Copilot AI review requested due to automatic review settings December 9, 2025 03:47
@hzhangxyz hzhangxyz merged commit 2aa3c28 into main Dec 9, 2025
55 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

需要模仿bnf/tests中的python 测试写一下 js的测试, jest的配置可以参考repo root的那个package.json

2 participants