mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2025-01-06 04:07:47 +03:00
22 lines
507 B
JavaScript
22 lines
507 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/);
|
|
};
|
|
|
|
const moveMoved = () => {
|
|
const pear = new wasm.Fruit('pear');
|
|
pear.name();
|
|
wasm.eat(pear);
|
|
assert.throws(() => wasm.eat(pear), /Attempt to use a moved value/);
|
|
};
|
|
|
|
exports.js_works = () => {
|
|
useMoved();
|
|
moveMoved();
|
|
};
|