mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-18 06:00:27 +00:00
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This regressed in cd15b1a2c9
.
If a prefixed number is out-of-range of a u64, stroul would previously
fall back to ULONG_MAX. This patch restores that behavior.
67 lines
1.8 KiB
JavaScript
67 lines
1.8 KiB
JavaScript
// FIXME: Some of the test cases below are duplicated, presumably to test
|
|
// uppercase as well which then got lowercased by Prettier at some point.
|
|
|
|
test("hex literals", () => {
|
|
expect(0xff).toBe(255);
|
|
expect(0xff).toBe(255);
|
|
});
|
|
|
|
test("octal literals", () => {
|
|
expect(0o10).toBe(8);
|
|
expect(0o10).toBe(8);
|
|
expect(010).toBe(8);
|
|
expect(089).toBe(89);
|
|
});
|
|
|
|
test("binary literals", () => {
|
|
expect(0b10).toBe(2);
|
|
expect(0b10).toBe(2);
|
|
});
|
|
|
|
test("exponential literals", () => {
|
|
expect(1e3).toBe(1000);
|
|
expect(1e3).toBe(1000);
|
|
expect(1e-3).toBe(0.001);
|
|
expect(1e1).toBe(10);
|
|
expect(0.1e1).toBe(1);
|
|
expect(0.1e1).toBe(1);
|
|
expect(0.1e1).toBe(1);
|
|
expect(0.1e1).toBe(1);
|
|
});
|
|
|
|
test("decimal numbers", () => {
|
|
expect(1).toBe(1);
|
|
expect(0.1).toBe(0.1);
|
|
});
|
|
|
|
test("accessing properties of decimal numbers", () => {
|
|
Number.prototype.foo = "foo";
|
|
expect((1).foo).toBe("foo");
|
|
expect((1.1).foo).toBe("foo");
|
|
expect((0.1).foo).toBe("foo");
|
|
});
|
|
|
|
test("invalid numeric literals", () => {
|
|
expect("1e").not.toEval();
|
|
expect("0x").not.toEval();
|
|
expect("0b").not.toEval();
|
|
expect("0o").not.toEval();
|
|
expect("'use strict'; 0755").not.toEval();
|
|
expect("1in[]").not.toEval();
|
|
expect("2instanceof foo").not.toEval();
|
|
});
|
|
|
|
test("out-of-range literals", () => {
|
|
expect(0x10000000000000000).toBe(18446744073709552000);
|
|
expect(-0x10000000000000000).toBe(-18446744073709552000);
|
|
|
|
expect(0o2000000000000000000000).toBe(18446744073709552000);
|
|
expect(-0o2000000000000000000000).toBe(-18446744073709552000);
|
|
|
|
expect(0b10000000000000000000000000000000000000000000000000000000000000000).toBe(
|
|
18446744073709552000
|
|
);
|
|
expect(-0b10000000000000000000000000000000000000000000000000000000000000000).toBe(
|
|
-18446744073709552000
|
|
);
|
|
});
|