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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial