mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2025-01-05 19:53:55 +03:00
ab3688d01a
In non-debug mode Rust is already checking these pointers, so let's only generate the relevant code in debug mode.
24 lines
575 B
JavaScript
24 lines
575 B
JavaScript
const wasm = require('wasm-bindgen-test.js');
|
|
const assert = require('assert');
|
|
|
|
const useMoved = () => {
|
|
const apple = new wasm.Fruit('apple');
|
|
apple.name();
|
|
wasm.eat(apple);
|
|
assert.throws(() => apple.name(),
|
|
/Attempt to use a moved value|null pointer passed to rust/);
|
|
};
|
|
|
|
const moveMoved = () => {
|
|
const pear = new wasm.Fruit('pear');
|
|
pear.name();
|
|
wasm.eat(pear);
|
|
assert.throws(() => wasm.eat(pear),
|
|
/Attempt to use a moved value|null pointer passed to rust/);
|
|
};
|
|
|
|
exports.js_works = () => {
|
|
useMoved();
|
|
moveMoved();
|
|
};
|