| 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 37ab7dd2f5be11a95de9f3040994c14995a877b2..0da781451efde4736ecbbcbdf9153190d051e670 100644
|
| --- a/test/unittests/wasm/function-body-decoder-unittest.cc
|
| +++ b/test/unittests/wasm/function-body-decoder-unittest.cc
|
| @@ -104,29 +104,11 @@
|
| local_decls.AddLocals(count, type);
|
| }
|
|
|
| - void PrepareBytecode(const byte** startp, const byte** endp) {
|
| - const byte* start = *startp;
|
| - const byte* end = *endp;
|
| - 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;
|
| -
|
| - *startp = buffer;
|
| - *endp = buffer + total_size;
|
| - }
|
| -
|
| // Prepends local variable declarations and renders nice error messages for
|
| // verification failures.
|
| void Verify(ErrorCode expected, FunctionSig* sig, const byte* start,
|
| const byte* end) {
|
| - PrepareBytecode(&start, &end);
|
| -
|
| + local_decls.Prepend(zone(), &start, &end);
|
| // Verify the code.
|
| DecodeResult result = VerifyWasmCode(
|
| zone()->allocator(), module == nullptr ? nullptr : module->module, sig,
|
| @@ -479,7 +461,11 @@
|
| }
|
|
|
| TEST_F(FunctionBodyDecoderTest, Block0_end) {
|
| - EXPECT_FAILURE(v_v, WASM_EMPTY_BLOCK, kExprEnd);
|
| + EXPECT_VERIFIES(v_v, WASM_EMPTY_BLOCK, kExprEnd);
|
| +}
|
| +
|
| +TEST_F(FunctionBodyDecoderTest, Block0_end_end) {
|
| + EXPECT_FAILURE(v_v, WASM_EMPTY_BLOCK, kExprEnd, kExprEnd);
|
| }
|
|
|
| TEST_F(FunctionBodyDecoderTest, Block1) {
|
| @@ -732,13 +718,14 @@
|
| 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);
|
| }
|
|
|
|
|