1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-29 03:42:07 +00:00

LibJS: Fix that leftshift for BigInts did not round down

For negative number this previously rounded towards zero instead of the
intended always rounding down.
This commit is contained in:
davidot 2022-08-20 00:23:11 +02:00 committed by Linus Groh
parent cb49c07fb7
commit e663504df1
3 changed files with 37 additions and 4 deletions

View file

@ -63,3 +63,13 @@ test("shifting with non-numeric values", () => {
expect(Infinity << Infinity).toBe(0);
expect(-Infinity << Infinity).toBe(0);
});
describe("logical left shift on big ints", () => {
expect(3n << -1n).toBe(1n);
expect(3n << -2n).toBe(0n);
expect(-3n << -1n).toBe(-2n);
expect(-3n << -2n).toBe(-1n);
expect(-3n << -128n).toBe(-1n);
expect(3n << 6n).toBe(192n);
expect(3n << 0n).toBe(3n);
});