mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-18 01:11:32 +00:00
Less prose; Update i64 example; More options for asc
This commit is contained in:
40
examples/i64-polyfill/tests/index.js
Normal file
40
examples/i64-polyfill/tests/index.js
Normal file
@ -0,0 +1,40 @@
|
||||
var assert = require("assert");
|
||||
|
||||
function assertUnary(op, loLeft, hiLeft, loResult, hiResult) {
|
||||
op(loLeft, hiLeft);
|
||||
assert.strictEqual(i64.getLo(), loResult);
|
||||
assert.strictEqual(i64.getHi(), hiResult);
|
||||
}
|
||||
|
||||
function assertBinary(op, loLeft, hiLeft, loRight, hiRight, loResult, hiResult) {
|
||||
op(loLeft, hiLeft, loLeft, loRight);
|
||||
assert.strictEqual(i64.getLo(), loResult);
|
||||
assert.strictEqual(i64.getHi(), hiResult);
|
||||
}
|
||||
|
||||
var i64 = require("..");
|
||||
|
||||
assertUnary(i64.clz, 1, 0, 63, 0);
|
||||
assertUnary(i64.clz, 0, 1, 31, 0);
|
||||
assertUnary(i64.clz, 1, 1, 31, 0);
|
||||
assertUnary(i64.clz, 0, 0, 64, 0);
|
||||
|
||||
assertUnary(i64.ctz, 0, 0x80000000, 63, 0);
|
||||
assertUnary(i64.ctz, 0x80000000, 0x80000000, 31, 0);
|
||||
assertUnary(i64.ctz, 0, 1, 32, 0);
|
||||
assertUnary(i64.ctz, 1, 0, 0, 0);
|
||||
assertUnary(i64.ctz, 0, 0, 64, 0);
|
||||
|
||||
assertUnary(i64.popcnt, 0x55555555, 0x55555555, 32, 0);
|
||||
assertUnary(i64.popcnt, -1, -1, 64, 0);
|
||||
assertUnary(i64.popcnt, 0, 0, 0, 0);
|
||||
assertUnary(i64.popcnt, 0x55, 0, 4, 0);
|
||||
assertUnary(i64.popcnt, 0, 0x55, 4, 0);
|
||||
assertUnary(i64.popcnt, 0x55, 0x55, 8, 0);
|
||||
|
||||
assertUnary(i64.eqz, 0, 0, 1, 0);
|
||||
assertUnary(i64.eqz, 0, 1, 0, 0);
|
||||
assertUnary(i64.eqz, 1, 0, 0, 0);
|
||||
assertUnary(i64.eqz, 1, 1, 0, 0);
|
||||
|
||||
// TODO...
|
Reference in New Issue
Block a user