Skip to content

Commit

Permalink
feat(coverage): enable regexp in test262
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Jul 13, 2024
1 parent 4940034 commit b83cf40
Show file tree
Hide file tree
Showing 14 changed files with 8,311 additions and 8,328 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ oxc_traverse = { version = "0.20.0", path = "crates/oxc_traverse" }
oxc_module_lexer = { version = "0.20.0", path = "crates/oxc_module_lexer" }
oxc_cfg = { version = "0.20.0", path = "crates/oxc_cfg" }
oxc_isolated_declarations = { version = "0.20.0", path = "crates/oxc_isolated_declarations" }
oxc_regexp_parser = { version = "0.0.0", path = "crates/oxc_regexp_parser" }
oxc_transform_napi = { version = "0.20.0", path = "napi/transform" }

# publish = false
Expand Down
11 changes: 6 additions & 5 deletions crates/oxc_parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ workspace = true
doctest = false

[dependencies]
oxc_allocator = { workspace = true }
oxc_span = { workspace = true }
oxc_ast = { workspace = true }
oxc_syntax = { workspace = true }
oxc_diagnostics = { workspace = true }
oxc_allocator = { workspace = true }
oxc_span = { workspace = true }
oxc_ast = { workspace = true }
oxc_syntax = { workspace = true }
oxc_diagnostics = { workspace = true }
oxc_regexp_parser = { workspace = true }

assert-unchecked = { workspace = true }
bitflags = { workspace = true }
Expand Down
11 changes: 7 additions & 4 deletions crates/oxc_parser/src/js/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'a> ParserImpl<'a> {
}
Kind::LParen => self.parse_parenthesized_expression(span),
Kind::Slash | Kind::SlashEq => {
let literal = self.parse_literal_regexp();
let literal = self.parse_literal_regexp()?;
Ok(self.ast.expression_from_reg_exp_literal(literal))
}
// JSXElement, JSXFragment
Expand Down Expand Up @@ -337,20 +337,23 @@ impl<'a> ParserImpl<'a> {
Ok(self.ast.big_int_literal(self.end_span(span), raw, base))
}

pub(crate) fn parse_literal_regexp(&mut self) -> RegExpLiteral<'a> {
pub(crate) fn parse_literal_regexp(&mut self) -> Result<RegExpLiteral<'a>> {
use oxc_regexp_parser::{ParserOptions, PatternParser};
let span = self.start_span();

// split out pattern
let (pattern_end, flags) = self.read_regex();
let pattern_start = self.cur_token().start + 1; // +1 to exclude `/`
let pattern = &self.source_text[pattern_start as usize..pattern_end as usize];
PatternParser::new(&self.ast.allocator, self.source_text, ParserOptions::default())
.parse()?;

self.bump_any();
self.ast.reg_exp_literal(
Ok(self.ast.reg_exp_literal(
self.end_span(span),
EmptyObject,
RegExp { pattern: self.ast.atom(pattern), flags },
)
))
}

pub(crate) fn parse_literal_string(&mut self) -> Result<StringLiteral<'a>> {
Expand Down
4,846 changes: 1 addition & 4,845 deletions tasks/coverage/codegen_sourcemap.snap

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tasks/coverage/codegen_test262.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
commit: a1587416

codegen_test262 Summary:
AST Parsed : 46406/46406 (100.00%)
Positive Passed: 46406/46406 (100.00%)
AST Parsed : 46466/46466 (100.00%)
Positive Passed: 46466/46466 (100.00%)
4 changes: 2 additions & 2 deletions tasks/coverage/minifier_test262.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
commit: a1587416

minifier_test262 Summary:
AST Parsed : 46406/46406 (100.00%)
Positive Passed: 46401/46406 (99.99%)
AST Parsed : 46466/46466 (100.00%)
Positive Passed: 46461/46466 (99.99%)
Expect to Parse: "language/expressions/new/S11.2.2_A3_T1.js"
Expect to Parse: "language/expressions/new/S11.2.2_A3_T4.js"
Expect to Parse: "language/types/reference/put-value-prop-base-primitive.js"
Expand Down
115 changes: 77 additions & 38 deletions tasks/coverage/parser_babel.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
commit: 12619ffe

parser_babel Summary:
AST Parsed : 2093/2101 (99.62%)
Positive Passed: 2083/2101 (99.14%)
AST Parsed : 2069/2101 (98.48%)
Positive Passed: 2059/2101 (98.00%)
Negative Passed: 1380/1501 (91.94%)
Expect Syntax Error: "annex-b/disabled/1.1-html-comments-close/input.js"
Expect Syntax Error: "annex-b/disabled/3.1-sloppy-labeled-functions/input.js"
Expand Down Expand Up @@ -125,6 +125,21 @@ Expect Syntax Error: "typescript/types/read-only-4/input.ts"
Expect Syntax Error: "typescript/types/tuple-labeled-invalid-optional/input.ts"
Expect Syntax Error: "typescript/types/tuple-optional-invalid/input.ts"
Expect Syntax Error: "typescript/types/tuple-required-after-labeled-optional/input.ts"
Expect to Parse: "core/categorized/04-regex/input.js"

