diff --git a/test/built-ins/String/length.js b/test/built-ins/String/length.js new file mode 100644 index 0000000000000000000000000000000000000000..839a7cdf8eb9316dc1fc0ce992c3f740c343c6c9 --- /dev/null +++ b/test/built-ins/String/length.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-properties-of-string-instances-length +es6id: 21.1.4.1 +description: The "length" property of String objects +info: | + [...] + 4. Return ? StringCreate(s, ? GetPrototypeFromConstructor(NewTarget, + "%StringPrototype%")). +includes: [propertyHelper.js] +---*/ + +var str = new String(''); + +verifyNotEnumerable(str, 'length'); +verifyNotWritable(str, 'length'); +verifyNotConfigurable(str, 'length'); + +assert.sameValue(str.length, 0, 'empty string'); + +str = new String(' '); +assert.sameValue(str.length, 1, 'whitespace'); + +str = new String(' \b '); +assert.sameValue(str.length, 3, 'character escape (U+008, "backspace")'); + +str = new String('\ud834\udf06'); +assert.sameValue(str.length, 2, 'Unicode escape (surrogate pair)'); diff --git a/test/built-ins/String/prototype/charAt/pos-coerce-err.js b/test/built-ins/String/prototype/charAt/pos-coerce-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a1c48a00e32c21ef3e283536303a2e67d4ea43d6 --- /dev/null +++ b/test/built-ins/String/prototype/charAt/pos-coerce-err.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charat +es6id: 21.1.3.1 +description: Error when attempting to coerce providec "pos" to a Number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). +---*/ + +var noCoerce = Object.create(null); + +assert.throws(TypeError, function() { + ''.charAt(noCoerce); +}); diff --git a/test/built-ins/String/prototype/charAt/pos-coerce-string.js b/test/built-ins/String/prototype/charAt/pos-coerce-string.js new file mode 100644 index 0000000000000000000000000000000000000000..53825a15a0b326e3725d5246c091668cfd5a39df --- /dev/null +++ b/test/built-ins/String/prototype/charAt/pos-coerce-string.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charat +es6id: 21.1.3.1 +description: Coercion of "pos" string value into number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). +---*/ + +assert.sameValue('abcd'.charAt(' +00200.0000E-0002 '), 'c'); diff --git a/test/built-ins/String/prototype/charAt/pos-rounding.js b/test/built-ins/String/prototype/charAt/pos-rounding.js new file mode 100644 index 0000000000000000000000000000000000000000..10615e2e7bf8c105272c3340987440e6e5959e39 --- /dev/null +++ b/test/built-ins/String/prototype/charAt/pos-rounding.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charat +es6id: 21.1.3.1 +description: Rounding of the provided "pos" number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). + 2. If number is NaN, return +0. + 3. If number is +0, -0, +∞, or -∞, return number. + 4. Return the number value that is the same sign as number and whose + magnitude is floor(abs(number)). +---*/ + +assert.sameValue('abc'.charAt(-0.99999), 'a', '-0.99999'); +assert.sameValue('abc'.charAt(-0.00001), 'a', '-0.00001'); +assert.sameValue('abc'.charAt(0.00001), 'a', '0.00001'); +assert.sameValue('abc'.charAt(0.99999), 'a', '0.99999'); +assert.sameValue('abc'.charAt(1.00001), 'b', '1.00001'); +assert.sameValue('abc'.charAt(1.99999), 'b', '1.99999'); diff --git a/test/built-ins/String/prototype/charAt/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/charAt/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..46029419c563394aa44d779dc65fc03c427ed363 --- /dev/null +++ b/test/built-ins/String/prototype/charAt/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charat +es6id: 21.1.3.1 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var charAt = String.prototype.charAt; + +assert.sameValue(typeof charAt, 'function'); + +assert.throws(TypeError, function() { + charAt.call(undefined, 0); +}, 'undefined'); + +assert.throws(TypeError, function() { + charAt.call(null, 0); +}, 'null'); diff --git a/test/built-ins/String/prototype/charCodeAt/pos-coerce-err.js b/test/built-ins/String/prototype/charCodeAt/pos-coerce-err.js new file mode 100644 index 0000000000000000000000000000000000000000..801a8baaa6c1324a1d674e51bb70e44333bdd9d0 --- /dev/null +++ b/test/built-ins/String/prototype/charCodeAt/pos-coerce-err.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charcodeat +es6id: 21.1.3.2 +description: Error when attempting to coerce providec "pos" to a Number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). +---*/ + +var noCoerce = Object.create(null); + +assert.throws(TypeError, function() { + ''.charCodeAt(noCoerce); +}); diff --git a/test/built-ins/String/prototype/charCodeAt/pos-coerce-string.js b/test/built-ins/String/prototype/charCodeAt/pos-coerce-string.js new file mode 100644 index 0000000000000000000000000000000000000000..9d11a7f46a16f9de62f172ef14b62b2183d17346 --- /dev/null +++ b/test/built-ins/String/prototype/charCodeAt/pos-coerce-string.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charcodeat +es6id: 21.1.3.2 +description: Coercion of "pos" string value into number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). +---*/ + +var cCode = 99; + +assert.sameValue('abcd'.charCodeAt(' +00200.0000E-0002 '), cCode); diff --git a/test/built-ins/String/prototype/charCodeAt/pos-rounding.js b/test/built-ins/String/prototype/charCodeAt/pos-rounding.js new file mode 100644 index 0000000000000000000000000000000000000000..32bd2ac7a6daf1f265bd6e7465d51dc25fe60c6d --- /dev/null +++ b/test/built-ins/String/prototype/charCodeAt/pos-rounding.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charcodeat +es6id: 21.1.3.2 +description: Rounding of the provided "pos" number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). + 2. If number is NaN, return +0. + 3. If number is +0, -0, +∞, or -∞, return number. + 4. Return the number value that is the same sign as number and whose + magnitude is floor(abs(number)). +---*/ + +var aCode = 97; +var bCode = 98; + +assert.sameValue('abc'.charCodeAt(-0.99999), aCode, '-0.99999'); +assert.sameValue('abc'.charCodeAt(-0.00001), aCode, '-0.00001'); +assert.sameValue('abc'.charCodeAt(0.00001), aCode, '0.00001'); +assert.sameValue('abc'.charCodeAt(0.99999), aCode, '0.99999'); +assert.sameValue('abc'.charCodeAt(1.00001), bCode, '1.00001'); +assert.sameValue('abc'.charCodeAt(1.99999), bCode, '1.99999'); diff --git a/test/built-ins/String/prototype/charCodeAt/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/charCodeAt/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..1ec966f79f2ac148a039b46a944c62001b9ceb1f --- /dev/null +++ b/test/built-ins/String/prototype/charCodeAt/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charcodeat +es6id: 21.1.3.2 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var charCodeAt = String.prototype.charCodeAt; + +assert.sameValue(typeof charCodeAt, 'function'); + +assert.throws(TypeError, function() { + charCodeAt.call(undefined, 0); +}, 'undefined'); + +assert.throws(TypeError, function() { + charCodeAt.call(null, 0); +}, 'null'); diff --git a/test/built-ins/String/prototype/concat/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/concat/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..23901e886cd7cd24e1abd4a8babad6ba4fb944a8 --- /dev/null +++ b/test/built-ins/String/prototype/concat/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.concat +es6id: 21.1.3.4 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var concat = String.prototype.concat; + +assert.sameValue(typeof concat, 'function'); + +assert.throws(TypeError, function() { + concat.call(undefined, ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + concat.call(null, ''); +}, 'null'); diff --git a/test/built-ins/String/prototype/indexOf/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/indexOf/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..4efca6cffe062b86ea4c37e1342a7badb45457f8 --- /dev/null +++ b/test/built-ins/String/prototype/indexOf/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.indexof +es6id: 21.1.3.8 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var indexOf = String.prototype.indexOf; + +assert.sameValue(typeof indexOf, 'function'); + +assert.throws(TypeError, function() { + indexOf.call(undefined, ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + indexOf.call(null, ''); +}, 'null'); diff --git a/test/built-ins/String/prototype/lastIndexOf/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/lastIndexOf/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..4eae545b44c9efc15b6d52ef2079ef519be1c2e8 --- /dev/null +++ b/test/built-ins/String/prototype/lastIndexOf/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.lastindexof +es6id: 21.1.3.9 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var lastIndexOf = String.prototype.lastIndexOf; + +assert.sameValue(typeof lastIndexOf, 'function'); + +assert.throws(TypeError, function() { + lastIndexOf.call(undefined, ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + lastIndexOf.call(null, ''); +}, 'null'); diff --git a/test/built-ins/String/prototype/localeCompare/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/localeCompare/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..7adac196a5b3be6107677cc64c8e92bb425e217d --- /dev/null +++ b/test/built-ins/String/prototype/localeCompare/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.localecompare +es6id: 21.1.3.10 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var localeCompare = String.prototype.localeCompare; + +assert.sameValue(typeof localeCompare, 'function'); + +assert.throws(TypeError, function() { + localeCompare.call(undefined, ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + localeCompare.call(null, ''); +}, 'null'); diff --git a/test/built-ins/String/prototype/match/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/match/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..e7e9fac2f07ba42526efc053c068a40a2a561a31 --- /dev/null +++ b/test/built-ins/String/prototype/match/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.match +es6id: 21.1.3.11 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var match = String.prototype.match; + +assert.sameValue(typeof match, 'function'); + +assert.throws(TypeError, function() { + match.call(undefined, /./); +}, 'undefined'); + +assert.throws(TypeError, function() { + match.call(null, /./); +}, 'null'); diff --git a/test/built-ins/String/prototype/replace/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/replace/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..858dce314e47c8f5a1ab0a46674bbe8612f791ca --- /dev/null +++ b/test/built-ins/String/prototype/replace/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.replace +es6id: 21.1.3.14 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var replace = String.prototype.replace; + +assert.sameValue(typeof replace, 'function'); + +assert.throws(TypeError, function() { + replace.call(undefined, '', ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + replace.call(null, '', ''); +}, 'null'); diff --git a/test/built-ins/String/prototype/search/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/search/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..461a347cacec8a04d0e86b7b90cfd65aafd11abf --- /dev/null +++ b/test/built-ins/String/prototype/search/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.search +es6id: 21.1.3.15 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var search = String.prototype.search; + +assert.sameValue(typeof search, 'function'); + +assert.throws(TypeError, function() { + search.call(undefined, /./); +}, 'undefined'); + +assert.throws(TypeError, function() { + search.call(null, /./); +}, 'null'); diff --git a/test/built-ins/String/prototype/slice/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/slice/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..b80ffd81ee6e07e63461eddbd29003667cec8f5f --- /dev/null +++ b/test/built-ins/String/prototype/slice/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.slice +es6id: 21.1.3.16 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var slice = String.prototype.slice; + +assert.sameValue(typeof slice, 'function'); + +assert.throws(TypeError, function() { + slice.call(undefined, 0); +}, 'undefined'); + +assert.throws(TypeError, function() { + slice.call(null, 0); +}, 'null'); diff --git a/test/built-ins/String/prototype/split/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/split/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..f769cb747c26f4bc2ce1cf7252e83f104cb53f9f --- /dev/null +++ b/test/built-ins/String/prototype/split/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.split +es6id: 21.1.3.17 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var split = String.prototype.split; + +assert.sameValue(typeof split, 'function'); + +assert.throws(TypeError, function() { + split.call(undefined, ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + split.call(null, ''); +}, 'null'); diff --git a/test/built-ins/String/prototype/substring/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/substring/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..b10927b8190806f52034f8e3d5a37e6be46ad735 --- /dev/null +++ b/test/built-ins/String/prototype/substring/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.substring +es6id: 21.1.3.19 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var substring = String.prototype.substring; + +assert.sameValue(typeof substring, 'function'); + +assert.throws(TypeError, function() { + substring.call(undefined, 0, 1); +}, 'undefined'); + +assert.throws(TypeError, function() { + substring.call(null, 0, 1); +}, 'null'); diff --git a/test/built-ins/String/prototype/toLocaleLowerCase/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/toLocaleLowerCase/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..e058b14f320abf04e7fc6910441572bcfde7b25f --- /dev/null +++ b/test/built-ins/String/prototype/toLocaleLowerCase/this-value-not-obj-coercible.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.tolocalelowercase +es6id: 21.1.3.20 +description: The "this" value must be object-coercible +info: | + This function works exactly the same as toLowerCase except that its result is + intended to yield the correct result for the host environment's current + locale, rather than a locale-independent result. + + 21.1.3.24 String.prototype.toLowerCase + + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +assert.sameValue(typeof toLocaleLowerCase, 'function'); + +assert.throws(TypeError, function() { + toLocaleLowerCase.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + toLocaleLowerCase.call(null); +}, 'null'); diff --git a/test/built-ins/String/prototype/toLocaleUpperCase/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/toLocaleUpperCase/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..fb9d816fecbe1e028ffbc66ce7fe29d35be68c24 --- /dev/null +++ b/test/built-ins/String/prototype/toLocaleUpperCase/this-value-not-obj-coercible.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.tolocaleuppercase +es6id: 21.1.3.21 +description: The "this" value must be object-coercible +info: | + This function works exactly the same as toUpperCase except that its result is + intended to yield the correct result for the host environment's current + locale, rather than a locale-independent result. + + 21.1.3.26 String.prototype.toUpperCase + + This function behaves in exactly the same way as + String.prototype.toLowerCase, except that code points are mapped to their + uppercase equivalents as specified in the Unicode Character Database. + + 21.1.3.24 String.prototype.toLowerCase + + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var toLocaleUpperCase = String.prototype.toLocaleUpperCase; + +assert.sameValue(typeof toLocaleUpperCase, 'function'); + +assert.throws(TypeError, function() { + toLocaleUpperCase.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + toLocaleUpperCase.call(null); +}, 'null'); diff --git a/test/built-ins/String/prototype/toLowerCase/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/toLowerCase/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..17638ca4e959df07541a4929fc4533f918ee1e18 --- /dev/null +++ b/test/built-ins/String/prototype/toLowerCase/this-value-not-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.tolowercase +es6id: 21.1.3.22 +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var toLowerCase = String.prototype.toLowerCase; + +assert.sameValue(typeof toLowerCase, 'function'); + +assert.throws(TypeError, function() { + toLowerCase.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + toLowerCase.call(null); +}, 'null'); diff --git a/test/built-ins/String/prototype/toUpperCase/this-value-not-obj-coercible.js b/test/built-ins/String/prototype/toUpperCase/this-value-not-obj-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..757aa5d57e55471a11596ede685f01d3a86eb664 --- /dev/null +++ b/test/built-ins/String/prototype/toUpperCase/this-value-not-obj-coercible.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.touppercase +es6id: 21.1.3.24 +description: The "this" value must be object-coercible +info: | + This function behaves in exactly the same way as + String.prototype.toLowerCase, except that code points are mapped to their + uppercase equivalents as specified in the Unicode Character Database. + + 21.1.3.24 String.prototype.toLowerCase + + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var toUpperCase = String.prototype.toUpperCase; + +assert.sameValue(typeof toUpperCase, 'function'); + +assert.throws(TypeError, function() { + toUpperCase.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + toUpperCase.call(null); +}, 'null');