Sha256: 0d7de3801257e18756a974bdd2950d2fb06755f7c0d1c681e03b56d97e828e34

Contents?: true

Size: 572 Bytes

Versions: 30

Compression:

Stored size: 572 Bytes

Contents

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

const ARGUMENT_NAMES = /([^\s,]+)/g;
const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;

// https://stackoverflow.com/q/1007981/210304
function getArgNames(func) {
    let fnStr = func.toString().replace(STRIP_COMMENTS, '');
    let result = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')).match(ARGUMENT_NAMES);
    return result === null ? [] : result;
}

exports.js_arg_names = () => {
    assert.deepEqual(getArgNames(wasm.fn_with_many_args), ['_a', '_b', '_c', '_d']);
};

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/arg_names.js
wasmtime-22.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/arg_names.js
wasmtime-21.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/arg_names.js
wasmtime-20.0.2 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/arg_names.js
wasmtime-20.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/arg_names.js
wasmtime-18.0.3 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/arg_names.js
wasmtime-17.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/arg_names.js
wasmtime-17.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/arg_names.js
wasmtime-16.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/arg_names.js
wasmtime-15.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/arg_names.js
wasmtime-15.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/tests/wasm/arg_names.js
wasmtime-14.0.4 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/arg_names.js
wasmtime-14.0.3 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/arg_names.js
wasmtime-14.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/arg_names.js
wasmtime-14.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/arg_names.js
wasmtime-13.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/arg_names.js
wasmtime-12.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/arg_names.js
wasmtime-12.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/arg_names.js
wasmtime-11.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/arg_names.js
wasmtime-10.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.87/tests/wasm/arg_names.js