js/src/tests/ecma_6/String/fromCodePoint.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:7754716a0b90
1 var BUGNUMBER = 918879;
2 var summary = 'String.fromCodePoint';
3
4 print(BUGNUMBER + ": " + summary);
5
6 // Tests taken from:
7 // https://github.com/mathiasbynens/String.fromCodePoint/blob/master/tests/tests.js
8
9 assertEq(String.fromCodePoint.length, 0);
10 assertEq(String.propertyIsEnumerable('fromCodePoint'), false);
11
12 assertEq(String.fromCodePoint(''), '\0');
13 assertEq(String.fromCodePoint(), '');
14 assertEq(String.fromCodePoint(-0), '\0');
15 assertEq(String.fromCodePoint(0), '\0');
16 assertEq(String.fromCodePoint(0x1D306), '\uD834\uDF06');
17 assertEq(String.fromCodePoint(0x1D306, 0x61, 0x1D307), '\uD834\uDF06a\uD834\uDF07');
18 assertEq(String.fromCodePoint(0x61, 0x62, 0x1D307), 'ab\uD834\uDF07');
19 assertEq(String.fromCodePoint(false), '\0');
20 assertEq(String.fromCodePoint(null), '\0');
21
22 assertThrowsInstanceOf(function() { String.fromCodePoint('_'); }, RangeError);
23 assertThrowsInstanceOf(function() { String.fromCodePoint('+Infinity'); }, RangeError);
24 assertThrowsInstanceOf(function() { String.fromCodePoint('-Infinity'); }, RangeError);
25 assertThrowsInstanceOf(function() { String.fromCodePoint(-1); }, RangeError);
26 assertThrowsInstanceOf(function() { String.fromCodePoint(0x10FFFF + 1); }, RangeError);
27 assertThrowsInstanceOf(function() { String.fromCodePoint(3.14); }, RangeError);
28 assertThrowsInstanceOf(function() { String.fromCodePoint(3e-2); }, RangeError);
29 assertThrowsInstanceOf(function() { String.fromCodePoint(Infinity); }, RangeError);
30 assertThrowsInstanceOf(function() { String.fromCodePoint(NaN); }, RangeError);
31 assertThrowsInstanceOf(function() { String.fromCodePoint(undefined); }, RangeError);
32 assertThrowsInstanceOf(function() { String.fromCodePoint({}); }, RangeError);
33
34 var counter = Math.pow(2, 15) * 3 / 2;
35 var result = [];
36 while (--counter >= 0) {
37 result.push(0); // one code unit per symbol
38 }
39 String.fromCodePoint.apply(null, result); // must not throw
40
41 var counter = Math.pow(2, 15) * 3 / 2;
42 var result = [];
43 while (--counter >= 0) {
44 result.push(0xFFFF + 1); // two code units per symbol
45 }
46 String.fromCodePoint.apply(null, result); // must not throw
47
48 reportCompare(0, 0, "ok");

mercurial