Skip to content

Commit a526c8d

Browse files
committed
Add tests for static variables
1 parent 093fb85 commit a526c8d

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/test/run-make/wasm-export-all-symbols/bar.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22

33
#[no_mangle]
44
pub extern fn foo() {}
5+
6+
#[no_mangle]
7+
pub static FOO: u64 = 42;

src/test/run-make/wasm-export-all-symbols/verify.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,31 @@ let list = WebAssembly.Module.exports(m);
88
console.log('exports', list);
99

1010
const my_exports = {};
11-
let nexports = 0;
11+
let nexports_fn = 0;
12+
let nexports_global = 0;
1213
for (const entry of list) {
13-
if (entry.kind !== 'function')
14-
continue;
15-
my_exports[entry.name] = true;
16-
nexports += 1;
14+
if (entry.kind == 'function'){
15+
nexports_fn += 1;
16+
}
17+
if (entry.kind == 'global'){
18+
nexports_global += 1;
19+
}
20+
my_exports[entry.name] = true;
1721
}
1822

1923
if (my_exports.foo === undefined)
2024
throw new Error("`foo` wasn't defined");
2125

26+
if (my_exports.FOO === undefined)
27+
throw new Error("`FOO` wasn't defined");
28+
2229
if (my_exports.main === undefined) {
23-
if (nexports != 1)
30+
if (nexports_fn != 1)
2431
throw new Error("should only have one function export");
2532
} else {
26-
if (nexports != 2)
33+
if (nexports_fn != 2)
2734
throw new Error("should only have two function exports");
2835
}
36+
37+
if (nexports_global != 1)
38+
throw new Error("should only have one static export");

0 commit comments

Comments
 (0)