test: Add basic WebAssembly test#16760
Conversation
cd894c3 to
f8bc445
Compare
|
ci: https://ci.nodejs.org/job/node-test-pull-request/11194/ /cc @nodejs/tsc what is the best practice for the licensing on this one? the WASM is generated from WAT code that came from an APACHE 2.0 project... we could potentially just write some new code for this but the base function is fairly straight forward. |
test/parallel/test-wasm-simple.js
Outdated
There was a problem hiding this comment.
Does this pass make lint? I think we have a rule against assert.equal (in favour of assert.strictEqual)
f8bc445 to
9538932
Compare
|
Isn't this just testing a strictly V8 feature? Wouldn't it be best to leave this to the V8 test suite? |
|
@mscdex It will also be testing |
test/parallel/test-wasm-simple.js
Outdated
There was a problem hiding this comment.
fixtures.readSync('simple.wasm') and then drop the fs module from the test?
9538932 to
70ab5a2
Compare
Tests a basic WebAssembly module that adds two numbers. wasm example from the WebAssembly/wabt repo licensed Apache 2.0. Refs: https://github.com/WebAssembly/wabt/blob/master/demo/wat2wasm/examples.js#L27-L32
70ab5a2 to
71036dd
Compare
|
|
||
| assert.ok(WebAssembly.validate(buffer), 'Buffer should be valid WebAssembly'); | ||
|
|
||
| WebAssembly.instantiate(buffer, {}).then((results) => { |
There was a problem hiding this comment.
Nit: common.mustCall around the then would be better.
There was a problem hiding this comment.
oh, right … we might also want common.crashOnUnhandledRejection() to make sure it really crashes when the promise gets rejected
edit: this test might be trickier than first thought 😄
| assert.strictEqual( | ||
| results.instance.exports.addTwo(10, 20), | ||
| 30, | ||
| 'Exported function should add two numbers.', |
There was a problem hiding this comment.
Suggestion: it would likely be better to either omit the message here or include the expected and actual values in the message.
There was a problem hiding this comment.
is this worth blocking on or should we land and fix in a follow up?
|
Landed in 74e7a4a, thanks for the PR & congratulations to being a Node contributor now! 🎉 |
Tests a basic WebAssembly module that adds two numbers. wasm example from the WebAssembly/wabt repo licensed Apache 2.0. Refs: https://github.com/WebAssembly/wabt/blob/49b7984544ddaf14d5e2f1ad9115dad7e9a2b299/demo/wat2wasm/examples.js#L27-L32 PR-URL: #16760 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
Tests a basic WebAssembly module that adds two numbers. wasm example from the WebAssembly/wabt repo licensed Apache 2.0. Refs: https://github.com/WebAssembly/wabt/blob/49b7984544ddaf14d5e2f1ad9115dad7e9a2b299/demo/wat2wasm/examples.js#L27-L32 PR-URL: #16760 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
Tests a basic WebAssembly module that adds two numbers. wasm example from the WebAssembly/wabt repo licensed Apache 2.0. Refs: https://github.com/WebAssembly/wabt/blob/49b7984544ddaf14d5e2f1ad9115dad7e9a2b299/demo/wat2wasm/examples.js#L27-L32 PR-URL: #16760 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
Tests a basic WebAssembly module that adds two numbers. wasm example from the WebAssembly/wabt repo licensed Apache 2.0. Refs: https://github.com/WebAssembly/wabt/blob/49b7984544ddaf14d5e2f1ad9115dad7e9a2b299/demo/wat2wasm/examples.js#L27-L32 PR-URL: #16760 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
Tests a basic WebAssembly module that adds two numbers.
wasm example from the WebAssembly/wabt repo licensed Apache 2.0.
Not sure if there are licensing concerns. Please let me know if we need to add anything else.
Refs: https://github.com/WebAssembly/wabt/blob/master/demo/wat2wasm/examples.js#L27-L32
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test