| 1 |
// Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
es6id: 21.1.2.2 |
| 5 |
description: > |
| 6 |
Throw a RangeError if an argument is < 0 or > 0x10FFFF. |
| 7 |
info: | |
| 8 |
String.fromCodePoint ( ...codePoints ) |
| 9 |
|
| 10 |
1. Let codePoints be a List containing the arguments passed to this function. |
| 11 |
2. Let length be the number of elements in codePoints. |
| 12 |
3. Let elements be a new List. |
| 13 |
4. Let nextIndex be 0. |
| 14 |
5. Repeat while nextIndex < length |
| 15 |
a. Let next be codePoints[nextIndex]. |
| 16 |
b. Let nextCP be ToNumber(next). |
| 17 |
c. ReturnIfAbrupt(nextCP). |
| 18 |
d. If SameValue(nextCP, ToInteger(nextCP)) is false, throw a RangeError |
| 19 |
exception. |
| 20 |
e. If nextCP < 0 or nextCP > 0x10FFFF, throw a RangeError exception. |
| 21 |
... |
| 22 |
---*/ |
| 23 |
|
| 24 |
assert.throws(RangeError, function() { |
| 25 |
String.fromCodePoint(-1); |
| 26 |
}); |
| 27 |
|
| 28 |
assert.throws(RangeError, function() { |
| 29 |
String.fromCodePoint(1, -1); |
| 30 |
}); |
| 31 |
|
| 32 |
assert.throws(RangeError, function() { |
| 33 |
String.fromCodePoint(1114112); |
| 34 |
}); |
| 35 |
|
| 36 |
assert.throws(RangeError, function() { |
| 37 |
String.fromCodePoint(Infinity); |
| 38 |
}); |