mirror of
https://github.com/tc39/test262.git
synced 2025-05-05 07:20:27 +02:00
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
38 lines
937 B
JavaScript
38 lines
937 B
JavaScript
// Regression test for https://bugs.webkit.org/show_bug.cgi?id=174044. This test should not throw or crash.
|
|
|
|
function test1()
|
|
{
|
|
let expected = ["\na", "\na", "\na", "\n"];
|
|
|
|
let str = "\na\na\na\n";
|
|
let re = new RegExp(".*\\s.*", "g");
|
|
|
|
let match = str.match(re);
|
|
|
|
if (match.length != expected.length)
|
|
throw "Expected match.length of " + expected.length + ", got " + match.length;
|
|
|
|
for (let i = 0; i < expected.length; i++) {
|
|
if (match[i] != expected[i])
|
|
throw "Expected match[" + i + "] to be \"" + expected[i] + "\", got \"" + match[i] + "\"";
|
|
}
|
|
}
|
|
|
|
function test2()
|
|
{
|
|
let result = undefined;
|
|
|
|
let re = new RegExp(".*\\s.*", "g");
|
|
let str = "\na\n";
|
|
result = str.replace(re,'x');
|
|
|
|
if (result != "xx")
|
|
throw "Expected result of \"xx\", got \"" + result + "\"";
|
|
}
|
|
|
|
for (let i = 0; i < 5000; i++)
|
|
test1();
|
|
|
|
for (let i = 0; i < 5000; i++)
|
|
test2();
|