File indexing completed on 2024-04-28 15:28:37

0001 var h = "a\xefc";
0002 var u = "a\u1234c";
0003 var z = "\x00";
0004 
0005 shouldBe("h.charCodeAt(1)", "239");
0006 shouldBe("u.charCodeAt(1)", "4660");
0007 shouldBe("escape(h)", "'a%EFc'");
0008 shouldBe("escape(u)", "'a%u1234c'");
0009 shouldBe("escape(z)", "'%00'");
0010 shouldBe("unescape(escape(h))", "h");
0011 shouldBe("unescape(escape(u))", "u");
0012 shouldBe("unescape(escape(z))", "z");
0013 
0014 shouldBeTrue("isNaN(NaN)");
0015 shouldBeTrue("isNaN('NaN')");
0016 shouldBeFalse("isNaN('1')");
0017 
0018 shouldBeTrue("isFinite(1)");
0019 shouldBeTrue("isFinite('1')");
0020 
0021 // all should return NaN because 1st char is non-number
0022 shouldBeFalse("isFinite('a')");
0023 shouldBe('isNaN(parseInt("Hello", 8))', "true");
0024 shouldBe('isNaN(parseInt("FFF", 10))', "true");
0025 shouldBe('isNaN(parseInt(".5", 10))', "true");
0026 
0027 shouldBeFalse("isFinite(Infinity)");
0028 shouldBeFalse("isFinite('Infinity')");
0029 
0030 shouldBeTrue("isNaN(parseInt())");
0031 shouldBeTrue("isNaN(parseInt(''))");
0032 shouldBeTrue("isNaN(parseInt(' '))");
0033 shouldBeTrue("isNaN(parseInt('a'))");
0034 shouldBe("parseInt(1)", "1");
0035 shouldBe("parseInt(1234567890123456)", "1234567890123456");
0036 shouldBe("parseInt(1.2)", "1");
0037 shouldBe("parseInt(' 2.3')", "2");
0038 shouldBe("parseInt('0x10')", "16");
0039 shouldBe("parseInt('11', 0)", "11");
0040 shouldBe("parseInt('F', 16)", "15");
0041 
0042 shouldBeTrue("isNaN(parseInt('10', 40))");
0043 shouldBe("parseInt('3x')", "3");
0044 shouldBe("parseInt('3 x')", "3");
0045 shouldBeTrue("isNaN(parseInt('Infinity'))");
0046 
0047 // all should return 15
0048 shouldBe('parseInt("15")', "15");
0049 shouldBe('parseInt("017")', "15"); /// The spec says it's ok, and even encouraged, to parse this as 17!
0050 shouldBe('parseInt("0xf")', "15");
0051 shouldBe('parseInt("15", 0)', "15");
0052 shouldBe('parseInt("15", 10)', "15");
0053 shouldBe('parseInt("F", 16)', "15");
0054 shouldBe('parseInt("17", 8)', "15");
0055 shouldBe('parseInt("15.99", 10)', "15");
0056 shouldBe('parseInt("FXX123", 16)', "15");
0057 shouldBe('parseInt("1111", 2)', "15");
0058 shouldBe('parseInt("15*3", 10)', "15");
0059 
0060 // this should be 0
0061 shouldBe('parseInt("0x7", 10)', "0");
0062 shouldBe('parseInt("1x7", 10)', "1");
0063 
0064 shouldBeTrue("isNaN(parseFloat())");
0065 shouldBeTrue("isNaN(parseFloat(''))");
0066 shouldBeTrue("isNaN(parseFloat(' '))");
0067 shouldBeTrue("isNaN(parseFloat('a'))");
0068 shouldBe("parseFloat(1)", "1");
0069 shouldBe("parseFloat(' 2.3')", "2.3");
0070 shouldBe("parseFloat('3.1 x', 3)", "3.1");
0071 shouldBe("parseFloat('3.1x', 3)", "3.1");
0072 shouldBeFalse("isFinite(parseFloat('Infinity'))");
0073 shouldBeFalse("delete NaN");
0074 shouldBeFalse("delete Infinity");
0075 shouldBeFalse("delete undefined");