diff options
author | Linus Groh <mail@linusgroh.de> | 2020-04-23 13:36:14 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-23 19:38:13 +0200 |
commit | f0e7404480d7712d004fcd9ff6908b6df812b54a (patch) | |
tree | acaae40a1f280ffd62b3ecfb4f2a733424d3df44 /Libraries/LibJS/Tests/binary-bitwise-or.js | |
parent | 97366f4dd435c7906ab363d695d85fd7bb56aa96 (diff) | |
download | serenity-f0e7404480d7712d004fcd9ff6908b6df812b54a.zip |
LibJS: Implement bitwise left shift operator (<<)
Diffstat (limited to 'Libraries/LibJS/Tests/binary-bitwise-or.js')
-rw-r--r-- | Libraries/LibJS/Tests/binary-bitwise-or.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/binary-bitwise-or.js b/Libraries/LibJS/Tests/binary-bitwise-or.js new file mode 100644 index 0000000000..09eb1ae036 --- /dev/null +++ b/Libraries/LibJS/Tests/binary-bitwise-or.js @@ -0,0 +1,63 @@ +load("test-common.js"); + +try { + assert((0 | 0) === 0); + assert((0 | 1) === 1); + assert((0 | 2) === 2); + assert((0 | 3) === 3); + assert((0 | 4) === 4); + assert((0 | 5) === 5); + + assert((1 | 0) === 1); + assert((1 | 1) === 1); + assert((1 | 2) === 3); + assert((1 | 3) === 3); + assert((1 | 4) === 5); + assert((1 | 5) === 5); + + assert((2 | 0) === 2); + assert((2 | 1) === 3); + assert((2 | 2) === 2); + assert((2 | 3) === 3); + assert((2 | 4) === 6); + assert((2 | 5) === 7); + + assert((3 | 0) === 3); + assert((3 | 1) === 3); + assert((3 | 2) === 3); + assert((3 | 3) === 3); + assert((3 | 4) === 7); + assert((3 | 5) === 7); + + assert((4 | 0) === 4); + assert((4 | 1) === 5); + assert((4 | 2) === 6); + assert((4 | 3) === 7); + assert((4 | 4) === 4); + assert((4 | 5) === 5); + + assert((5 | 0) === 5); + assert((5 | 1) === 5); + assert((5 | 2) === 7); + assert((5 | 3) === 7); + assert((5 | 4) === 5); + assert((5 | 5) === 5); + + var x = 3; + var y = 7; + assert(("42" | 6) === 46); + assert((x | y) === 7); + assert((x | [[[[12]]]]) === 15); + assert((undefined | y) === 7); + assert(("a" | "b") === 0); + assert((null | null) === 0); + assert((undefined | undefined) === 0); + assert((NaN | NaN) === 0); + assert((NaN | 6) === 6); + assert((Infinity | Infinity) === 0); + assert((-Infinity | Infinity) === 0); + + console.log("PASS"); +} catch (e) { + console.log("FAIL: " + e); +} |