File: exec.tjs

package info (click to toggle)
node-webassemblyjs 1.11.0%2Bdfsg%2B~cs10.10.16-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,040 kB
  • sloc: javascript: 28,630; makefile: 84; sh: 42; ansic: 16
file content (22 lines) | stat: -rw-r--r-- 500 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
it("should import the memory", () => {
  const mem = new WebAssembly.Memory({ initial: 100 });

  // Fill memory
  const i32 = new Uint32Array(mem.buffer);
  i32[0] = 10;

  const importObject = {
    env: { mem }
  };

  return WebAssembly.instantiate(wasmmodule, importObject).then(m => {
    const get = m.instance.exports.get;

    assert.typeOf(get(), "number");
    assert.notEqual(get(), 0); // default value
    assert.equal(get(), 10);

    i32[0] = 1;
    assert.equal(get(), 1);
  });
});