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:
parent
69c23aaedb
commit
8e4301dea6
1 changed files with 41 additions and 0 deletions
41
Libraries/LibJS/Tests/assignment-operators.js
Normal file
41
Libraries/LibJS/Tests/assignment-operators.js
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue