Title: [202770] trunk
Revision
202770
Author
[email protected]
Date
2016-07-01 19:20:39 -0700 (Fri, 01 Jul 2016)

Log Message

[JSC] RegExp.compile is not returning the regexp when it succeed
https://bugs.webkit.org/show_bug.cgi?id=159381

Patch by Benjamin Poulain <[email protected]> on 2016-07-01
Reviewed by Mark Lam.

Source/_javascript_Core:

Spec:
-https://tc39.github.io/ecma262/#sec-regexp.prototype.compile
-https://tc39.github.io/ecma262/#sec-regexpinitialize

* runtime/RegExpPrototype.cpp:
(JSC::regExpProtoFuncCompile):

LayoutTests:

* js/regexp-compile-expected.txt:
* js/script-tests/regexp-compile.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202769 => 202770)


--- trunk/LayoutTests/ChangeLog	2016-07-02 01:15:44 UTC (rev 202769)
+++ trunk/LayoutTests/ChangeLog	2016-07-02 02:20:39 UTC (rev 202770)
@@ -1,3 +1,13 @@
+2016-07-01  Benjamin Poulain  <[email protected]>
+
+        [JSC] RegExp.compile is not returning the regexp when it succeed
+        https://bugs.webkit.org/show_bug.cgi?id=159381
+
+        Reviewed by Mark Lam.
+
+        * js/regexp-compile-expected.txt:
+        * js/script-tests/regexp-compile.js:
+
 2016-07-01  Zalan Bujtas  <[email protected]>
 
         prepareForDestruction() always needs to be called before destroying the Document object.

Modified: trunk/LayoutTests/js/regexp-compile-expected.txt (202769 => 202770)


--- trunk/LayoutTests/js/regexp-compile-expected.txt	2016-07-02 01:15:44 UTC (rev 202769)
+++ trunk/LayoutTests/js/regexp-compile-expected.txt	2016-07-02 02:20:39 UTC (rev 202770)
@@ -23,6 +23,9 @@
 PASS re.toString() is '/z/'
 PASS re.lastIndex is 0
 PASS re.lastIndex is 1
+PASS regexpWithUndefinedCompiledToValid = new RegExp(undefined), regexpWithUndefinedCompiledToValid.compile('abc') is regexpWithUndefinedCompiledToValid
+PASS regexpValidPatternCompiledToValid = new RegExp('zyx'), regexpValidPatternCompiledToValid.compile('abc') is regexpValidPatternCompiledToValid
+PASS regexpWithValidCompiledToUndefined = new RegExp('abc'), regexpWithValidCompiledToUndefined.compile(undefined) is regexpWithValidCompiledToUndefined
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/js/script-tests/regexp-compile.js (202769 => 202770)


--- trunk/LayoutTests/js/script-tests/regexp-compile.js	2016-07-02 01:15:44 UTC (rev 202769)
+++ trunk/LayoutTests/js/script-tests/regexp-compile.js	2016-07-02 02:20:39 UTC (rev 202770)
@@ -49,3 +49,8 @@
 shouldBe("re.lastIndex", "0");
 re.exec("aaa");
 shouldBe("re.lastIndex", "1");
+
+// Compile returns the regexp itself.
+shouldBe("regexpWithUndefinedCompiledToValid = new RegExp(undefined), regexpWithUndefinedCompiledToValid.compile('abc')", "regexpWithUndefinedCompiledToValid");
+shouldBe("regexpValidPatternCompiledToValid = new RegExp('zyx'), regexpValidPatternCompiledToValid.compile('abc')", "regexpValidPatternCompiledToValid");
+shouldBe("regexpWithValidCompiledToUndefined = new RegExp('abc'), regexpWithValidCompiledToUndefined.compile(undefined)", "regexpWithValidCompiledToUndefined");

Modified: trunk/Source/_javascript_Core/ChangeLog (202769 => 202770)


--- trunk/Source/_javascript_Core/ChangeLog	2016-07-02 01:15:44 UTC (rev 202769)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-07-02 02:20:39 UTC (rev 202770)
@@ -1,3 +1,17 @@
+2016-07-01  Benjamin Poulain  <[email protected]>
+
+        [JSC] RegExp.compile is not returning the regexp when it succeed
+        https://bugs.webkit.org/show_bug.cgi?id=159381
+
+        Reviewed by Mark Lam.
+
+        Spec:
+        -https://tc39.github.io/ecma262/#sec-regexp.prototype.compile
+        -https://tc39.github.io/ecma262/#sec-regexpinitialize
+
+        * runtime/RegExpPrototype.cpp:
+        (JSC::regExpProtoFuncCompile):
+
 2016-07-01  Saam Barati  <[email protected]>
 
         fix "ASSERTION FAILED: currentOffset() >= currentLineStartOffset()"

Modified: trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp (202769 => 202770)


--- trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp	2016-07-02 01:15:44 UTC (rev 202769)
+++ trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp	2016-07-02 02:20:39 UTC (rev 202770)
@@ -166,7 +166,7 @@
 
     asRegExpObject(thisValue)->setRegExp(exec->vm(), regExp);
     asRegExpObject(thisValue)->setLastIndex(exec, 0);
-    return JSValue::encode(jsUndefined());
+    return JSValue::encode(thisValue);
 }
 
 typedef std::array<char, 5 + 1> FlagsString; // 5 different flags and a null character terminator.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to