mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 13:01:22 +00:00
Migrate webidl
tests to wasm_bindgen_test
(#590)
This commit moves the `webidl/tests` folder to a new `crates/webidl-tests` crate (to have a test-only build script) and ports them to the `#[wasm_bindgen_test]` attribute, which should hopefully make testing much speedier for execution!
This commit is contained in:
70
crates/webidl-tests/array.js
Normal file
70
crates/webidl-tests/array.js
Normal file
@ -0,0 +1,70 @@
|
||||
const strictEqual = require('assert').strictEqual;
|
||||
|
||||
global.TestArrays = class {
|
||||
strings(x) {
|
||||
strictEqual(x, 'y');
|
||||
return 'x';
|
||||
}
|
||||
byteStrings(x) {
|
||||
strictEqual(x, 'yz');
|
||||
return 'xx';
|
||||
}
|
||||
usvStrings(x) {
|
||||
strictEqual(x, 'abc');
|
||||
return 'efg';
|
||||
}
|
||||
f32(x) {
|
||||
strictEqual(x.length, 2);
|
||||
strictEqual(x[0], 1);
|
||||
strictEqual(x[1], 2);
|
||||
return new Float32Array([3, 4, 5]);
|
||||
}
|
||||
f64(x) {
|
||||
strictEqual(x.length, 2);
|
||||
strictEqual(x[0], 1);
|
||||
strictEqual(x[1], 2);
|
||||
return new Float64Array([3, 4, 5]);
|
||||
}
|
||||
i8(x) {
|
||||
strictEqual(x.length, 2);
|
||||
strictEqual(x[0], 1);
|
||||
strictEqual(x[1], 2);
|
||||
return new Int8Array([3, 4, 5]);
|
||||
}
|
||||
i16(x) {
|
||||
strictEqual(x.length, 2);
|
||||
strictEqual(x[0], 1);
|
||||
strictEqual(x[1], 2);
|
||||
return new Int16Array([3, 4, 5]);
|
||||
}
|
||||
i32(x) {
|
||||
strictEqual(x.length, 2);
|
||||
strictEqual(x[0], 1);
|
||||
strictEqual(x[1], 2);
|
||||
return new Int32Array([3, 4, 5]);
|
||||
}
|
||||
u8(x) {
|
||||
strictEqual(x.length, 2);
|
||||
strictEqual(x[0], 1);
|
||||
strictEqual(x[1], 2);
|
||||
return new Uint8Array([3, 4, 5]);
|
||||
}
|
||||
u8Clamped(x) {
|
||||
strictEqual(x.length, 2);
|
||||
strictEqual(x[0], 1);
|
||||
strictEqual(x[1], 2);
|
||||
return new Uint8ClampedArray([3, 4, 5]);
|
||||
}
|
||||
u16(x) {
|
||||
strictEqual(x.length, 2);
|
||||
strictEqual(x[0], 1);
|
||||
strictEqual(x[1], 2);
|
||||
return new Uint16Array([3, 4, 5]);
|
||||
}
|
||||
u32(x) {
|
||||
strictEqual(x.length, 2);
|
||||
strictEqual(x[0], 1);
|
||||
strictEqual(x[1], 2);
|
||||
return new Uint32Array([3, 4, 5]);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user