Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/RegExp/from-regexp-like-get-flags-err.js

raw
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.
3
4 /*---
5 description: >
6 Behavior when error thrown from `flags` property of a RegExp-like object
7 es6id: 21.2.3.1
8 info: |
9 1. Let patternIsRegExp be IsRegExp(pattern).
10 [...]
11 6. Else if patternIsRegExp is true, then
12 [...]
13 c. If flags is undefined, then
14 i. Let F be Get(pattern, "flags").
15 ii. ReturnIfAbrupt(F).
16 features: [Symbol, Symbol.match]
17 ---*/
18
19 var obj = {};
20 Object.defineProperty(obj, 'flags', {
21 get: function() {
22 throw new Test262Error();
23 }
24 });
25
26 obj[Symbol.match] = true;
27 assert.throws(Test262Error, function() {
28 new RegExp(obj);
29 });
30
31 obj[Symbol.match] = 'string';
32 assert.throws(Test262Error, function() {
33 new RegExp(obj);
34 });
35
36 obj[Symbol.match] = [];
37 assert.throws(Test262Error, function() {
38 new RegExp(obj);
39 });
40
41 obj[Symbol.match] = Symbol();
42 assert.throws(Test262Error, function() {
43 new RegExp(obj);
44 });
45
46 obj[Symbol.match] = 86;
47 assert.throws(Test262Error, function() {
48 new RegExp(obj);
49 });