Title: [197962] trunk
Revision
197962
Author
[email protected]
Date
2016-03-10 15:38:15 -0800 (Thu, 10 Mar 2016)

Log Message

[ES6] Allow RegExp constructor to take pattern from an existing RegExp with new flags
https://bugs.webkit.org/show_bug.cgi?id=155315

Reviewed by Saam Barati.

Source/_javascript_Core:

Changed to comply with section 21.2.3.1, step 5.  Eliminated syntax error.

In the process, change to get the VM at the top of the function.

Updated tests accordingly.

* runtime/RegExpConstructor.cpp:
(JSC::constructRegExp):
* tests/es6.yaml: Changed miscellaneous_RegExp_constructor_can_alter_flags.js to normal.
* tests/mozilla/mozilla-tests.yaml: Disabled ecma_3/RegExp/15.10.4.1-5-n.js as it checks
for the old behavior of throwing a syntax error.

LayoutTests:

New and updated test for change.

* fast/regex/constructor-expected.txt:
* fast/regex/script-tests/constructor.js:
Changed test for new behavior.`

* js/regexp-old-regexp-new-flags-expected.txt: Added.
* js/regexp-old-regexp-new-flags.html: Added.
* js/script-tests/regexp-old-regexp-new-flags.js: Added.
New test.

* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T1-expected.txt: Removed.
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T1.html: Removed.
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T2-expected.txt: Removed.
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T2.html: Removed.
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T1-expected.txt: Removed.
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T1.html: Removed.
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T2-expected.txt: Removed.
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T2.html: Removed.
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A8_T8-expected.txt: Removed.
* sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A8_T8.html: Removed.
Removed obsolete tests.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (197961 => 197962)


--- trunk/LayoutTests/ChangeLog	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/ChangeLog	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,3 +1,33 @@
+2016-03-10  Michael Saboff  <[email protected]>
+
+        [ES6] Allow RegExp constructor to take pattern from an existing RegExp with new flags
+        https://bugs.webkit.org/show_bug.cgi?id=155315
+
+        Reviewed by Saam Barati.
+
+        New and updated test for change.
+
+        * fast/regex/constructor-expected.txt:
+        * fast/regex/script-tests/constructor.js:
+        Changed test for new behavior.`
+
+        * js/regexp-old-regexp-new-flags-expected.txt: Added.
+        * js/regexp-old-regexp-new-flags.html: Added.
+        * js/script-tests/regexp-old-regexp-new-flags.js: Added.
+        New test.
+
+        * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T1-expected.txt: Removed.
+        * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T1.html: Removed.
+        * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T2-expected.txt: Removed.
+        * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T2.html: Removed.
+        * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T1-expected.txt: Removed.
+        * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T1.html: Removed.
+        * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T2-expected.txt: Removed.
+        * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T2.html: Removed.
+        * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A8_T8-expected.txt: Removed.
+        * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A8_T8.html: Removed.
+        Removed obsolete tests.
+
 2016-03-10  Myles C. Maxfield  <[email protected]>
 
         [OS X] Main frame scrollbars should appear on the left on RTL systems

Modified: trunk/LayoutTests/fast/regex/constructor-expected.txt (197961 => 197962)


--- trunk/LayoutTests/fast/regex/constructor-expected.txt	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/fast/regex/constructor-expected.txt	2016-03-10 23:38:15 UTC (rev 197962)
@@ -5,8 +5,8 @@
 
 PASS re === RegExp(re) is true
 PASS re !== new RegExp(re) is true
-PASS re === RegExp(re,'i') threw exception TypeError: Cannot supply flags when constructing one RegExp from another..
-PASS re !== new RegExp(re,'i') threw exception TypeError: Cannot supply flags when constructing one RegExp from another..
+PASS re === RegExp(re,'i') is true
+PASS re !== new RegExp(re,'i') is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/regex/script-tests/constructor.js (197961 => 197962)


