Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: test/unittests/wasm/ast-decoder-unittest.cc

Issue 2587143002: [wasm] Add iterators for opcodes or offsets of one function (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « src/wasm/wasm-objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698