tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / js / kde / script-tests / GlobalObject.js
1 var h = "a\xefc";
2 var u = "a\u1234c";
3 var z = "\x00";
4
5 shouldBe("h.charCodeAt(1)", "239");
6 shouldBe("u.charCodeAt(1)", "4660");
7 shouldBe("escape(h)", "'a%EFc'");
8 shouldBe("escape(u)", "'a%u1234c'");
9 shouldBe("escape(z)", "'%00'");
10 shouldBe("unescape(escape(h))", "h");
11 shouldBe("unescape(escape(u))", "u");
12 shouldBe("unescape(escape(z))", "z");
13
14 shouldBeTrue("isNaN(NaN)");
15 shouldBeTrue("isNaN('NaN')");
16 shouldBeFalse("isNaN('1')");
17
18 shouldBeTrue("isFinite(1)");
19 shouldBeTrue("isFinite('1')");
20
21 // all should return NaN because 1st char is non-number
22 shouldBeFalse("isFinite('a')");
23 shouldBe('isNaN(parseInt("Hello", 8))', "true");
24 shouldBe('isNaN(parseInt("FFF", 10))', "true");
25 shouldBe('isNaN(parseInt(".5", 10))', "true");
26
27 shouldBeFalse("isFinite(Infinity)");
28 shouldBeFalse("isFinite('Infinity')");
29
30 shouldBeTrue("isNaN(parseInt())");
31 shouldBeTrue("isNaN(parseInt(''))");
32 shouldBeTrue("isNaN(parseInt(' '))");
33 shouldBeTrue("isNaN(parseInt('a'))");
34 shouldBe("parseInt(1)", "1");
35 shouldBe("parseInt(1234567890123456)", "1234567890123456");
36 shouldBe("parseInt(1.2)", "1");
37 shouldBe("parseInt(' 2.3')", "2");
38 shouldBe("parseInt('0x10')", "16");
39 shouldBe("parseInt('11', 0)", "11");
40 shouldBe("parseInt('F', 16)", "15");
41
42 shouldBeTrue("isNaN(parseInt('10', 40))");
43 shouldBe("parseInt('3x')", "3");
44 shouldBe("parseInt('3 x')", "3");
45 shouldBeTrue("isNaN(parseInt('Infinity'))");
46
47 // all should return 15
48 shouldBe('parseInt("15")', "15");
49 shouldBe('parseInt("017")', "15"); /// The spec says it's ok, and even encouraged, to parse this as 17!
50 shouldBe('parseInt("0xf")', "15");
51 shouldBe('parseInt("15", 0)', "15");
52 shouldBe('parseInt("15", 10)', "15");
53 shouldBe('parseInt("F", 16)', "15");
54 shouldBe('parseInt("17", 8)', "15");
55 shouldBe('parseInt("15.99", 10)', "15");
56 shouldBe('parseInt("FXX123", 16)', "15");
57 shouldBe('parseInt("1111", 2)', "15");
58 shouldBe('parseInt("15*3", 10)', "15");
59
60 // this should be 0
61 shouldBe('parseInt("0x7", 10)', "0");
62 shouldBe('parseInt("1x7", 10)', "1");
63
64 shouldBeTrue("isNaN(parseFloat())");
65 shouldBeTrue("isNaN(parseFloat(''))");
66 shouldBeTrue("isNaN(parseFloat(' '))");
67 shouldBeTrue("isNaN(parseFloat('a'))");
68 shouldBe("parseFloat(1)", "1");
69 shouldBe("parseFloat(' 2.3')", "2.3");
70 shouldBe("parseFloat('3.1 x', 3)", "3.1");
71 shouldBe("parseFloat('3.1x', 3)", "3.1");
72 shouldBeFalse("isFinite(parseFloat('Infinity'))");
73 shouldBeFalse("delete NaN");
74 shouldBeFalse("delete Infinity");
75 shouldBeFalse("delete undefined");