-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update RegExp.prototype.{match,replace} tests to expect Get(rx, "flags")
- Loading branch information
Showing
13 changed files
with
219 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
test/built-ins/RegExp/prototype/Symbol.match/flags-tostring-error.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (C) 2022 Richard Gibson. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: > | ||
Errors thrown by converting `flags` to string are forwarded to the runtime | ||
esid: sec-regexp.prototype-@@match | ||
info: | | ||
1. Let _rx_ be the *this* value. | ||
2. If Type(_rx_) is not Object, throw a *TypeError* exception. | ||
3. Let _S_ be ? ToString(_string_). | ||
4. Let _flags_ be ? ToString(? Get(_rx_, *"flags"*)). | ||
features: [Symbol.match] | ||
---*/ | ||
|
||
function CustomError() {} | ||
var toStringThrows = { | ||
[Symbol.toPrimitive](hint) { | ||
if (hint === 'string') { | ||
throw new CustomError(); | ||
} | ||
throw new Test262Error('@@toPrimitive should be called with hint "string"'); | ||
}, | ||
get toString() { throw new Test262Error('toString property should not be read'); }, | ||
get valueOf() { throw new Test262Error('valueOf property should not be read'); } | ||
}; | ||
|
||
var re = /./; | ||
Object.defineProperties(re, { | ||
flags: { | ||
get() { return toStringThrows; } | ||
}, | ||
global: { | ||
get() { throw new Test262Error('global property should not be read'); } | ||
}, | ||
unicode: { | ||
get() { throw new Test262Error('unicode property should not be read'); } | ||
} | ||
}); | ||
|
||
assert.throws(CustomError, function() { | ||
re[Symbol.match](''); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
test/built-ins/RegExp/prototype/Symbol.match/get-flags-err.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (C) 2022 Richard Gibson. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: > | ||
Errors thrown by `flags` accessor are forwarded to the runtime | ||
esid: sec-regexp.prototype-@@match | ||
info: | | ||
1. Let _rx_ be the *this* value. | ||
2. If Type(_rx_) is not Object, throw a *TypeError* exception. | ||
3. Let _S_ be ? ToString(_string_). | ||
4. Let _flags_ be ? ToString(? Get(_rx_, *"flags"*)). | ||
features: [Symbol.match] | ||
---*/ | ||
|
||
function CustomError() {} | ||
|
||
var obj = { | ||
get flags() { | ||
throw new CustomError(); | ||
}, | ||
get global() { | ||
throw new Test262Error('global property should not be read'); | ||
}, | ||
get unicode() { | ||
throw new Test262Error('unicode property should not be read'); | ||
} | ||
}; | ||
|
||
assert.throws(CustomError, function() { | ||
RegExp.prototype[Symbol.match].call(obj); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
test/built-ins/RegExp/prototype/Symbol.replace/flags-tostring-error.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (C) 2022 Richard Gibson. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: > | ||
Errors thrown by converting `flags` to string are forwarded to the runtime | ||
esid: sec-regexp.prototype-@@replace | ||
info: | | ||
1. Let _rx_ be the *this* value. | ||
2. If Type(_rx_) is not Object, throw a *TypeError* exception. | ||
3. Let _S_ be ? ToString(_string_). | ||
4. Let _lengthS_ be the number of code unit elements in _S_. | ||
5. Let _functionalReplace_ be IsCallable(_replaceValue_). | ||
6. If _functionalReplace_ is *false*, then | ||
a. Set _replaceValue_ to ? ToString(_replaceValue_). | ||
i. Let _flags_ be ? ToString(? Get(_rx_, *"flags"*)). | ||
features: [Symbol.replace] | ||
---*/ | ||
|
||
function CustomError() {} | ||
var toStringThrows = { | ||
[Symbol.toPrimitive](hint) { | ||
if (hint === 'string') { | ||
throw new CustomError(); | ||
} | ||
throw new Test262Error('@@toPrimitive should be called with hint "string"'); | ||
}, | ||
get toString() { throw new Test262Error('toString property should not be read'); }, | ||
get valueOf() { throw new Test262Error('valueOf property should not be read'); } | ||
}; | ||
|
||
var re = /./g; | ||
Object.defineProperties(re, { | ||
flags: { | ||
get() { return toStringThrows; } | ||
}, | ||
global: { | ||
get() { throw new Test262Error('global property should not be read'); } | ||
}, | ||
unicode: { | ||
get() { throw new Test262Error('unicode property should not be read'); } | ||
} | ||
}); | ||
|
||
assert.throws(CustomError, function() { | ||
re[Symbol.replace](''); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
test/built-ins/RegExp/prototype/Symbol.replace/get-flags-err.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (C) 2022 Richard Gibson. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: > | ||
Errors thrown by `flags` accessor are forwarded to the runtime | ||
esid: sec-regexp.prototype-@@replace | ||
info: | | ||
1. Let _rx_ be the *this* value. | ||
2. If Type(_rx_) is not Object, throw a *TypeError* exception. | ||
3. Let _S_ be ? ToString(_string_). | ||
4. Let _lengthS_ be the number of code unit elements in _S_. | ||
5. Let _functionalReplace_ be IsCallable(_replaceValue_). | ||
6. If _functionalReplace_ is *false*, then | ||
a. Set _replaceValue_ to ? ToString(_replaceValue_). | ||
i. Let _flags_ be ? ToString(? Get(_rx_, *"flags"*)). | ||
features: [Symbol.replace] | ||
---*/ | ||
|
||
function CustomError() {} | ||
|
||
var obj = { | ||
get flags() { | ||
throw new CustomError(); | ||
}, | ||
get global() { | ||
throw new Test262Error('global property should not be read'); | ||
}, | ||
get unicode() { | ||
throw new Test262Error('unicode property should not be read'); | ||
} | ||
}; | ||
|
||
assert.throws(CustomError, function() { | ||
RegExp.prototype[Symbol.replace].call(obj); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters