| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
var obj = { |
| 22 |
source: 'source text' |
| 23 |
}; |
| 24 |
var result; |
| 25 |
|
| 26 |
Object.defineProperty(obj, 'flags', { |
| 27 |
get: function() { |
| 28 |
$ERROR('The `flags` property value should not be referenced.'); |
| 29 |
} |
| 30 |
}); |
| 31 |
|
| 32 |
obj[Symbol.match] = true; |
| 33 |
result = new RegExp(obj, 'g'); |
| 34 |
assert.sameValue( |
| 35 |
result.source, 'source text', '@@match specified as a primitive boolean' |
| 36 |
); |
| 37 |
assert.sameValue( |
| 38 |
result.flags, 'g', '@@match specified as a primitive boolean' |
| 39 |
); |
| 40 |
|
| 41 |
obj[Symbol.match] = 'string'; |
| 42 |
result = new RegExp(obj, 'g'); |
| 43 |
assert.sameValue( |
| 44 |
result.source, 'source text', '@@match specified as a primitive string' |
| 45 |
); |
| 46 |
assert.sameValue(result.flags, 'g', '@@match specified as a primitive string'); |
| 47 |
|
| 48 |
obj[Symbol.match] = []; |
| 49 |
result = new RegExp(obj, 'g'); |
| 50 |
assert.sameValue( |
| 51 |
result.source, 'source text', '@@match specified as an array' |
| 52 |
); |
| 53 |
assert.sameValue(result.flags, 'g', '@@match specified as an array'); |
| 54 |
|
| 55 |
obj[Symbol.match] = Symbol(); |
| 56 |
result = new RegExp(obj, 'g'); |
| 57 |
assert.sameValue( |
| 58 |
result.source, 'source text', '@@match specified as a Symbol' |
| 59 |
); |
| 60 |
assert.sameValue(result.flags, 'g', '@@match specified as a Symbol'); |
| 61 |
|
| 62 |
obj[Symbol.match] = 86; |
| 63 |
result = new RegExp(obj, 'g'); |
| 64 |
assert.sameValue( |
| 65 |
result.source, 'source text', '@@match specified as a primitive number' |
| 66 |
); |
| 67 |
assert.sameValue(result.flags, 'g', '@@match specified as a primitive number'); |