--- trunk/LayoutTests/fast/regex/script-tests/constructor.js	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/fast/regex/script-tests/constructor.js	2016-03-10 23:38:15 UTC (rev 197962)
@@ -4,6 +4,6 @@
 
 shouldBeTrue("re === RegExp(re)");
 shouldBeTrue("re !== new RegExp(re)");
-shouldThrow("re === RegExp(re,'i')");
-shouldThrow("re !== new RegExp(re,'i')");
+shouldBeTrue("re === RegExp(re,'i')");
+shouldBeTrue("re !== new RegExp(re,'i')");
 

Added: trunk/LayoutTests/js/regexp-old-regexp-new-flags-expected.txt (0 => 197962)


--- trunk/LayoutTests/js/regexp-old-regexp-new-flags-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/regexp-old-regexp-new-flags-expected.txt	2016-03-10 23:38:15 UTC (rev 197962)
@@ -0,0 +1,21 @@
+Test for ES6 RegExp construct a new RegExp from exiting RegExp pattern and new flags
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS re.test("   Abc   ") is true
+PASS re.flags is ""
+PASS re.test(" ABC  ") is true
+PASS re.flags is "i"
+PASS re.test("   Abc   ") is true
+PASS re.flags is ""
+PASS re.exec("abcABCAbc").toString() is "abc"
+PASS re.exec("abcABCAbc").toString() is "ABC"
+PASS re.exec("abcABCAbc").toString() is "Abc"
+PASS re.flags is "iy"
+PASS re.test("abc") is false
+PASS new RegExp(re, "bad flags") threw exception SyntaxError: Invalid flags supplied to RegExp constructor..
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/js/regexp-old-regexp-new-flags.html (0 => 197962)


--- trunk/LayoutTests/js/regexp-old-regexp-new-flags.html	                        (rev 0)
+++ trunk/LayoutTests/js/regexp-old-regexp-new-flags.html	2016-03-10 23:38:15 UTC (rev 197962)
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/js/script-tests/regexp-old-regexp-new-flags.js (0 => 197962)


--- trunk/LayoutTests/js/script-tests/regexp-old-regexp-new-flags.js	                        (rev 0)
+++ trunk/LayoutTests/js/script-tests/regexp-old-regexp-new-flags.js	2016-03-10 23:38:15 UTC (rev 197962)
@@ -0,0 +1,26 @@
+description(
+'Test for ES6 RegExp construct a new RegExp from exiting RegExp pattern and new flags'
+);
+
+var re = new RegExp("Abc");
+shouldBeTrue('re.test("   Abc   ")');
+shouldBe('re.flags', '""');
+
+re = new RegExp(re, "i");
+shouldBeTrue('re.test(" ABC  ")');
+shouldBe('re.flags', '"i"');
+
+re = new RegExp(re, "");
+shouldBeTrue('re.test("   Abc   ")');
+shouldBe('re.flags', '""');
+
+re = new RegExp(re, "iy");
+shouldBe('re.exec("abcABCAbc").toString()', '"abc"');
+shouldBe('re.exec("abcABCAbc").toString()', '"ABC"');
+shouldBe('re.exec("abcABCAbc").toString()', '"Abc"');
+shouldBe('re.flags', '"iy"');
+
+re = new RegExp(re, "");
+shouldBeFalse('re.test("abc")');
+
+shouldThrow('new RegExp(re, "bad flags")', '"SyntaxError: Invalid flags supplied to RegExp constructor."');

