Skip to content

test: add UglifyJS compatibility harness#321

Open
pmatos wants to merge 1 commit into
mainfrom
sym/jsse/296-node-compat-library-uglify-js
Open

test: add UglifyJS compatibility harness#321
pmatos wants to merge 1 commit into
mainfrom
sym/jsse/296-node-compat-library-uglify-js

Conversation

@pmatos

@pmatos pmatos commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • pin UglifyJS v3.19.3 and generate a deterministic filesystem-free entry for all 4,233 compress DSL cases
  • cross-check the full parse/compress/transform/mangle/codegen/reparse corpus against Node with an exact expected count
  • fix non-Unicode RegExp ranges spanning surrogate code units and preserve UTF-16 strings through functional @@replace
  • document the harness and add a focused surrogate-range regression

Validation

  • cargo fmt --check
  • ./scripts/lint.sh (clippy)
  • cargo build --release
  • cargo test --release (295 passed)
  • uv run python scripts/run-custom-tests.py (7 passed)
  • uv run python scripts/run-test262.py test262/test/built-ins/RegExp/prototype/Symbol.replace/ (138/138)
  • uv run python scripts/run-test262.py test262/test/language/literals/regexp/ (476/476)
  • ./scripts/run-library-tests.sh uglify-js (4,233/4,233 on jsse and Node)
  • ./scripts/run-library-tests.sh acorn (13,507/13,507 on jsse and Node)
  • full test262: 99,546/99,568, 323 new passes, with 22 baseline-reported Intl/Temporal failures; representative failures reproduce on the exact unmodified base commit 176116b, while the new RegExp regression fails there and passes on this branch (documented on Node-compat library: uglify-js #296)

Closes #296

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 969a242de6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2132 to +2137
if in_char_class
&& !unicode
&& let Some((lo, lo_end)) = parse_simple_class_atom(&chars, i)
&& lo_end < len
&& chars[lo_end] == '-'
&& let Some((hi, hi_end)) = parse_simple_class_atom(&chars, lo_end + 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude the negation marker from range detection

When a negated class starts with a literal hyphen and the following atom reaches the surrogate interval, this parser treats the leading ^ as the lower range endpoint. For example, [^-\uD800] is translated as the positive range ^U+D800: jsse consequently reports that it matches U+D800 but not A, while ECMAScript requires the opposite. Track the start of the class and skip the negation marker before applying this range expansion.

Useful? React with 👍 / 👎.

Comment on lines +8093 to +8100
let cap_str = match interp.to_js_string(&cap_n) {
Ok(s) => s,
Err(e) => {
interp.gc_temp_roots.truncate(gc_root_start);
return Completion::Throw(e);
}
};
captures.push(JsValue::String(JsString::from_str(&cap_str)));
captures.push(JsValue::String(cap_str));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve surrogate captures in template substitution

For the newly supported surrogate ranges, non-functional replacements still corrupt captured lone surrogates. For example, String.fromCharCode(0xD801).replace(/([\uD800-\uDFFF])/g, "$1") now returns U+FFFD; the capture is preserved here as a JsString, but get_substitution later converts $1 through the lossy to_string_value path. Carry the UTF-16-preserving representation through numbered and named template substitutions as well as functional replacement.

Useful? React with 👍 / 👎.

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.

Node-compat library: uglify-js

1 participant