mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 06:28:13 +00:00
LibJS: Improve correctness of rounding and bitwise operations
Patch from Anonymous
This commit is contained in:
parent
6622ad8895
commit
16a0e7a66d
9 changed files with 106 additions and 19 deletions
|
@ -0,0 +1,28 @@
|
|||
test("basic rounding", () => {
|
||||
expect(Math.round(1.25)).toBe(1);
|
||||
expect(Math.round(-1.25)).toBe(-1);
|
||||
expect(Math.round(1.5)).toBe(2);
|
||||
expect(Math.round(-1.5)).toBe(-1);
|
||||
expect(Math.round(1.75)).toBe(2);
|
||||
expect(Math.round(-1.75)).toBe(-2);
|
||||
expect(Math.round(1)).toBe(1);
|
||||
expect(Math.round(-1)).toBe(-1);
|
||||
expect(Math.round(4294967296.5)).toBe(4294967297);
|
||||
expect(Math.round(-4294967296.5)).toBe(-4294967296);
|
||||
expect(Math.round(4294967297)).toBe(4294967297);
|
||||
expect(Math.round(-4294967297)).toBe(-4294967297);
|
||||
});
|
||||
test("basic floor", () => {
|
||||
expect(Math.floor(1.25)).toBe(1);
|
||||
expect(Math.floor(-1.25)).toBe(-2);
|
||||
expect(Math.floor(1.5)).toBe(1);
|
||||
expect(Math.floor(-1.5)).toBe(-2);
|
||||
expect(Math.floor(1.75)).toBe(1);
|
||||
expect(Math.floor(-1.75)).toBe(-2);
|
||||
expect(Math.floor(1)).toBe(1);
|
||||
expect(Math.floor(-1)).toBe(-1);
|
||||
expect(Math.floor(4294967296.5)).toBe(4294967296);
|
||||
expect(Math.floor(-4294967296.5)).toBe(-4294967297);
|
||||
expect(Math.floor(4294967297)).toBe(4294967297);
|
||||
expect(Math.floor(-4294967297)).toBe(-4294967297);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue