Index: test/unittests/wasm/ast-decoder-unittest.cc |
diff --git a/test/unittests/wasm/ast-decoder-unittest.cc b/test/unittests/wasm/ast-decoder-unittest.cc |
index 0861e00be1d77732941f418901c868387d8b7170..872eef99f84fd2fd560887f5bc35e4c43c5af590 100644 |
--- a/test/unittests/wasm/ast-decoder-unittest.cc |
+++ b/test/unittests/wasm/ast-decoder-unittest.cc |
@@ -2669,7 +2669,7 @@ TEST_F(BytecodeIteratorTest, SimpleForeach) { |
WasmOpcode expected[] = {kExprI8Const, kExprIf, kExprI8Const, |
kExprElse, kExprI8Const, kExprEnd}; |
size_t pos = 0; |
- for (WasmOpcode opcode : iter) { |
+ for (WasmOpcode opcode : iter.opcodes()) { |
if (pos >= arraysize(expected)) { |
EXPECT_TRUE(false); |
break; |
@@ -2685,20 +2685,40 @@ TEST_F(BytecodeIteratorTest, ForeachTwice) { |
int count = 0; |
count = 0; |
- for (WasmOpcode opcode : iter) { |
+ for (WasmOpcode opcode : iter.opcodes()) { |
USE(opcode); |
count++; |
} |
EXPECT_EQ(6, count); |
count = 0; |
- for (WasmOpcode opcode : iter) { |
+ for (WasmOpcode opcode : iter.opcodes()) { |
USE(opcode); |
count++; |
} |
EXPECT_EQ(6, count); |
} |
+TEST_F(BytecodeIteratorTest, ForeachOffset) { |
+ byte code[] = {WASM_IF_ELSE(WASM_ZERO, WASM_ZERO, WASM_ZERO)}; |
+ BytecodeIterator iter(code, code + sizeof(code)); |
+ int count = 0; |
+ |
+ count = 0; |
+ for (auto offset : iter.offsets()) { |
+ USE(offset); |
+ count++; |
+ } |
+ EXPECT_EQ(6, count); |
+ |
+ count = 0; |
+ for (auto offset : iter.offsets()) { |
+ USE(offset); |
+ count++; |
+ } |
+ EXPECT_EQ(6, count); |
+} |
+ |
TEST_F(BytecodeIteratorTest, WithAstDecls) { |
byte code[] = {1, 1, kLocalI32, WASM_I8(9), WASM_I8(11)}; |
AstLocalDecls decls(zone()); |