2018-08-05 05:00:16 +03:00
|
|
|
const wasm = require('wasm-bindgen-test.js');
|
2019-03-27 03:29:53 +03:00
|
|
|
const assert = require('assert');
|
2018-08-05 05:00:16 +03:00
|
|
|
|
|
|
|
exports.js_auto_bind_math = () => {
|
|
|
|
wasm.math(1.0, 2.0);
|
|
|
|
};
|
2019-03-27 03:29:53 +03:00
|
|
|
|
|
|
|
exports.roundtrip = x => x;
|
|
|
|
|
|
|
|
exports.test_js_roundtrip = () => {
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_i8(0), 0);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_i8(0x80), -128);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_i8(0x7f), 127);
|
|
|
|
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_i16(0), 0);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_i16(0x8000), -32768);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_i16(0x7fff), 32767);
|
|
|
|
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_i32(0), 0);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_i32(0x80000000), -2147483648);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_i32(0x7fffffff), 2147483647);
|
|
|
|
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u8(0), 0);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u8(0x80), 128);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u8(0x7f), 127);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u8(0xff), 255);
|
|
|
|
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u16(0), 0);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u16(0x8000), 32768);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u16(0x7fff), 32767);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u16(0xffff), 65535);
|
|
|
|
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u32(0), 0);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u32(0x80000000), 2147483648);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u32(0x7fffffff), 2147483647);
|
|
|
|
assert.strictEqual(wasm.rust_roundtrip_u32(0xffffffff), 4294967295);
|
|
|
|
};
|