diff options
Diffstat (limited to '')
13 files changed, 354 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-Symbol.js b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-Symbol.js new file mode 100644 index 0000000000..909f4909c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-Symbol.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Return abrupt from ToNumber(next). +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + 2. Let length be the number of elements in codePoints. + 3. Let elements be a new List. + 4. Let nextIndex be 0. + 5. Repeat while nextIndex < length + a. Let next be codePoints[nextIndex]. + b. Let nextCP be ToNumber(next). + c. ReturnIfAbrupt(nextCP). +features: [Symbol, String.fromCodePoint] +---*/ + +assert.throws(TypeError, function() { + String.fromCodePoint(Symbol()); +}); + +assert.throws(TypeError, function() { + String.fromCodePoint(42, Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-not-integer.js b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-not-integer.js new file mode 100644 index 0000000000..e5410178a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-not-integer.js @@ -0,0 +1,49 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Throw a RangeError if an argument is not equal to its Integer representation. +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + 2. Let length be the number of elements in codePoints. + 3. Let elements be a new List. + 4. Let nextIndex be 0. + 5. Repeat while nextIndex < length + a. Let next be codePoints[nextIndex]. + b. Let nextCP be ToNumber(next). + c. ReturnIfAbrupt(nextCP). + d. If SameValue(nextCP, ToInteger(nextCP)) is false, throw a RangeError + exception. + ... +features: [String.fromCodePoint] +---*/ + +assert.throws(RangeError, function() { + String.fromCodePoint(3.14); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint(42, 3.14); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint('3.14'); +}); + +// ToNumber(undefined) returns NaN. +assert.throws(RangeError, function() { + String.fromCodePoint(undefined); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint('_1'); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint('1a'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/argument-not-coercible.js b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-not-coercible.js new file mode 100644 index 0000000000..344690c1ca --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-not-coercible.js @@ -0,0 +1,44 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Return abrupt from ToNumber(next). +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + 2. Let length be the number of elements in codePoints. + 3. Let elements be a new List. + 4. Let nextIndex be 0. + 5. Repeat while nextIndex < length + a. Let next be codePoints[nextIndex]. + b. Let nextCP be ToNumber(next). + c. ReturnIfAbrupt(nextCP). +features: [String.fromCodePoint] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'item', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + String.fromCodePoint({ + valueOf: function() { + throw new Test262Error(); + } + }); +}); + +assert.throws(Test262Error, function() { + String.fromCodePoint(42, { + valueOf: function() { + throw new Test262Error(); + } + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/arguments-is-empty.js b/js/src/tests/test262/built-ins/String/fromCodePoint/arguments-is-empty.js new file mode 100644 index 0000000000..5fa6407f27 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/arguments-is-empty.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + The the arguments list is empty, an empty string is returned. +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + ... + 5. Repeat while nextIndex < length + ... + f. Append the elements of the UTF16Encoding (10.1.1) of nextCP to the end of + elements. + g. Let nextIndex be nextIndex + 1. + 6. Return the String value whose elements are, in order, the elements in the + List elements. If length is 0, the empty string is returned. + +features: [String.fromCodePoint] +---*/ + +assert.sameValue(String.fromCodePoint(), ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/browser.js b/js/src/tests/test262/built-ins/String/fromCodePoint/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/browser.js diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/fromCodePoint.js b/js/src/tests/test262/built-ins/String/fromCodePoint/fromCodePoint.js new file mode 100644 index 0000000000..6e9f8746be --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/fromCodePoint.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + String.fromCodePoint property descriptor +info: | + String.fromCodePoint ( ...codePoints ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.fromCodePoint] +---*/ + +verifyNotEnumerable(String, 'fromCodePoint'); +verifyWritable(String, 'fromCodePoint'); +verifyConfigurable(String, 'fromCodePoint'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/length.js b/js/src/tests/test262/built-ins/String/fromCodePoint/length.js new file mode 100644 index 0000000000..5708d475e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/length.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + The length property of the String.fromCodePoint constructor is 1. +includes: [propertyHelper.js] +features: [String.fromCodePoint] +---*/ + +assert.sameValue( + String.fromCodePoint.length, 1, + 'The value of `String.fromCodePoint.length` is `1`' +); + +verifyNotEnumerable(String.fromCodePoint, 'length'); +verifyNotWritable(String.fromCodePoint, 'length'); +verifyConfigurable(String.fromCodePoint, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/name.js b/js/src/tests/test262/built-ins/String/fromCodePoint/name.js new file mode 100644 index 0000000000..306ca1041d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + String.fromCodePoint.name +info: | + String.fromCodePoint ( ...codePoints ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.fromCodePoint] +---*/ + +assert.sameValue( + String.fromCodePoint.name, 'fromCodePoint', + 'The value of `String.fromCodePoint.name` is "fromCodePoint"' +); + +verifyNotEnumerable(String.fromCodePoint, 'name'); +verifyNotWritable(String.fromCodePoint, 'name'); +verifyConfigurable(String.fromCodePoint, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/not-a-constructor.js b/js/src/tests/test262/built-ins/String/fromCodePoint/not-a-constructor.js new file mode 100644 index 0000000000..ad07f88425 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + String.fromCodePoint does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(String.fromCodePoint), false, 'isConstructor(String.fromCodePoint) must return false'); + +assert.throws(TypeError, () => { + new String.fromCodePoint(); +}, '`new String.fromCodePoint()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/number-is-out-of-range.js b/js/src/tests/test262/built-ins/String/fromCodePoint/number-is-out-of-range.js new file mode 100644 index 0000000000..2ea4144e2a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/number-is-out-of-range.js @@ -0,0 +1,41 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Throw a RangeError if an argument is < 0 or > 0x10FFFF. +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + 2. Let length be the number of elements in codePoints. + 3. Let elements be a new List. + 4. Let nextIndex be 0. + 5. Repeat while nextIndex < length + a. Let next be codePoints[nextIndex]. + b. Let nextCP be ToNumber(next). + c. ReturnIfAbrupt(nextCP). + d. If SameValue(nextCP, ToInteger(nextCP)) is false, throw a RangeError + exception. + e. If nextCP < 0 or nextCP > 0x10FFFF, throw a RangeError exception. + ... +features: [String.fromCodePoint] +---*/ + +assert.throws(RangeError, function() { + String.fromCodePoint(-1); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint(1, -1); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint(1114112); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint(Infinity); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/return-string-value.js b/js/src/tests/test262/built-ins/String/fromCodePoint/return-string-value.js new file mode 100644 index 0000000000..d58934636a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/return-string-value.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Returns the String value whose elements are, in order, the code unit for the + numbers in the arguments list. +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + ... + 5. Repeat while nextIndex < length + ... + f. Append the elements of the UTF16Encoding (10.1.1) of nextCP to the end of + elements. + g. Let nextIndex be nextIndex + 1. + 6. Return the String value whose elements are, in order, the elements in the + List elements. If length is 0, the empty string is returned. +features: [String.fromCodePoint] +---*/ + +assert.sameValue(String.fromCodePoint(0), '\x00'); +assert.sameValue(String.fromCodePoint(42), '*'); +assert.sameValue(String.fromCodePoint(65, 90), 'AZ'); +assert.sameValue(String.fromCodePoint(0x404), '\u0404'); +assert.sameValue(String.fromCodePoint(0x2F804), '\uD87E\uDC04'); +assert.sameValue(String.fromCodePoint(194564), '\uD87E\uDC04'); +assert.sameValue( + String.fromCodePoint(0x1D306, 0x61, 0x1D307), + '\uD834\uDF06a\uD834\uDF07' +); +assert.sameValue(String.fromCodePoint(1114111), '\uDBFF\uDFFF'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/shell.js b/js/src/tests/test262/built-ins/String/fromCodePoint/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/shell.js diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/to-number-conversions.js b/js/src/tests/test262/built-ins/String/fromCodePoint/to-number-conversions.js new file mode 100644 index 0000000000..452a904479 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/to-number-conversions.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Returns the String value with the code unit for the given coerced types. +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + ... + 5. Repeat while nextIndex < length + a. Let next be codePoints[nextIndex]. + b. Let nextCP be ToNumber(next). + ... + 6. Return the String value whose elements are, in order, the elements in the + List elements. If length is 0, the empty string is returned. + + Ref: 7.1.3 ToNumber ( argument ) +features: [String.fromCodePoint] +---*/ + +assert.sameValue(String.fromCodePoint(null), '\x00'); +assert.sameValue(String.fromCodePoint(false), '\x00'); +assert.sameValue(String.fromCodePoint(true), '\x01'); +assert.sameValue(String.fromCodePoint('42'), '\x2A'); +assert.sameValue(String.fromCodePoint('042'), '\x2A'); +assert.sameValue( + String.fromCodePoint({ + valueOf: function() { + return 31; + } + }), + '\x1F' +); + +reportCompare(0, 0); |