Index: test/unittests/wasm/function-body-decoder-unittest.cc |
diff --git a/test/unittests/wasm/function-body-decoder-unittest.cc b/test/unittests/wasm/function-body-decoder-unittest.cc |
index 0da781451efde4736ecbbcbdf9153190d051e670..0f7476b24df49947f54fb28f437d930e20cfebf3 100644 |
--- a/test/unittests/wasm/function-body-decoder-unittest.cc |
+++ b/test/unittests/wasm/function-body-decoder-unittest.cc |
@@ -108,7 +108,19 @@ |
// verification failures. |
void Verify(ErrorCode expected, FunctionSig* sig, const byte* start, |
const byte* end) { |
- local_decls.Prepend(zone(), &start, &end); |
+ size_t locals_size = local_decls.Size(); |
+ size_t total_size = end - start + locals_size + 1; |
+ byte* buffer = static_cast<byte*>(zone()->New(total_size)); |
+ // Prepend the local decls to the code. |
+ local_decls.Emit(buffer); |
+ // Emit the code. |
+ memcpy(buffer + locals_size, start, end - start); |
+ // Append an extra end opcode. |
+ buffer[total_size - 1] = kExprEnd; |
+ |
+ start = buffer; |
+ end = buffer + total_size; |
+ |
// Verify the code. |
DecodeResult result = VerifyWasmCode( |
zone()->allocator(), module == nullptr ? nullptr : module->module, sig, |
@@ -461,11 +473,7 @@ |
} |
TEST_F(FunctionBodyDecoderTest, Block0_end) { |
- EXPECT_VERIFIES(v_v, WASM_EMPTY_BLOCK, kExprEnd); |
-} |
- |
-TEST_F(FunctionBodyDecoderTest, Block0_end_end) { |
- EXPECT_FAILURE(v_v, WASM_EMPTY_BLOCK, kExprEnd, kExprEnd); |
+ EXPECT_FAILURE(v_v, WASM_EMPTY_BLOCK, kExprEnd); |
} |
TEST_F(FunctionBodyDecoderTest, Block1) { |
@@ -718,14 +726,13 @@ |
EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP)); |
} |
+TEST_F(FunctionBodyDecoderTest, If_end) { |
+ static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP, kExprEnd}; |
+ EXPECT_VERIFIES_C(v_i, code); |
+} |
+ |
TEST_F(FunctionBodyDecoderTest, If_end_end) { |
static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP, kExprEnd, kExprEnd}; |
- EXPECT_VERIFIES_C(v_i, code); |
-} |
- |
-TEST_F(FunctionBodyDecoderTest, If_end_end_end) { |
- static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP, |
- kExprEnd, kExprEnd, kExprEnd}; |
EXPECT_FAILURE_C(v_i, code); |
} |