diff options
author | André Bargull <andre.bargull@gmail.com> | 2017-12-08 13:18:14 -0800 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2017-12-19 15:42:56 -0500 |
commit | 9b54779018ce73c873b727b944264974a62c59b4 (patch) | |
tree | 29ce8565254d9db38fa40cb5979d4117b9af9bec /test/annexB | |
parent | eecf0fd06b45e85eb7e93b212477ebf4e2a7df5f (diff) | |
download | qtdeclarative-testsuites-9b54779018ce73c873b727b944264974a62c59b4.tar.gz |
Add tests for recompilation in @@split
Diffstat (limited to 'test/annexB')
2 files changed, 67 insertions, 0 deletions
diff --git a/test/annexB/built-ins/RegExp/prototype/Symbol.split/Symbol.match-getter-recompiles-source.js b/test/annexB/built-ins/RegExp/prototype/Symbol.split/Symbol.match-getter-recompiles-source.js new file mode 100644 index 000000000..228e79212 --- /dev/null +++ b/test/annexB/built-ins/RegExp/prototype/Symbol.split/Symbol.match-getter-recompiles-source.js @@ -0,0 +1,35 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-regexp.prototype-@@split +description: > + Side-effects in IsRegExp may recompile the regular expression. +info: | + 21.2.5.11 RegExp.prototype [ @@split ] ( string, limit ) + ... + 4. Let C be ? SpeciesConstructor(rx, %RegExp%). + ... + 10. Let splitter be ? Construct(C, « rx, newFlags »). + ... + + 21.2.3.1 RegExp ( pattern, flags ) + 1. Let patternIsRegExp be ? IsRegExp(pattern). + ... + +features: [Symbol.match, Symbol.split] +---*/ + +var regExp = /a/; +Object.defineProperty(regExp, Symbol.match, { + get: function() { + regExp.compile("b"); + } +}); + +var result = regExp[Symbol.split]("abba"); + +assert.sameValue(result.length, 3); +assert.sameValue(result[0], "a"); +assert.sameValue(result[1], ""); +assert.sameValue(result[2], "a"); diff --git a/test/annexB/built-ins/RegExp/prototype/Symbol.split/toint32-limit-recompiles-source.js b/test/annexB/built-ins/RegExp/prototype/Symbol.split/toint32-limit-recompiles-source.js new file mode 100644 index 000000000..eed5a2a4a --- /dev/null +++ b/test/annexB/built-ins/RegExp/prototype/Symbol.split/toint32-limit-recompiles-source.js @@ -0,0 +1,32 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-regexp.prototype-@@split +description: > + Side-effects in ToUint32 may recompile the regular expression. +info: | + 21.2.5.11 RegExp.prototype [ @@split ] ( string, limit ) + ... + 10. Let splitter be ? Construct(C, « rx, newFlags »). + ... + 13. If limit is undefined, let lim be 2^32-1; else let lim be ? ToUint32(limit). + ... + +features: [Symbol.split] +---*/ + +var regExp = /a/; +var limit = { + valueOf: function() { + regExp.compile("b"); + return -1; + } +}; + +var result = regExp[Symbol.split]("abba", limit); + +assert.sameValue(result.length, 3); +assert.sameValue(result[0], ""); +assert.sameValue(result[1], "bb"); +assert.sameValue(result[2], ""); |