1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

LibJS: Add test for assignment operators

This commit is contained in:
Linus Groh 2020-05-04 22:34:37 +01:00 committed by Andreas Kling
parent 69c23aaedb
commit 8e4301dea6

View file

@ -0,0 +1,41 @@
load("test-common.js");
try {
var x;
x = 1;
assert((x = 2) === 2);
assert(x === 2);
x = 1;
assert((x += 2) === 3);
assert(x === 3);
x = 3;
assert((x -= 2) === 1);
assert(x === 1);
x = 3;
assert((x *= 2) === 6);
assert(x === 6);
x = 6;
assert((x /= 2) === 3);
assert(x === 3);
x = 2;
assert((x <<= 2) === 8);
assert(x === 8);
x = 8;
assert((x >>= 2) === 2);
assert(x === 2);
x = -(2 ** 32 - 10);
assert((x >>>= 2) === 2);
assert(x === 2);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}