mirror of https://github.com/tc39/test262.git
Improve coverage for section 21: String (#712)
This changeset increases coverage for section 21, specifically "21.1 String Objects". * Add tests for "this" validation of String methods * Add tests for ToNumber as used by String methods * Add test for `length` prop of exotic String objs * fixup! Add test for `length` prop of exotic String objs
This commit is contained in:
parent
021d44822c
commit
f554f68ae9
|
@ -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)');
|
|
@ -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);
|
||||||
|
});
|
|
@ -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');
|
|
@ -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');
|
|
@ -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');
|
|
@ -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);
|
||||||
|
});
|
|
@ -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);
|
|
@ -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');
|
|
@ -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');
|
|
@ -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');
|
|
@ -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');
|
|
@ -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');
|
21
test/built-ins/String/prototype/localeCompare/this-value-not-obj-coercible.js
vendored
Normal file
21
test/built-ins/String/prototype/localeCompare/this-value-not-obj-coercible.js
vendored
Normal file
|
@ -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');
|
|
@ -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');
|
|
@ -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');
|
|
@ -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');
|
|
@ -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');
|
|
@ -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');
|
|
@ -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');
|
27
test/built-ins/String/prototype/toLocaleLowerCase/this-value-not-obj-coercible.js
vendored
Normal file
27
test/built-ins/String/prototype/toLocaleLowerCase/this-value-not-obj-coercible.js
vendored
Normal file
|
@ -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');
|
33
test/built-ins/String/prototype/toLocaleUpperCase/this-value-not-obj-coercible.js
vendored
Normal file
33
test/built-ins/String/prototype/toLocaleUpperCase/this-value-not-obj-coercible.js
vendored
Normal file
|
@ -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');
|
|
@ -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');
|
|
@ -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');
|
Loading…
Reference in New Issue