× Incomplete quantifier
Expect to Parse: "core/categorized/05-regex/input.js"

× Incomplete quantifier
Expect to Parse: "core/categorized/07-regex/input.js"

× Incomplete quantifier
Expect to Parse: "core/categorized/labeled-block-statement-regex/input.js"

× Incomplete quantifier
Expect to Parse: "core/categorized/regex-after-block/input.js"

× Incomplete quantifier
Expect to Parse: "core/opts/allowNewTargetOutsideFunction-true/input.js"

× Unexpected new.target expression
Expand All @@ -142,6 +157,63 @@ Expect to Parse: "core/opts/allowNewTargetOutsideFunction-true/input.js"
· ──────────
╰────
help: new.target is only allowed in constructors and functions invoked using thew `new` operator
Expect to Parse: "core/regression/2591/input.js"

× Incomplete quantifier
Expect to Parse: "core/uncategorised/328/input.js"

× Incomplete quantifier
Expect to Parse: "core/uncategorised/330/input.js"

× Incomplete quantifier
Expect to Parse: "core/uncategorised/331/input.js"

× Nothing to repeat
Expect to Parse: "core/uncategorised/332/input.js"

× Incomplete quantifier
Expect to Parse: "core/uncategorised/336/input.js"

× Incomplete quantifier
Expect to Parse: "core/uncategorised/337/input.js"

× Incomplete quantifier
Expect to Parse: "core/uncategorised/340/input.js"

× Incomplete quantifier
Expect to Parse: "core/uncategorised/341/input.js"

× Incomplete quantifier
Expect to Parse: "core/uncategorised/541/input.js"

× Incomplete quantifier
Expect to Parse: "es2015/for-of/brackets-const/input.js"

× Incomplete quantifier
Expect to Parse: "es2015/for-of/brackets-let/input.js"

× Incomplete quantifier
Expect to Parse: "es2015/for-of/brackets-var/input.js"

× Incomplete quantifier
Expect to Parse: "es2015/generators/yield-regex/input.js"

× Incomplete quantifier
Expect to Parse: "es2015/uncategorised/317/input.js"

× Incomplete quantifier
Expect to Parse: "es2015/yield/asi2/input.js"

× Incomplete quantifier
Expect to Parse: "es2015/yield/regexp/input.js"

× Incomplete quantifier
Expect to Parse: "es2017/async-functions/context-regex-after-statement/input.js"

× Incomplete quantifier
Expect to Parse: "esprima/expression-primary-literal-regular-expression/u-flag-valid-range/input.js"

× Invalid unicode escape
Expect to Parse: "typescript/arrow-function/generic-tsx-babel-7/input.ts"

× Expected `<` but found `EOF`
Expand Down Expand Up @@ -1236,18 +1308,7 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts"
· ─────
╰────

× Invalid Unicode escape sequence
╭─[core/uncategorised/366/input.js:1:17]
1 │ var x = /[a-z]/\ux
· ─
╰────

× Expected a semicolon or an implicit semicolon after a statement, but found none
╭─[core/uncategorised/366/input.js:1:16]
1 │ var x = /[a-z]/\ux
· ▲
╰────
help: Try insert a semicolon here
× Invalid unicode escape

× Cannot assign to this expression
╭─[core/uncategorised/367/input.js:1:1]
Expand Down Expand Up @@ -8234,31 +8295,9 @@ Expect to Parse: "typescript/types/const-type-parameters-babel-7/input.ts"
2 │ /
╰────

× Invalid Unicode escape sequence
╭─[esprima/invalid-syntax/migrated_0041/input.js:1:17]
1 │ var x = /[a-z]/\ux
· ─
╰────

× Expected a semicolon or an implicit semicolon after a statement, but found none
╭─[esprima/invalid-syntax/migrated_0041/input.js:1:16]
1 │ var x = /[a-z]/\ux
· ▲
╰────
help: Try insert a semicolon here

× Invalid Unicode escape sequence
╭─[esprima/invalid-syntax/migrated_0042/input.js:1:19]
1 │ var x = /[a-z\n]/\ux
· ─
╰────
× Invalid unicode escape

× Expected a semicolon or an implicit semicolon after a statement, but found none
╭─[esprima/invalid-syntax/migrated_0042/input.js:1:18]
1 │ var x = /[a-z\n]/\ux
· ▲
╰────
help: Try insert a semicolon here
× Invalid unicode escape

× Invalid Unicode escape sequence
╭─[esprima/invalid-syntax/migrated_0043/input.js:1:17]
Expand Down
Loading

0 comments on commit b83cf40

Please sign in to comment.