Serenity Operating System
1// FIXME: Some of the test cases below are duplicated, presumably to test
2// uppercase as well which then got lowercased by Prettier at some point.
3
4test("hex literals", () => {
5 expect(0xff).toBe(255);
6 expect(0xff).toBe(255);
7});
8
9test("octal literals", () => {
10 expect(0o10).toBe(8);
11 expect(0o10).toBe(8);
12 expect(010).toBe(8);
13 expect(089).toBe(89);
14});
15
16test("binary literals", () => {
17 expect(0b10).toBe(2);
18 expect(0b10).toBe(2);
19});
20
21test("exponential literals", () => {
22 expect(1e3).toBe(1000);
23 expect(1e3).toBe(1000);
24 expect(1e-3).toBe(0.001);
25 expect(1e1).toBe(10);
26 expect(0.1e1).toBe(1);
27 expect(0.1e1).toBe(1);
28 expect(0.1e1).toBe(1);
29 expect(0.1e1).toBe(1);
30});
31
32test("decimal numbers", () => {
33 expect(1).toBe(1);
34 expect(0.1).toBe(0.1);
35});
36
37test("accessing properties of decimal numbers", () => {
38 Number.prototype.foo = "foo";
39 expect((1).foo).toBe("foo");
40 expect((1.1).foo).toBe("foo");
41 expect((0.1).foo).toBe("foo");
42});
43
44test("invalid numeric literals", () => {
45 expect("1e").not.toEval();
46 expect("0x").not.toEval();
47 expect("0b").not.toEval();
48 expect("0o").not.toEval();
49 expect("'use strict'; 0755").not.toEval();
50 expect("1in[]").not.toEval();
51 expect("2instanceof foo").not.toEval();
52});