Sha256: a726a85f4805648d9e69c804a266bbedaed942228a1b3a46274a91bcb83eafe9

Contents?: true

Size: 1.23 KB

Versions: 30

Compression:

Stored size: 1.23 KB

Contents

const wasm = require('wasm-bindgen-test.js');
const assert = require('assert');

// NB: `wasm-pack` uses the presence of checks for moved values as a way to test
// whether it is correctly enabling `--debug` when configured to do so, so don't
// change this expected debug output without also updating `wasm-pack`'s tests.
const assertMovedPtrThrows = process.env.WASM_BINDGEN_NO_DEBUG == null
    ? f => assert.throws(f, /Attempt to use a moved value/)
    : f => assert.throws(f, /null pointer passed to rust/);

const useMoved = () => {
    const apple = new wasm.Fruit('apple');
    apple.name();
    wasm.eat(apple);
    assertMovedPtrThrows(() => apple.name());
};

const moveMoved = () => {
    const pear = new wasm.Fruit('pear');
    pear.name();
    wasm.eat(pear);
    assertMovedPtrThrows(() => wasm.eat(pear));
};

const methodMoved = () => {
    const quince = new wasm.Fruit('quince');
    quince.name();
    quince.rot();
    assertMovedPtrThrows(() => quince.rot());
};

exports.js_works = () => {
    useMoved();
    moveMoved();
    methodMoved();

    const a = new wasm.Fruit('a');
    a.prop;
    assertMovedPtrThrows(() => a.prop);
    const b = new wasm.Fruit('a');
    b.prop = 3;
    assertMovedPtrThrows(() => { b.prop = 4; });
};

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
wasmtime-23.0.2 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/validate_prt.js
wasmtime-22.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/validate_prt.js
wasmtime-21.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/validate_prt.js
wasmtime-20.0.2 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/validate_prt.js
wasmtime-20.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/validate_prt.js
wasmtime-18.0.3 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/validate_prt.js
wasmtime-17.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/validate_prt.js
wasmtime-17.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/validate_prt.js
wasmtime-16.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/validate_prt.js
wasmtime-15.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/validate_prt.js
wasmtime-15.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/validate_prt.js
wasmtime-14.0.4 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/validate_prt.js
wasmtime-14.0.3 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/validate_prt.js
wasmtime-14.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/validate_prt.js
wasmtime-14.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/validate_prt.js
wasmtime-13.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/validate_prt.js
wasmtime-12.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/validate_prt.js
wasmtime-12.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/validate_prt.js
wasmtime-11.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/validate_prt.js
wasmtime-10.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/validate_prt.js