Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / RegExp / from-regexp-like-get-ctor-err.js
blobcc905363ec1c9ec803597fc761a80f5f4933598d
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 description: >
6     Behavior when accessing `constructor` property of RegExp-like objects
7 es6id: 21.2.3.1
8 info: |
9     1. Let patternIsRegExp be IsRegExp(pattern).
10     [...]
11     3. If NewTarget is not undefined, let newTarget be NewTarget.
12     4. Else,
13        a. Let newTarget be the active function object.
14        b. If patternIsRegExp is true and flags is undefined, then
15           i. Let patternConstructor be Get(pattern, "constructor").
16           ii. ReturnIfAbrupt(patternConstructor).
17           iii. If SameValue(newTarget, patternConstructor) is true, return
18                pattern.
19 features: [Symbol, Symbol.match]
20 ---*/
22 var obj = Object.defineProperty({}, 'constructor', {
23   get: function() {
24     throw new Test262Error();
25   }
26 });
28 obj[Symbol.match] = true;
29 assert.throws(Test262Error, function() {
30   RegExp(obj);
31 });
33 obj[Symbol.match] = 'string';
34 assert.throws(Test262Error, function() {
35   RegExp(obj);
36 });
38 obj[Symbol.match] = [];
39 assert.throws(Test262Error, function() {
40   RegExp(obj);
41 });
43 obj[Symbol.match] = Symbol()
44 assert.throws(Test262Error, function() {
45   RegExp(obj);
46 });
48 obj[Symbol.match] = 86;
49 assert.throws(Test262Error, function() {
50   RegExp(obj);
51 });
53 reportCompare(0, 0);