Skip to content

Commit

Permalink
Fix regular expression performance with /g flag (#1157)
Browse files Browse the repository at this point in the history
Co-authored-by: Marko Lahma <marko.lahma@gmail.com>
  • Loading branch information
sebastienros and lahma committed May 4, 2022
1 parent 59a9cd2 commit 408df55
Show file tree
Hide file tree
Showing 4 changed files with 1,698 additions and 14 deletions.
23 changes: 23 additions & 0 deletions Jint.Tests/Runtime/EngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,29 @@ public void ShouldExecuteHandlebars()
");
}

[Fact]
public void ShouldExecutePrism()
{
var content = GetEmbeddedFile("prism.js");

RunTest(content);

RunTest(@"
var input = 'using System; public class Person { public int Name { get; set; } }';
var lang = 'csharp';
var highlighted = Prism.highlight(input, Prism.languages.csharp, lang);
assert(highlighted.includes('System'));
assert(highlighted.includes('Person'));
assert(highlighted.includes('Name'));
log(highlighted);
");

_engine.SetValue("input", File.ReadAllText("../../../../Jint/Engine.cs"));
RunTest("Prism.highlight(input, Prism.languages.csharp, lang);");
}

[Fact]
public void ShouldExecuteDromaeoBase64()
{
Expand Down

0 comments on commit 408df55

Please sign in to comment.