diff --git a/test/built-ins/RegExp/prototype/flags/coercion-dotall.js b/test/built-ins/RegExp/prototype/flags/coercion-dotall.js new file mode 100644 index 0000000000..92d9b47c5e --- /dev/null +++ b/test/built-ins/RegExp/prototype/flags/coercion-dotall.js @@ -0,0 +1,45 @@ +// Copyright (C) 2017 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.flags +description: Boolean coercion of the dotAll property +info: > + get RegExp.prototype.flags + + ... + 10. Let dotAll be ToBoolean(? Get(R, "dotAll")). + ... +features: [Symbol, regexp-dotall] +---*/ + +var get = Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get; + +var r = {}; + +r.dotAll = undefined; +assert.sameValue(get.call(r), "", "dotAll: undefined"); + +r.dotAll = null; +assert.sameValue(get.call(r), "", "dotAll: null"); + +r.dotAll = NaN; +assert.sameValue(get.call(r), "", "dotAll: NaN"); + +r.dotAll = ""; +assert.sameValue(get.call(r), "", "dotAll: the empty string"); + +r.dotAll = "string"; +assert.sameValue(get.call(r), "s", "dotAll: string"); + +r.dotAll = 86; +assert.sameValue(get.call(r), "s", "dotAll: 86"); + +r.dotAll = Symbol(); +assert.sameValue(get.call(r), "s", "dotAll: Symbol()"); + +r.dotAll = []; +assert.sameValue(get.call(r), "s", "dotAll: []"); + +r.dotAll = {}; +assert.sameValue(get.call(r), "s", "dotAll: {}"); diff --git a/test/built-ins/RegExp/prototype/flags/coercion-global.js b/test/built-ins/RegExp/prototype/flags/coercion-global.js new file mode 100644 index 0000000000..2276a9b579 --- /dev/null +++ b/test/built-ins/RegExp/prototype/flags/coercion-global.js @@ -0,0 +1,45 @@ +// Copyright (C) 2017 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.flags +description: Boolean coercion of the global property +info: > + get RegExp.prototype.flags + + ... + 4. Let global be ToBoolean(? Get(R, "global")). + ... +features: [Symbol] +---*/ + +var get = Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get; + +var r = {}; + +r.global = undefined; +assert.sameValue(get.call(r), "", "global: undefined"); + +r.global = null; +assert.sameValue(get.call(r), "", "global: null"); + +r.global = NaN; +assert.sameValue(get.call(r), "", "global: NaN"); + +r.global = ""; +assert.sameValue(get.call(r), "", "global: the empty string"); + +r.global = "string"; +assert.sameValue(get.call(r), "g", "global: string"); + +r.global = 86; +assert.sameValue(get.call(r), "g", "global: 86"); + +r.global = Symbol(); +assert.sameValue(get.call(r), "g", "global: Symbol()"); + +r.global = []; +assert.sameValue(get.call(r), "g", "global: []"); + +r.global = {}; +assert.sameValue(get.call(r), "g", "global: {}"); diff --git a/test/built-ins/RegExp/prototype/flags/coercion-ignoreCase.js b/test/built-ins/RegExp/prototype/flags/coercion-ignoreCase.js new file mode 100644 index 0000000000..b66d4afe5c --- /dev/null +++ b/test/built-ins/RegExp/prototype/flags/coercion-ignoreCase.js @@ -0,0 +1,45 @@ +// Copyright (C) 2017 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.flags +description: Boolean coercion of the ignoreCase property +info: > + get RegExp.prototype.flags + + ... + 6. Let ignoreCase be ToBoolean(? Get(R, "ignoreCase")). + ... +features: [Symbol] +---*/ + +var get = Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get; + +var r = {}; + +r.ignoreCase = undefined; +assert.sameValue(get.call(r), "", "ignoreCase: undefined"); + +r.ignoreCase = null; +assert.sameValue(get.call(r), "", "ignoreCase: null"); + +r.ignoreCase = NaN; +assert.sameValue(get.call(r), "", "ignoreCase: NaN"); + +r.ignoreCase = ""; +assert.sameValue(get.call(r), "", "ignoreCase: the empty string"); + +r.ignoreCase = "string"; +assert.sameValue(get.call(r), "i", "ignoreCase: string"); + +r.ignoreCase = 86; +assert.sameValue(get.call(r), "i", "ignoreCase: 86"); + +r.ignoreCase = Symbol(); +assert.sameValue(get.call(r), "i", "ignoreCase: Symbol()"); + +r.ignoreCase = []; +assert.sameValue(get.call(r), "i", "ignoreCase: []"); + +r.ignoreCase = {}; +assert.sameValue(get.call(r), "i", "ignoreCase: {}"); diff --git a/test/built-ins/RegExp/prototype/flags/coercion-multiline.js b/test/built-ins/RegExp/prototype/flags/coercion-multiline.js new file mode 100644 index 0000000000..2ce2965a19 --- /dev/null +++ b/test/built-ins/RegExp/prototype/flags/coercion-multiline.js @@ -0,0 +1,45 @@ +// Copyright (C) 2017 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.flags +description: Boolean coercion of the multiline property +info: > + get RegExp.prototype.flags + + ... + 8. Let multiline be ToBoolean(? Get(R, "multiline")). + ... +features: [Symbol] +---*/ + +var get = Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get; + +var r = {}; + +r.multiline = undefined; +assert.sameValue(get.call(r), "", "multiline: undefined"); + +r.multiline = null; +assert.sameValue(get.call(r), "", "multiline: null"); + +r.multiline = NaN; +assert.sameValue(get.call(r), "", "multiline: NaN"); + +r.multiline = ""; +assert.sameValue(get.call(r), "", "multiline: the empty string"); + +r.multiline = "string"; +assert.sameValue(get.call(r), "m", "multiline: string"); + +r.multiline = 86; +assert.sameValue(get.call(r), "m", "multiline: 86"); + +r.multiline = Symbol(); +assert.sameValue(get.call(r), "m", "multiline: Symbol()"); + +r.multiline = []; +assert.sameValue(get.call(r), "m", "multiline: []"); + +r.multiline = {}; +assert.sameValue(get.call(r), "m", "multiline: {}"); diff --git a/test/built-ins/RegExp/prototype/flags/coercion-sticky.js b/test/built-ins/RegExp/prototype/flags/coercion-sticky.js new file mode 100644 index 0000000000..4274e56590 --- /dev/null +++ b/test/built-ins/RegExp/prototype/flags/coercion-sticky.js @@ -0,0 +1,45 @@ +// Copyright (C) 2017 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.flags +description: Boolean coercion of the sticky property +info: > + get RegExp.prototype.flags + + ... + 14. Let sticky be ToBoolean(? Get(R, "sticky")). + ... +features: [Symbol] +---*/ + +var get = Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get; + +var r = {}; + +r.sticky = undefined; +assert.sameValue(get.call(r), "", "sticky: undefined"); + +r.sticky = null; +assert.sameValue(get.call(r), "", "sticky: null"); + +r.sticky = NaN; +assert.sameValue(get.call(r), "", "sticky: NaN"); + +r.sticky = ""; +assert.sameValue(get.call(r), "", "sticky: the empty string"); + +r.sticky = "string"; +assert.sameValue(get.call(r), "y", "sticky: string"); + +r.sticky = 86; +assert.sameValue(get.call(r), "y", "sticky: 86"); + +r.sticky = Symbol(); +assert.sameValue(get.call(r), "y", "sticky: Symbol()"); + +r.sticky = []; +assert.sameValue(get.call(r), "y", "sticky: []"); + +r.sticky = {}; +assert.sameValue(get.call(r), "y", "sticky: {}"); diff --git a/test/built-ins/RegExp/prototype/flags/coercion-unicode.js b/test/built-ins/RegExp/prototype/flags/coercion-unicode.js new file mode 100644 index 0000000000..5d8c41e5e9 --- /dev/null +++ b/test/built-ins/RegExp/prototype/flags/coercion-unicode.js @@ -0,0 +1,45 @@ +// Copyright (C) 2017 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.flags +description: Boolean coercion of the unicode property +info: > + get RegExp.prototype.flags + + ... + 12. Let unicode be ToBoolean(? Get(R, "unicode")). + ... +features: [Symbol] +---*/ + +var get = Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get; + +var r = {}; + +r.unicode = undefined; +assert.sameValue(get.call(r), "", "unicode: undefined"); + +r.unicode = null; +assert.sameValue(get.call(r), "", "unicode: null"); + +r.unicode = NaN; +assert.sameValue(get.call(r), "", "unicode: NaN"); + +r.unicode = ""; +assert.sameValue(get.call(r), "", "unicode: the empty string"); + +r.unicode = "string"; +assert.sameValue(get.call(r), "u", "unicode: string"); + +r.unicode = 86; +assert.sameValue(get.call(r), "u", "unicode: 86"); + +r.unicode = Symbol(); +assert.sameValue(get.call(r), "u", "unicode: Symbol()"); + +r.unicode = []; +assert.sameValue(get.call(r), "u", "unicode: []"); + +r.unicode = {}; +assert.sameValue(get.call(r), "u", "unicode: {}"); diff --git a/test/built-ins/RegExp/prototype/flags/coercion.js b/test/built-ins/RegExp/prototype/flags/coercion.js deleted file mode 100644 index 2ab545a5c4..0000000000 --- a/test/built-ins/RegExp/prototype/flags/coercion.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2017 Aleksey Shvayka. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-regexp.prototype.flags -description: Boolean coercion of properties -info: > - get RegExp.prototype.flags - - [...] - 4. Let global be ToBoolean(? Get(R, "global")). - 6. Let ignoreCase be ToBoolean(? Get(R, "ignoreCase")). - 8. Let multiline be ToBoolean(? Get(R, "multiline")). - 10. Let dotAll be ToBoolean(? Get(R, "dotAll")). - 12. Let unicode be ToBoolean(? Get(R, "unicode")). - 14. Let sticky be ToBoolean(? Get(R, "sticky")). -features: [Symbol, regexp-dotall] ----*/ - -var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get; -var flags = [ - ['g', 'global'], - ['i', 'ignoreCase'], - ['m', 'multiline'], - ['s', 'dotAll'], - ['u', 'unicode'], - ['y', 'sticky'], -]; - -flags.forEach(function(flag) { - var res = flag[0]; - var key = flag[1]; - var r = {}; - - r[key] = undefined; - assert.sameValue(get.call(r), '', key + ' = undefined'); - - r[key] = null; - assert.sameValue(get.call(r), '', key + ' = null'); - - r[key] = NaN; - assert.sameValue(get.call(r), '', key + ' = NaN'); - - r[key] = ''; - assert.sameValue(get.call(r), '', key + ' = ""'); - - r[key] = 'string'; - assert.sameValue(get.call(r), res, key + ' = "string"'); - - r[key] = 86; - assert.sameValue(get.call(r), res, key + ' = 86'); - - r[key] = Symbol(); - assert.sameValue(get.call(r), res, key + ' = Symbol()'); - - r[key] = []; - assert.sameValue(get.call(r), res, key + ' = []'); - - r[key] = {}; - assert.sameValue(get.call(r), res, key + ' = {}'); -}); diff --git a/test/built-ins/RegExp/prototype/flags/order-gets.js b/test/built-ins/RegExp/prototype/flags/get-order.js similarity index 96% rename from test/built-ins/RegExp/prototype/flags/order-gets.js rename to test/built-ins/RegExp/prototype/flags/get-order.js index 2cebc3a7f6..a2d14b6476 100644 --- a/test/built-ins/RegExp/prototype/flags/order-gets.js +++ b/test/built-ins/RegExp/prototype/flags/get-order.js @@ -41,5 +41,5 @@ var re = { var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get; -assert.sameValue(get.call(re), ''); +get.call(re); assert.sameValue(calls, 'gimsuy'); diff --git a/test/built-ins/RegExp/prototype/flags/rethrow.js b/test/built-ins/RegExp/prototype/flags/rethrow.js index ec394a9e47..544ae976ad 100644 --- a/test/built-ins/RegExp/prototype/flags/rethrow.js +++ b/test/built-ins/RegExp/prototype/flags/rethrow.js @@ -25,7 +25,7 @@ assert.throws(Test262Error, function() { throw new Test262Error(); }, }); -}, 'global'); +}, 'Let global be ToBoolean(? Get(R, "global"))'); assert.throws(Test262Error, function() { get.call({ @@ -33,7 +33,7 @@ assert.throws(Test262Error, function() { throw new Test262Error(); }, }); -}, 'ignoreCase'); +}, 'Let ignoreCase be ToBoolean(? Get(R, "ignoreCase"))'); assert.throws(Test262Error, function() { get.call({ @@ -41,7 +41,7 @@ assert.throws(Test262Error, function() { throw new Test262Error(); }, }); -}, 'multiline'); +}, 'Let multiline be ToBoolean(? Get(R, "multiline"))'); assert.throws(Test262Error, function() { get.call({ @@ -49,7 +49,7 @@ assert.throws(Test262Error, function() { throw new Test262Error(); }, }); -}, 'dotAll'); +}, 'Let dotAll be ToBoolean(? Get(R, "dotAll"))'); assert.throws(Test262Error, function() { get.call({ @@ -57,7 +57,7 @@ assert.throws(Test262Error, function() { throw new Test262Error(); }, }); -}, 'unicode'); +}, 'Let unicode be ToBoolean(? Get(R, "unicode"))'); assert.throws(Test262Error, function() { get.call({ @@ -65,4 +65,4 @@ assert.throws(Test262Error, function() { throw new Test262Error(); }, }); -}, 'sticky'); +}, 'Let sticky be ToBoolean(? Get(R, "sticky"))'); diff --git a/test/built-ins/RegExp/prototype/flags/order.js b/test/built-ins/RegExp/prototype/flags/return-order.js similarity index 100% rename from test/built-ins/RegExp/prototype/flags/order.js rename to test/built-ins/RegExp/prototype/flags/return-order.js diff --git a/test/built-ins/RegExp/prototype/flags/this-val-regexp-prototype.js b/test/built-ins/RegExp/prototype/flags/this-val-regexp-prototype.js index 8ded3a96e8..fd9019a451 100644 --- a/test/built-ins/RegExp/prototype/flags/this-val-regexp-prototype.js +++ b/test/built-ins/RegExp/prototype/flags/this-val-regexp-prototype.js @@ -6,9 +6,20 @@ esid: sec-get-regexp.prototype.flags description: > Return "" when the `this` value is the RegExp.prototype object info: | - 1. Let R be the this value. - 2. If Type(R) is not Object, throw a TypeError exception. 3. Let result be the empty String. + 4. Let global be ToBoolean(? Get(R, "global")). + 5. If global is true, append "g" as the last code unit of result. + 6. Let ignoreCase be ToBoolean(? Get(R, "ignoreCase")). + 7. If ignoreCase is true, append "i" as the last code unit of result. + 8. Let multiline be ToBoolean(? Get(R, "multiline")). + 9. If multiline is true, append "m" as the last code unit of result. + 10. Let dotAll be ToBoolean(? Get(R, "dotAll")). + 11. If dotAll is true, append "s" as the last code unit of result. + 12. Let unicode be ToBoolean(? Get(R, "unicode")). + 13. If unicode is true, append "u" as the last code unit of result. + 14. Let sticky be ToBoolean(? Get(R, "sticky")). + 15. If sticky is true, append "y" as the last code unit of result. + 16. Return result. ---*/ var get = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get; diff --git a/test/built-ins/RegExp/prototype/flags/this-val-regexp.js b/test/built-ins/RegExp/prototype/flags/this-val-regexp.js index 4606f6da94..17747abb72 100644 --- a/test/built-ins/RegExp/prototype/flags/this-val-regexp.js +++ b/test/built-ins/RegExp/prototype/flags/this-val-regexp.js @@ -6,8 +6,20 @@ esid: sec-get-regexp.prototype.flags description: > RegExp.prototype.flags returns RegExp flags as a string info: | - 1. Let R be the this value. - 2. If Type(R) is not Object, throw a TypeError exception. + 3. Let result be the empty String. + 4. Let global be ToBoolean(? Get(R, "global")). + 5. If global is true, append "g" as the last code unit of result. + 6. Let ignoreCase be ToBoolean(? Get(R, "ignoreCase")). + 7. If ignoreCase is true, append "i" as the last code unit of result. + 8. Let multiline be ToBoolean(? Get(R, "multiline")). + 9. If multiline is true, append "m" as the last code unit of result. + 10. Let dotAll be ToBoolean(? Get(R, "dotAll")). + 11. If dotAll is true, append "s" as the last code unit of result. + 12. Let unicode be ToBoolean(? Get(R, "unicode")). + 13. If unicode is true, append "u" as the last code unit of result. + 14. Let sticky be ToBoolean(? Get(R, "sticky")). + 15. If sticky is true, append "y" as the last code unit of result. + 16. Return result. features: [regexp-dotall] ---*/