Skip to content

Commit

Permalink
feat(coverage): add ContentEq test for regular_expression (#6411)
Browse files Browse the repository at this point in the history
closes #6409

Marking as good first issue if anyone wants to pick this up and fix the failing test.
  • Loading branch information
Boshen committed Oct 10, 2024
1 parent 2d3ae63 commit 95892ec
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
16 changes: 15 additions & 1 deletion tasks/coverage/snapshots/parser_test262.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@ commit: d62fa93c

parser_test262 Summary:
AST Parsed : 43776/43776 (100.00%)
Positive Passed: 43776/43776 (100.00%)
Positive Passed: 43772/43776 (99.99%)
Negative Passed: 4237/4239 (99.95%)
Expect Syntax Error: tasks/coverage/test262/test/language/import/import-attributes/json-invalid.js
Expect Syntax Error: tasks/coverage/test262/test/language/import/import-attributes/json-named-bindings.js
Expect to Parse: tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T1.js

× Regular Expression content mismatch for `/[^]a/m`: `[]a` == `[]a`
Expect to Parse: tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T2.js

× Regular Expression content mismatch for `/a[^]/`: `a[]` == `a[]`
Expect to Parse: tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T8.js

× Regular Expression content mismatch for `/[^]/`: `[]` == `[]`
Expect to Parse: tasks/coverage/test262/test/built-ins/String/prototype/split/separator-regexp.js

× Regular Expression content mismatch for `/[^]/`: `[]` == `[]`

× Regular Expression content mismatch for `/\cY/`: `\c` == `\c`

× '0'-prefixed octal literals and octal escape sequences are deprecated
╭─[test262/test/annexB/language/expressions/template-literal/legacy-octal-escape-sequence-strict.js:19:4]
Expand Down
15 changes: 14 additions & 1 deletion tasks/coverage/snapshots/semantic_test262.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ commit: d62fa93c

semantic_test262 Summary:
AST Parsed : 43776/43776 (100.00%)
Positive Passed: 43576/43776 (99.54%)
Positive Passed: 43572/43776 (99.53%)
tasks/coverage/test262/test/annexB/language/function-code/if-decl-else-decl-a-func-block-scoping.js
semantic error: Symbol scope ID mismatch for "f":
after transform: SymbolId(3): ScopeId(4294967294)
Expand Down Expand Up @@ -1119,6 +1119,19 @@ semantic error: Symbol scope ID mismatch for "f":
after transform: SymbolId(0): ScopeId(4294967294)
rebuilt : SymbolId(0): ScopeId(4294967294)

tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T1.js
semantic error: Regular Expression content mismatch for `/[^]a/m`: `[]a` == `[]a`

tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T2.js
semantic error: Regular Expression content mismatch for `/a[^]/`: `a[]` == `a[]`

tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T8.js
semantic error: Regular Expression content mismatch for `/[^]/`: `[]` == `[]`

tasks/coverage/test262/test/built-ins/String/prototype/split/separator-regexp.js
semantic error: Regular Expression content mismatch for `/[^]/`: `[]` == `[]`
Regular Expression content mismatch for `/\cY/`: `\c` == `\c`

tasks/coverage/test262/test/language/module-code/eval-rqstd-once.js
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["dflt1", "dflt2", "dflt3", "global", "ns1", "ns3"]
Expand Down
32 changes: 17 additions & 15 deletions tasks/coverage/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use oxc::{
parser::{ParseOptions, ParserReturn},
regular_expression::{Parser, ParserOptions},
semantic::{Semantic, SemanticBuilderReturn},
span::{SourceType, Span},
span::{cmp::ContentEq, SourceType, Span},
transformer::{TransformOptions, TransformerReturn},
CompilerInterface,
};
Expand Down Expand Up @@ -163,27 +163,29 @@ impl Driver {
};
let printed1 = pattern.to_string();
let flags = literal.regex.flags.to_string();
let printed2 = match Parser::new(
&allocator,
&printed1,
ParserOptions::default().with_flags(&flags),
)
.parse()
{
Ok(pattern) => pattern.to_string(),
let options = ParserOptions::default().with_flags(&flags);
match Parser::new(&allocator, &printed1, options).parse() {
Ok(pattern2) => {
let printed2 = pattern2.to_string();
if !pattern2.content_eq(pattern) {
self.errors.push(OxcDiagnostic::error(format!(
"Regular Expression content mismatch for `{}`: `{pattern}` == `{pattern2}`",
literal.span.source_text(semantic.source_text())
)));
}
if printed1 != printed2 {
self.errors.push(OxcDiagnostic::error(format!(
"Regular Expression mismatch: {printed1} {printed2}"
)));
}
}
Err(error) => {
self.errors.push(OxcDiagnostic::error(format!(
"Failed to re-parse `{}`, printed as `/{printed1}/{flags}`, {error}",
literal.span.source_text(semantic.source_text()),
)));
continue;
}
};
if printed1 != printed2 {
self.errors.push(OxcDiagnostic::error(format!(
"Regular Expression mismatch: {printed1} {printed2}"
)));
}
}
}
}

0 comments on commit 95892ec

Please sign in to comment.