diff --git a/Directory.Packages.props b/Directory.Packages.props index 1078ab14ea..174afd89a4 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,8 +4,8 @@ true - - + + @@ -35,4 +35,4 @@ - \ No newline at end of file + diff --git a/Jint.Tests.Test262/Test262Harness.settings.json b/Jint.Tests.Test262/Test262Harness.settings.json index 470e449bea..83e3cf5902 100644 --- a/Jint.Tests.Test262/Test262Harness.settings.json +++ b/Jint.Tests.Test262/Test262Harness.settings.json @@ -6,7 +6,6 @@ "Parallel": true, "ExcludedFeatures": [ "import-defer", - "regexp-modifiers", "regexp-unicode-property-escapes", "regexp-v-flag", "source-phase-imports", @@ -52,6 +51,14 @@ "built-ins/RegExp/nullable-quantifier.js", "built-ins/RegExp/lookahead-quantifier-match-groups.js", + // .NET regex engine: scoped regexp modifiers don't fully match ECMAScript boundary and multiline semantics + "built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-b.js", + "built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-w.js", + "built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-b.js", + "built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-w.js", + "built-ins/RegExp/regexp-modifiers/add-multiline.js", + "built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-dotAll-flag.js", + // .NET regex engine: complex quantifier capture group tracking differs "built-ins/RegExp/S15.10.2.5_A1_T4.js", "built-ins/RegExp/prototype/exec/S15.10.6.2_A1_T6.js", @@ -288,4 +295,4 @@ // Per B.1.2, non-unicode RegExp should accept some malformed named group syntax "annexB/built-ins/RegExp/named-groups/non-unicode-malformed.js" ] -} \ No newline at end of file +} diff --git a/Jint.Tests/Runtime/RegExpTests.cs b/Jint.Tests/Runtime/RegExpTests.cs index 6508123533..d286e90f1e 100644 --- a/Jint.Tests/Runtime/RegExpTests.cs +++ b/Jint.Tests/Runtime/RegExpTests.cs @@ -132,6 +132,23 @@ public void ShouldAllowProblematicGroupNames() Assert.Equal("a-b-c", result); } + [Fact] + public void ShouldSupportRegExpModifiersInLiteralsAndConstructor() + { + var engine = new Engine(); + + var prepared = Engine.PrepareScript(""" + const literal = /(?m-i:^a$)/i; + `${literal.test('A\n')},${literal.test('a\n')}`; + """); + + engine.Evaluate(prepared).AsString().Should().Be("false,true"); + engine.Evaluate(""" + const regex = new RegExp("(?m-i:^a$)", "i"); + `${regex.test('A\n')},${regex.test('a\n')}`; + """).AsString().Should().Be("false,true"); + } + [Fact] public void Issue506() { diff --git a/Jint/Engine.Defaults.cs b/Jint/Engine.Defaults.cs index 95a942dfbe..1517bde464 100644 --- a/Jint/Engine.Defaults.cs +++ b/Jint/Engine.Defaults.cs @@ -9,6 +9,7 @@ public partial class Engine EcmaVersion = EcmaVersion.ES2023, ExperimentalESFeatures = ExperimentalESFeatures.ImportAttributes | ExperimentalESFeatures.RegExpDuplicateNamedCapturingGroups + | ExperimentalESFeatures.RegExpModifiers | ExperimentalESFeatures.ExplicitResourceManagement | ExperimentalESFeatures.Decorators, Tolerant = false,