| 1 |
const wasm = require('wasm-bindgen-test.js'); |
| 2 |
const assert = require('assert'); |
| 3 |
|
| 4 |
exports.pass_string_vec = () => { |
| 5 |
assert.deepStrictEqual( |
| 6 |
wasm.consume_string_vec(["hello", "world"]), |
| 7 |
["hello", "world", "Hello from Rust!"], |
| 8 |
); |
| 9 |
assert.deepStrictEqual( |
| 10 |
wasm.consume_optional_string_vec(["hello", "world"]), |
| 11 |
["hello", "world", "Hello from Rust!"], |
| 12 |
); |
| 13 |
assert.strictEqual(wasm.consume_optional_string_vec(undefined), undefined); |
| 14 |
}; |
| 15 |
|
| 16 |
exports.pass_invalid_string_vec = () => { |
| 17 |
try { |
| 18 |
wasm.consume_string_vec([42]); |
| 19 |
} catch (e) { |
| 20 |
assert.match(e.message, /array contains a value of the wrong type/) |
| 21 |
assert.match(e.stack, /consume_string_vec/) |
| 22 |
} |
| 23 |
}; |