Skip to content

Commit 2e89dc5

Browse files
authored
Fix js-api tests (WebAssembly#87)
This fixes four things in the JS-API tests: 1. Pass BigInt for i64 WebAssembly.Table and WebAssembly.Memory constructors. 2. Use reference types for tables (would throw a TypeError otherwise). 3. Overwrite 'toString' instead of 'valueOf' for the 'index' property which is a string. 4. 'index' is read after 'element' and before 'initial' in Table construction.
1 parent 1fca55a commit 2e89dc5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

test/js-api/memory/constructor.any.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ test(() => {
153153
}, "Memory with i32 index constructor");
154154

155155
test(() => {
156-
const argument = { "initial": 1, "index": "i64" };
156+
const argument = { "initial": 1n, "index": "i64" };
157157
const memory = new WebAssembly.Memory(argument);
158158
assert_Memory(memory, { "size": 1, "index": "i64" });
159159
}, "Memory with i64 index constructor");

test/js-api/table/constructor.any.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ test(() => {
161161
get index() {
162162
order.push("index");
163163
return {
164-
valueOf() {
165-
order.push("index valueOf");
164+
toString() {
165+
order.push("index toString");
166166
return "i32";
167167
},
168168
};
@@ -172,12 +172,12 @@ test(() => {
172172
assert_array_equals(order, [
173173
"element",
174174
"element toString",
175+
"index",
176+
"index toString",
175177
"initial",
176178
"initial valueOf",
177179
"maximum",
178180
"maximum valueOf",
179-
"index",
180-
"index valueOf",
181181
]);
182182
}, "Order of evaluation for descriptor");
183183

@@ -220,22 +220,22 @@ test(() => {
220220
}, "initialize anyfunc table with a bad default value");
221221

222222
test(() => {
223-
const argument = { "element": "i32", "initial": 3, "index": "i32" };
223+
const argument = { "element": "anyfunc", "initial": 3, "index": "i32" };
224224
const table = new WebAssembly.Table(argument);
225225
// Once this is merged with the type reflection proposal we should check the
226226
// index type of `table`.
227227
assert_equals(table.length, 3);
228228
}, "Table with i32 index constructor");
229229

230230
test(() => {
231-
const argument = { "element": "i32", "initial": 3, "index": "i64" };
231+
const argument = { "element": "anyfunc", "initial": 3n, "index": "i64" };
232232
const table = new WebAssembly.Table(argument);
233233
// Once this is merged with the type reflection proposal we should check the
234234
// index type of `table`.
235235
assert_equals(table.length, 3);
236236
}, "Table with i64 index constructor");
237237

238238
test(() => {
239-
const argument = { "element": "i32", "initial": 3, "index": "unknown" };
239+
const argument = { "element": "anyfunc", "initial": 3, "index": "unknown" };
240240
assert_throws_js(TypeError, () => new WebAssembly.Table(argument));
241241
}, "Unknown table index");

0 commit comments

Comments
 (0)