Deleted: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T1-expected.txt (197961 => 197962)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T1-expected.txt	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T1-expected.txt	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,6 +0,0 @@
-S15.10.3.1_A2_T1
-
-PASS 
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T1.html (197961 => 197962)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T1.html	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T1.html	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,103 +0,0 @@
-<html>
-<head>
-<meta charset='utf-8'>
-<style>
-.pass {
-    font-weight: bold;
-    color: green;
-}
-.fail {
-    font-weight: bold;
-    color: red;
-}
-</style>
-
-<script>
-if (window.testRunner)
-    testRunner.dumpAsText();
-
-function SputnikError(message)
-{
-    this.message = message;
-}
-
-SputnikError.prototype.toString = function ()
-{
-    return 'SputnikError: ' + this.message;
-};
-
-var sputnikException;
-
-function testPrint(msg)
-{
-    var span = document.createElement("span");
-    document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace 
-    span.innerHTML = msg + '<br />';
-}
-
-function escapeHTML(text)
-{
-    return text.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;");
-}
-
-function printTestPassed(msg)
-{
-    testPrint('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
-}
-
-function printTestFailed(msg)
-{
-    testPrint('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
-}
-
-function testFailed(msg)
-{
-    throw new SputnikError(msg);
-}
-
-var successfullyParsed = false;
-</script>
-
-</head>
-<body>
-<p>S15.10.3.1_A2_T1</p>
-<div id='console'></div>
-<script>
-try {
-
-/**
-* @name: S15.10.3.1_A2_T1;
-* @section: 15.10.3.1;
-* @assertion: If pattern is an object R whose [[Class]] property is "RegExp" and flags is defined, then 
-* call the RegExp constructor (15.10.4.1), passing it the pattern and flags arguments and return the object constructed by that constructor;
-* @description: Checking if using "1" as flags leads to throwing the correct exception;
-*/
-
-//CHECK#1
-try {
-	testFailed('#1.1: RegExp(new RegExp("\\d"), "1")) throw TypeError. Actual: ' + (RegExp(new RegExp("\d"), "1")));
-} catch (e) {
-	if ((e instanceof TypeError) !== true) {
-		testFailed('#1.2: RegExp(new RegExp("\\d"), "1")) throw TypeError. Actual: ' + (e));
-	}
-}
-
-
-} catch (ex) {
-    sputnikException = ex;
-}
-
-var successfullyParsed = true;
-</script>
-
-<script>
-if (!successfullyParsed)
-    printTestFailed('successfullyParsed is not set');
-else if (sputnikException)
-    printTestFailed(sputnikException);
-else
-    printTestPassed("");
-testPrint('<br /><span class="pass">TEST COMPLETE</span>');
-</script>
-</body>
-</html>

Deleted: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T2-expected.txt (197961 => 197962)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T2-expected.txt	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T2-expected.txt	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,6 +0,0 @@
-S15.10.3.1_A2_T2
-
-PASS 
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T2.html (197961 => 197962)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T2.html	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.3/S15.10.3.1_A2_T2.html	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,105 +0,0 @@
-<html>
-<head>
-<meta charset='utf-8'>
-<style>
-.pass {
-    font-weight: bold;
-    color: green;
-}
-.fail {
-    font-weight: bold;
-    color: red;
-}
-</style>
-
-<script>
-if (window.testRunner)
-    testRunner.dumpAsText();
-
-function SputnikError(message)
-{
-    this.message = message;
-}
-
-SputnikError.prototype.toString = function ()
-{
-    return 'SputnikError: ' + this.message;
-};
-
-var sputnikException;
-
-function testPrint(msg)
-{
-    var span = document.createElement("span");
-    document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace 
-    span.innerHTML = msg + '<br />';
-}
-
-function escapeHTML(text)
-{
-    return text.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;");
-}
-
-function printTestPassed(msg)
-{
-    testPrint('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
-}
-
-function printTestFailed(msg)
-{
-    testPrint('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
-}
-
-function testFailed(msg)
-{
-    throw new SputnikError(msg);
-}
-
-var successfullyParsed = false;
-</script>
-
-</head>
-<body>
-<p>S15.10.3.1_A2_T2</p>
-<div id='console'></div>
-<script>
-try {
-
-/**
-* @name: S15.10.3.1_A2_T2;
-* @section: 15.10.3.1;
-* @assertion: If pattern is an object R whose [[Class]] property is "RegExp" and flags is defined, then 
-* call the RegExp constructor (15.10.4.1), passing it the pattern and flags arguments and return the object constructed by that constructor;
-* @description: Checking if using dafined variable "x = 1" as flags leads to throwing the correct exception;
-*/
-
-var x = 1;
-
-//CHECK#1
-try {
-	testFailed('#1.1: var x = 1; RegExp(/[a-b]?/, x) throw TypeError. Actual: ' + (RegExp(/[a-b]?/, x)));
-} catch (e) {
-	if ((e instanceof TypeError) !== true) {
-		testFailed('#1.2: var x = 1; RegExp(/[a-b]?/, x) throw TypeError. Actual: ' + (e));
-	} 
-}
-
-
-} catch (ex) {
-    sputnikException = ex;
-}
-
-var successfullyParsed = true;
-</script>
-
-<script>
-if (!successfullyParsed)
-    printTestFailed('successfullyParsed is not set');
-else if (sputnikException)
-    printTestFailed(sputnikException);
-else
-    printTestPassed("");
-testPrint('<br /><span class="pass">TEST COMPLETE</span>');
-</script>
-</body>
-</html>

Deleted: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T1-expected.txt (197961 => 197962)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T1-expected.txt	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T1-expected.txt	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,6 +0,0 @@
-S15.10.4.1_A2_T1
-
-PASS 
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T1.html (197961 => 197962)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T1.html	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T1.html	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,102 +0,0 @@
-<html>
-<head>
-<meta charset='utf-8'>
-<style>
-.pass {
-    font-weight: bold;
-    color: green;
-}
-.fail {
-    font-weight: bold;
-    color: red;
-}
-</style>
-
-<script>
-if (window.testRunner)
-    testRunner.dumpAsText();
-
-function SputnikError(message)
-{
-    this.message = message;
-}
-
-SputnikError.prototype.toString = function ()
-{
-    return 'SputnikError: ' + this.message;
-};
-
-var sputnikException;
-
-function testPrint(msg)
-{
-    var span = document.createElement("span");
-    document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace 
-    span.innerHTML = msg + '<br />';
-}
-
-function escapeHTML(text)
-{
-    return text.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;");
-}
-
-function printTestPassed(msg)
-{
-    testPrint('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
-}
-
-function printTestFailed(msg)
-{
-    testPrint('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
-}
-
-function testFailed(msg)
-{
-    throw new SputnikError(msg);
-}
-
-var successfullyParsed = false;
-</script>
-
-</head>
-<body>
-<p>S15.10.4.1_A2_T1</p>
-<div id='console'></div>
-<script>
-try {
-
-/**
-* @name: S15.10.4.1_A2_T1;
-* @section: 15.10.4.1;
-* @assertion: If pattern is an object R whose [[Class]] property is "RegExp" and flags is not undefined, then throw a TypeError exception;
-* @description: Checking if execution of "new RegExp(pattern, "i")", where the pattern is "/\u0042/i", fails;
-*/
-
-//CHECK#1
-try {
-	testFailed('#1.1: new RegExp(/\\u0042/i, "i") throw TypeError. Actual: ' + (new RegExp(/\u0042/i, "i"))); 
-} catch (e) {
-	if ((e instanceof TypeError) !== true) {
-		testFailed('#1.2: new RegExp(/\\u0042/i, "i") throw TypeError. Actual: ' + (e));
-	}
-}
-
-
-} catch (ex) {
-    sputnikException = ex;
-}
-
-var successfullyParsed = true;
-</script>
-
-<script>
-if (!successfullyParsed)
-    printTestFailed('successfullyParsed is not set');
-else if (sputnikException)
-    printTestFailed(sputnikException);
-else
-    printTestPassed("");
-testPrint('<br /><span class="pass">TEST COMPLETE</span>');
-</script>
-</body>
-</html>

Deleted: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T2-expected.txt (197961 => 197962)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T2-expected.txt	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T2-expected.txt	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,6 +0,0 @@
-S15.10.4.1_A2_T2
-
-PASS 
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T2.html (197961 => 197962)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T2.html	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A2_T2.html	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,102 +0,0 @@
-<html>
-<head>
-<meta charset='utf-8'>
-<style>
-.pass {
-    font-weight: bold;
-    color: green;
-}
-.fail {
-    font-weight: bold;
-    color: red;
-}
-</style>
-
-<script>
-if (window.testRunner)
-    testRunner.dumpAsText();
-
-function SputnikError(message)
-{
-    this.message = message;
-}
-
-SputnikError.prototype.toString = function ()
-{
-    return 'SputnikError: ' + this.message;
-};
-
-var sputnikException;
-
-function testPrint(msg)
-{
-    var span = document.createElement("span");
-    document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace 
-    span.innerHTML = msg + '<br />';
-}
-
-function escapeHTML(text)
-{
-    return text.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;");
-}
-
-function printTestPassed(msg)
-{
-    testPrint('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
-}
-
-function printTestFailed(msg)
-{
-    testPrint('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
-}
-
-function testFailed(msg)
-{
-    throw new SputnikError(msg);
-}
-
-var successfullyParsed = false;
-</script>
-
-</head>
-<body>
-<p>S15.10.4.1_A2_T2</p>
-<div id='console'></div>
-<script>
-try {
-
-/**
-* @name: S15.10.4.1_A2_T2;
-* @section: 15.10.4.1;
-* @assertion: If pattern is an object R whose [[Class]] property is "RegExp" and flags is not undefined, then throw a TypeError exception;
-* @description: Checking if execution of "new RegExp(pattern, {})", where the pattern is "/1?1/mig", fails;
-*/
-
-//CHECK#1
-try {
-  testFailed('#1.1: new RegExp(/1?1/mig, {}) throw TypeError. Actual: ' + (new RegExp(/1?1/mig, {}))); 
-} catch (e) {
-  if ((e instanceof TypeError) !== true) {
-    testFailed('#1.2: new RegExp(/1?1/mig, {}) throw TypeError. Actual: ' + (e));
-  }
-}
-
-
-} catch (ex) {
-    sputnikException = ex;
-}
-
-var successfullyParsed = true;
-</script>
-
-<script>
-if (!successfullyParsed)
-    printTestFailed('successfullyParsed is not set');
-else if (sputnikException)
-    printTestFailed(sputnikException);
-else
-    printTestPassed("");
-testPrint('<br /><span class="pass">TEST COMPLETE</span>');
-</script>
-</body>
-</html>

Deleted: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A8_T8-expected.txt (197961 => 197962)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A8_T8-expected.txt	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A8_T8-expected.txt	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,6 +0,0 @@
-S15.10.4.1_A8_T8
-
-PASS 
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A8_T8.html (197961 => 197962)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A8_T8.html	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.4/S15.10.4.1_A8_T8.html	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,102 +0,0 @@
-<html>
-<head>
-<meta charset='utf-8'>
-<style>
-.pass {
-    font-weight: bold;
-    color: green;
-}
-.fail {
-    font-weight: bold;
-    color: red;
-}
-</style>
-
-<script>
-if (window.testRunner)
-    testRunner.dumpAsText();
-
-function SputnikError(message)
-{
-    this.message = message;
-}
-
-SputnikError.prototype.toString = function ()
-{
-    return 'SputnikError: ' + this.message;
-};
-
-var sputnikException;
-
-function testPrint(msg)
-{
-    var span = document.createElement("span");
-    document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace 
-    span.innerHTML = msg + '<br />';
-}
-
-function escapeHTML(text)
-{
-    return text.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;");
-}
-
-function printTestPassed(msg)
-{
-    testPrint('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
-}
-
-function printTestFailed(msg)
-{
-    testPrint('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
-}
-
-function testFailed(msg)
-{
-    throw new SputnikError(msg);
-}
-
-var successfullyParsed = false;
-</script>
-
-</head>
-<body>
-<p>S15.10.4.1_A8_T8</p>
-<div id='console'></div>
-<script>
-try {
-
-/**
-* @name: S15.10.4.1_A8_T8;
-* @section: 15.10.4.1;
-* @assertion: let P be ToString(pattern) and let F be ToString(flags);
-* @description: Pattern is {toString:function(){throw "intostr";} } and flags is "error";
-*/
-
-//CHECK#1
-try {
-	testFailed('#1.1: new RegExp({toString:function(){throw "intostr";}}, "error") throw "intostr". Actual: ' + (new RegExp({toString:function(){throw "intostr";}}, "error")));
-} catch (e) {
-	if (e !== "intostr" ) {
-		testFailed('#1.2: new RegExp({toString:function(){throw "intostr";}}, "error") throw "intostr". Actual: ' + (e));
-	}
-}
-
-
-} catch (ex) {
-    sputnikException = ex;
-}
-
-var successfullyParsed = true;
-</script>
-
-<script>
-if (!successfullyParsed)
-    printTestFailed('successfullyParsed is not set');
-else if (sputnikException)
-    printTestFailed(sputnikException);
-else
-    printTestPassed("");
-testPrint('<br /><span class="pass">TEST COMPLETE</span>');
-</script>
-</body>
-</html>

Modified: trunk/Source/_javascript_Core/ChangeLog (197961 => 197962)


--- trunk/Source/_javascript_Core/ChangeLog	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1,3 +1,22 @@
+2016-03-10  Michael Saboff  <[email protected]>
+
+        [ES6] Allow RegExp constructor to take pattern from an existing RegExp with new flags
+        https://bugs.webkit.org/show_bug.cgi?id=155315
+
+        Reviewed by Saam Barati.
+
+        Changed to comply with section 21.2.3.1, step 5.  Eliminated syntax error.
+
+        In the process, change to get the VM at the top of the function.
+
+        Updated tests accordingly.
+
+        * runtime/RegExpConstructor.cpp:
+        (JSC::constructRegExp):
+        * tests/es6.yaml: Changed miscellaneous_RegExp_constructor_can_alter_flags.js to normal.
+        * tests/mozilla/mozilla-tests.yaml: Disabled ecma_3/RegExp/15.10.4.1-5-n.js as it checks
+        for the old behavior of throwing a syntax error.
+
 2016-03-10  Saam barati  <[email protected]>
 
         [ES6] Make ToPropertyDescriptor spec compliant
@@ -82,6 +101,7 @@
         (noAssign): Deleted.
         (catch): Deleted.
 
+>>>>>>> .r197960
 2016-03-08  Skachkov Oleksandr  <[email protected]>
 
         How we load new.target in arrow functions is broken

Modified: trunk/Source/_javascript_Core/runtime/RegExpConstructor.cpp (197961 => 197962)


--- trunk/Source/_javascript_Core/runtime/RegExpConstructor.cpp	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/Source/_javascript_Core/runtime/RegExpConstructor.cpp	2016-03-10 23:38:15 UTC (rev 197962)
@@ -260,41 +260,47 @@
     JSValue arg0 = args.at(0);
     JSValue arg1 = args.at(1);
 
+    VM& vm = exec->vm();
+    RegExpFlags flags = NoFlags;
+    bool haveFlags = false;
+    if (!arg1.isUndefined()) {
+        flags = regExpFlags(arg1.toString(exec)->value(exec));
+        if (vm.exception())
+            return 0;
+        if (flags == InvalidFlags)
+            return vm.throwException(exec, createSyntaxError(exec, ASCIILiteral("Invalid flags supplied to RegExp constructor.")));
+        haveFlags = true;
+    }
+
     if (arg0.inherits(RegExpObject::info())) {
-        if (!arg1.isUndefined())
-            return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Cannot supply flags when constructing one RegExp from another.")));
         // If called as a function, this just returns the first argument (see 15.10.3.1).
         if (newTarget != jsUndefined()) {
             RegExp* regExp = static_cast<RegExpObject*>(asObject(arg0))->regExp();
             Structure* structure = getRegExpStructure(exec, globalObject, newTarget);
-            if (exec->hadException())
+            if (vm.exception())
                 return nullptr;
 
-            return RegExpObject::create(exec->vm(), structure, regExp);
+            if (haveFlags) {
+                regExp = RegExp::create(vm, regExp->pattern(), flags);
+                if (vm.exception())
+                    return nullptr;
+            }
+
+            return RegExpObject::create(vm, structure, regExp);
         }
         return asObject(arg0);
     }
 
     String pattern = arg0.isUndefined() ? emptyString() : arg0.toString(exec)->value(exec);
-    if (exec->hadException())
+    if (vm.exception())
         return 0;
 
-    RegExpFlags flags = NoFlags;
-    if (!arg1.isUndefined()) {
-        flags = regExpFlags(arg1.toString(exec)->value(exec));
-        if (exec->hadException())
-            return 0;
-        if (flags == InvalidFlags)
-            return exec->vm().throwException(exec, createSyntaxError(exec, ASCIILiteral("Invalid flags supplied to RegExp constructor.")));
-    }
-
-    VM& vm = exec->vm();
     RegExp* regExp = RegExp::create(vm, pattern, flags);
     if (!regExp->isValid())
         return vm.throwException(exec, createSyntaxError(exec, regExp->errorMessage()));
 
     Structure* structure = getRegExpStructure(exec, globalObject, newTarget);
-    if (exec->hadException())
+    if (vm.exception())
         return nullptr;
     return RegExpObject::create(vm, structure, regExp);
 }

Modified: trunk/Source/_javascript_Core/tests/es6.yaml (197961 => 197962)


--- trunk/Source/_javascript_Core/tests/es6.yaml	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/Source/_javascript_Core/tests/es6.yaml	2016-03-10 23:38:15 UTC (rev 197962)
@@ -873,7 +873,7 @@
 - path: es6/miscellaneous_no_assignments_allowed_in_for-in_head.js
   cmd: runES6 :fail
 - path: es6/miscellaneous_RegExp_constructor_can_alter_flags.js
-  cmd: runES6 :fail
+  cmd: runES6 :normal
 - path: es6/new.target_assignment_is_an_early_error.js
   cmd: runES6 :normal
 - path: es6/non-strict_function_semantics_hoisted_block-level_function_declaration.js

Modified: trunk/Source/_javascript_Core/tests/mozilla/mozilla-tests.yaml (197961 => 197962)


--- trunk/Source/_javascript_Core/tests/mozilla/mozilla-tests.yaml	2016-03-10 23:18:55 UTC (rev 197961)
+++ trunk/Source/_javascript_Core/tests/mozilla/mozilla-tests.yaml	2016-03-10 23:38:15 UTC (rev 197962)
@@ -1662,8 +1662,9 @@
   cmd: defaultRunMozillaTest :normal, "../shell.js", "shell.js"
 - path: ecma_3/RegExp/15.10.4.1-4.js
   cmd: defaultRunMozillaTest :normal, "../shell.js", "shell.js"
-- path: ecma_3/RegExp/15.10.4.1-5-n.js
-  cmd: defaultRunMozillaTest :negative, "../shell.js", "shell.js"
+# Test is no longer valid with ES6 changes
+# - path: ecma_3/RegExp/15.10.4.1-5-n.js
+#   cmd: defaultRunMozillaTest :negative, "../shell.js", "shell.js"
 - path: ecma_3/RegExp/15.10.6.2-1.js
   cmd: defaultRunMozillaTest :normal, "../shell.js", "shell.js"
 - path: ecma_3/RegExp/15.10.6.2-2.js
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to