| 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 not equal to its Integer representation. |
| 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 |
... |
| 21 |
---*/ |
| 22 |
|
| 23 |
assert.throws(RangeError, function() { |
| 24 |
String.fromCodePoint(3.14); |
| 25 |
}); |
| 26 |
|
| 27 |
assert.throws(RangeError, function() { |
| 28 |
String.fromCodePoint(42, 3.14); |
| 29 |
}); |
| 30 |
|
| 31 |
assert.throws(RangeError, function() { |
| 32 |
String.fromCodePoint('3.14'); |
| 33 |
}); |
| 34 |
|
| 35 |
// ToNumber(undefined) returns NaN. |
| 36 |
assert.throws(RangeError, function() { |
| 37 |
String.fromCodePoint(undefined); |
| 38 |
}); |
| 39 |
|
| 40 |
assert.throws(RangeError, function() { |
| 41 |
String.fromCodePoint('_1'); |
| 42 |
}); |
| 43 |
|
| 44 |
assert.throws(RangeError, function() { |
| 45 |
String.fromCodePoint('1a'); |
| 46 |
}); |