2018-08-05 05:00:16 +03:00
|
|
|
const wasm = require('wasm-bindgen-test.js');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const useMoved = () => {
|
|
|
|
const apple = new wasm.Fruit('apple');
|
|
|
|
apple.name();
|
|
|
|
wasm.eat(apple);
|
2018-09-22 01:17:19 +03:00
|
|
|
assert.throws(() => apple.name(),
|
|
|
|
/Attempt to use a moved value|null pointer passed to rust/);
|
2018-08-05 05:00:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const moveMoved = () => {
|
|
|
|
const pear = new wasm.Fruit('pear');
|
|
|
|
pear.name();
|
|
|
|
wasm.eat(pear);
|
2018-09-22 01:17:19 +03:00
|
|
|
assert.throws(() => wasm.eat(pear),
|
|
|
|
/Attempt to use a moved value|null pointer passed to rust/);
|
2018-08-05 05:00:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.js_works = () => {
|
|
|
|
useMoved();
|
|
|
|
moveMoved();
|
|
|
|
};
|