From f1cba8e8afa9c2ef8dc4cfe8a51e2807e024e45f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Sun, 23 Jun 2019 22:50:42 +0200 Subject: [PATCH] test: Add unit tests for PC --- test/unittests/execution_test.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unittests/execution_test.cpp b/test/unittests/execution_test.cpp index 1f302e37e3..2554970271 100644 --- a/test/unittests/execution_test.cpp +++ b/test/unittests/execution_test.cpp @@ -230,6 +230,20 @@ TEST_F(execution, bad_jumpdest) } } +TEST_F(execution, pc) +{ + const auto code = OP_CALLDATASIZE + push(9) + OP_JUMPI + push(12) + OP_PC + OP_SWAP1 + OP_JUMP + + OP_JUMPDEST + OP_GAS + OP_PC + OP_JUMPDEST + ret_top(); + + execute(code, ""); + EXPECT_STATUS(EVMC_SUCCESS); + EXPECT_OUTPUT_INT(6); + + execute(code, "ff"); + EXPECT_STATUS(EVMC_SUCCESS); + EXPECT_OUTPUT_INT(11); +} + TEST_F(execution, byte) { std::string s;