Improve RegExp.prototype.compile (#2971)
This patch fixes the return value of the routine also fixes several incorrect regression-tests due to the previously incorrect [[RegExpMatcher]] internal slot check. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
+6
-2
@@ -12,5 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var result = RegExp.prototype.compile([]);
|
||||
assert(result === undefined);
|
||||
try {
|
||||
RegExp.prototype.compile([]);
|
||||
assert(false);
|
||||
} catch (e) {
|
||||
assert(e instanceof TypeError);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ try {
|
||||
}
|
||||
|
||||
re2.lastIndex = 2;
|
||||
re2.compile("asd", "im");
|
||||
assert (re2.compile("asd", "im") === re2);
|
||||
|
||||
assert (re2 == "/asd/im");
|
||||
assert (re2.global === false);
|
||||
@@ -103,7 +103,7 @@ assert (re2.multiline === true);
|
||||
assert (re2.source === "asd");
|
||||
assert (re2.lastIndex === 0);
|
||||
|
||||
re2.compile(re1);
|
||||
assert (re2.compile(re1) === re2);
|
||||
assert (re2.toString() === re1.toString());
|
||||
assert (re2.global === re1.global);
|
||||
assert (re2.ignoreCase === re1.ignoreCase);
|
||||
|
||||
@@ -12,5 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
new (new (new RegExp().constructor)().constructor)().constructor.prototype.toString()
|
||||
RegExp().constructor().constructor.prototype.compile(RegExp.prototype)
|
||||
new (new (new RegExp().constructor)().constructor)().constructor.prototype.toString();
|
||||
|
||||
try {
|
||||
RegExp().constructor().constructor.prototype.compile(RegExp.prototype);
|
||||
assert(false);
|
||||
} catch (e) {
|
||||
assert(e instanceof TypeError);
|
||||
}
|
||||
|
||||
@@ -14,5 +14,12 @@
|
||||
|
||||
((new RegExp("}").constructor)("a", "g").constructor)(undefined).constructor.prototype.toString();
|
||||
new Date("2015-07-09T12:13:14.121+01:30").toISOString();
|
||||
RegExp(new RegExp("a", "g")).constructor("").constructor.prototype.compile(RegExp.prototype);
|
||||
|
||||
try {
|
||||
RegExp(new RegExp("a", "g")).constructor("").constructor.prototype.compile(RegExp.prototype);
|
||||
assert (false);
|
||||
} catch (e) {
|
||||
assert(e instanceof TypeError);
|
||||
}
|
||||
|
||||
new Date("2015-09-17").getUTCFullYear();
|
||||
|
||||
@@ -12,4 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
RegExp.prototype.compile(RegExp.prototype);
|
||||
try {
|
||||
RegExp.prototype.compile(RegExp.prototype);
|
||||
assert(false);
|
||||
} catch (e) {
|
||||
assert (e instanceof TypeError);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user