Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 113dd2b

Browse filesBrowse files
stevekinneyMylesBorins
authored andcommitted
test: add basic WebAssembly test
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 <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
1 parent 6f805c6 commit 113dd2b
Copy full SHA for 113dd2b

File tree

Expand file treeCollapse file tree

3 files changed

+22
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+22
-0
lines changed
Open diff view settings
Collapse file

‎test/.eslintrc.yaml‎

Copy file name to clipboardExpand all lines: test/.eslintrc.yaml
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ rules:
1515
inspector-check: error
1616
## common module is mandatory in tests
1717
required-modules: [error, common]
18+
19+
# Global scoped methods and vars
20+
globals:
21+
WebAssembly: false
Collapse file

‎test/fixtures/test.wasm‎

Copy file name to clipboard
44 Bytes
Binary file not shown.
Collapse file

‎test/parallel/test-wasm-simple.js‎

Copy file name to clipboard
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
require('../common');
4+
5+
const assert = require('assert');
6+
const fixtures = require('../common/fixtures');
7+
8+
const buffer = fixtures.readSync('test.wasm');
9+
10+
assert.ok(WebAssembly.validate(buffer), 'Buffer should be valid WebAssembly');
11+
12+
WebAssembly.instantiate(buffer, {}).then((results) => {
13+
assert.strictEqual(
14+
results.instance.exports.addTwo(10, 20),
15+
30,
16+
'Exported function should add two numbers.',
17+
);
18+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.