| 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: Skipping construction from RegExp-like objects |
| 6 |
es6id: 21.2.3.1 |
| 7 |
info: | |
| 8 |
1. Let patternIsRegExp be IsRegExp(pattern). |
| 9 |
[...] |
| 10 |
3. If NewTarget is not undefined, let newTarget be NewTarget. |
| 11 |
4. Else, |
| 12 |
a. Let newTarget be the active function object. |
| 13 |
b. If patternIsRegExp is true and flags is undefined, then |
| 14 |
i. Let patternConstructor be Get(pattern, "constructor"). |
| 15 |
ii. ReturnIfAbrupt(patternConstructor). |
| 16 |
iii. If SameValue(newTarget, patternConstructor) is true, return |
| 17 |
pattern. |
| 18 |
features: [Symbol, Symbol.match] |
| 19 |
---*/ |
| 20 |
|
| 21 |
var obj = { |
| 22 |
constructor: RegExp |
| 23 |
}; |
| 24 |
|
| 25 |
obj[Symbol.match] = true; |
| 26 |
assert.sameValue(RegExp(obj), obj); |
| 27 |
|
| 28 |
obj[Symbol.match] = 'string'; |
| 29 |
assert.sameValue(RegExp(obj), obj); |
| 30 |
|
| 31 |
obj[Symbol.match] = []; |
| 32 |
assert.sameValue(RegExp(obj), obj); |
| 33 |
|
| 34 |
obj[Symbol.match] = Symbol(); |
| 35 |
assert.sameValue(RegExp(obj), obj); |
| 36 |
|
| 37 |
obj[Symbol.match] = 86; |
| 38 |
assert.sameValue(RegExp(obj), obj); |