test: add UglifyJS compatibility harness#321
Conversation
There was a problem hiding this comment.
💡 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".
| 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) |
There was a problem hiding this comment.
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 👍 / 👎.
| 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)); |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
@@replaceValidation
cargo fmt --check./scripts/lint.sh(clippy)cargo build --releasecargo 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)176116b, while the new RegExp regression fails there and passes on this branch (documented on Node-compat library: uglify-js #296)Closes #296