mirror of https://github.com/tc39/test262.git
Add tests for cross‑realm and subclass `RegExp.prototype.compile` calls
This commit is contained in:
parent
d06c21c03a
commit
391f799152
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2020 ExE Boss. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-regexp.prototype.compile
|
||||
description: RegExp.prototype.compile throws a TypeError for cross-realm calls
|
||||
features: [legacy-regexp,cross-realm]
|
||||
---*/
|
||||
|
||||
const other = $262.createRealm().global;
|
||||
|
||||
const regexp = new RegExp("");
|
||||
const otherRealm_regexp = new other.RegExp("");
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function () {
|
||||
RegExp.prototype.compile.call(otherRealm_regexp);
|
||||
},
|
||||
"`RegExp.prototype.compile.call(otherRealm_regexp)` throws TypeError"
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function () {
|
||||
other.RegExp.prototype.compile.call(regexp);
|
||||
},
|
||||
"`other.RegExp.prototype.compile.call(regexp)` throws TypeError"
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
otherRealm_regexp.compile(),
|
||||
otherRealm_regexp,
|
||||
"`otherRealm_regexp.compile()` is SameValue with `otherRealm_regexp`"
|
||||
);
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) 2020 ExE Boss. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-regexp.prototype.compile
|
||||
description: RegExp.prototype.compile throws a TypeError for calls on subclasses
|
||||
features: [legacy-regexp,class]
|
||||
---*/
|
||||
|
||||
const subclass_regexp = new (class extends RegExp {})("");
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function () {
|
||||
subclass_regexp.compile();
|
||||
},
|
||||
"`subclass_regexp.compile()` throws TypeError"
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function () {
|
||||
RegExp.prototype.compile.call(subclass_regexp);
|
||||
},
|
||||
"`RegExp.prototype.compile.call(subclass_regexp)` throws TypeError"
|
||||
);
|
Loading…
Reference in New Issue