Debian Codegraph @

.cargo/vendor/wasm-bindgen/tests/wasm/option.js

raw
1 const wasm = require('wasm-bindgen-test.js');
2 const assert = require('assert');
3
4 class MyType {
5 }
6
7 exports.MyType = MyType;
8
9 exports.take_none_byval = x => {
10 assert.strictEqual(x, undefined);
11 };
12 exports.take_some_byval = x => {
13 assert.ok(x !== null && x !== undefined);
14 assert.ok(x instanceof MyType);
15 };
16 exports.return_undef_byval = () => undefined;
17 exports.return_null_byval = () => null;
18 exports.return_some_byval = () => new MyType();
19
20 exports.test_option_values = () => {
21 wasm.rust_take_none_byval(null);
22 wasm.rust_take_none_byval(undefined);
23 wasm.rust_take_some_byval(new MyType());
24 assert.strictEqual(wasm.rust_return_none_byval(), undefined);
25 const x = wasm.rust_return_some_byval();
26 assert.ok(x !== null && x !== undefined);
27 assert.ok(x instanceof MyType);
28 };