Index: test/mjsunit/wasm/table.js |
diff --git a/test/mjsunit/wasm/table.js b/test/mjsunit/wasm/table.js |
index 1abc29664e37eafa26faf31addcd159f14d2beda..54847206229300f986b5bff2dc3633339d3716c6 100644 |
--- a/test/mjsunit/wasm/table.js |
+++ b/test/mjsunit/wasm/table.js |
@@ -55,17 +55,21 @@ function assertTableIsValid(table) { |
assertTableIsValid(table); |
assertEquals(1, table.length); |
assertEquals(null, table.get(0)); |
+ assertEquals(undefined, table[0]); |
table = new WebAssembly.Table({element: "anyfunc", initial: "2"}); |
assertTableIsValid(table); |
assertEquals(2, table.length); |
assertEquals(null, table.get(0)); |
assertEquals(null, table.get(1)); |
+ assertEquals(undefined, table[0]); |
+ assertEquals(undefined, table[1]); |
table = new WebAssembly.Table({element: "anyfunc", initial: {valueOf() { return "1" }}}); |
assertTableIsValid(table); |
assertEquals(1, table.length); |
assertEquals(null, table.get(0)); |
+ assertEquals(undefined, table[0]); |
table = new WebAssembly.Table({element: "anyfunc", initial: undefined}); |
assertTableIsValid(table); |
@@ -160,6 +164,7 @@ function assertTableIsValid(table) { |
assertSame(null, table.get(i)); |
assertSame(undefined, table.set(i, f)); |
assertSame(f, table.get(i)); |
+ assertSame(undefined, table[i]); |
} |
for (let i = 0; i < table.length; ++i) table.set(i, null); |
@@ -167,12 +172,14 @@ function assertTableIsValid(table) { |
assertSame(null, table.get(i)); |
assertSame(undefined, table.set(String(i), f)); |
assertSame(f, table.get(i)); |
+ assertSame(undefined, table[i]); |
} |
for (let key of [0.4, "", NaN, {}, [], () => {}]) { |
assertSame(undefined, table.set(0, null)); |
assertSame(undefined, table.set(key, f)); |
assertSame(f, table.get(0)); |
+ assertSame(undefined, table[key]); |
} |
for (let key of [-1, table.length, table.length * 10]) { |
@@ -190,6 +197,30 @@ function assertTableIsValid(table) { |
} |
})(); |
+ |
+(function TestIndexing() { |
+ let builder = new WasmModuleBuilder; |
+ builder.addExport("wasm", builder.addFunction("", kSig_v_v)); |
+ builder.addExport("host", builder.addImportWithModule("test", "f", kSig_v_v)); |
+ let {wasm, host} = builder.instantiate({test: {f() {}}}).exports; |
+ |
+ let table = new WebAssembly.Table({element: "anyfunc", initial: 10}); |
+ |
+ for (let f of [wasm, host, () => {}, 5, {}, ""]) { |
+ for (let i = 0; i < table.length; ++i) table[i] = f; |
+ for (let i = 0; i < table.length; ++i) { |
+ assertSame(null, table.get(i)); |
+ assertSame(f, table[i]); |
+ } |
+ |
+ for (let key of [0.4, "", NaN, {}, [], () => {}]) { |
+ assertSame(f, table[key] = f); |
+ assertSame(f, table[key]); |
+ assertSame(null, table.get(key)); |
+ } |
+ } |
+})(); |
+ |
(function TestGrow() { |
let builder = new WasmModuleBuilder; |
builder.addExport("wasm", builder.addFunction("", kSig_v_v)); |