From adce9ca812bd0c8a79e1bc924ad70773bb9006b1 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 16 May 2018 15:52:24 +0200 Subject: Tidy up tests to always have closing braces on the proper line --- test/libsolidity/SolidityExpressionCompiler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/libsolidity/SolidityExpressionCompiler.cpp') diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 90d8265c..ad26ce6b 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -249,7 +249,8 @@ BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination) { var x = 1 finney; } - })"; + } + )"; bytes code = compileFirstExpression(sourceCode); bytes expectation({byte(Instruction::PUSH7), 0x3, 0x8d, 0x7e, 0xa4, 0xc6, 0x80, 0x00}); -- cgit v1.2.3 From 98c9ca257568e8f281a5d8857a45ef2c8aef2c77 Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Wed, 30 May 2018 17:02:47 -0400 Subject: Update tests for strict address literals --- test/libsolidity/SolidityExpressionCompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/libsolidity/SolidityExpressionCompiler.cpp') diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index ad26ce6b..ce8f4fe4 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -490,7 +490,7 @@ BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals) // have been applied char const* sourceCode = R"( contract test { - function f() { var x = (0xffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; } + function f() { var x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; } } )"; bytes code = compileFirstExpression(sourceCode); -- cgit v1.2.3 From 12c4eb769762d55a71ba05cf1b74b99797026f51 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Wed, 27 Jun 2018 13:22:33 +0200 Subject: Updates compiled unit tests to new constructor syntax. --- test/libsolidity/SolidityExpressionCompiler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/libsolidity/SolidityExpressionCompiler.cpp') diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index ce8f4fe4..5d5fb218 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -215,7 +215,7 @@ BOOST_AUTO_TEST_CASE(int_with_wei_ether_subdenomination) { char const* sourceCode = R"( contract test { - function test () { + constructor() { var x = 1 wei; } } @@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(int_with_szabo_ether_subdenomination) { char const* sourceCode = R"( contract test { - function test () { + constructor() { var x = 1 szabo; } } @@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination) { char const* sourceCode = R"( contract test { - function test () + constructor() { var x = 1 finney; } @@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(int_with_ether_ether_subdenomination) { char const* sourceCode = R"( contract test { - function test () { + constructor() { var x = 1 ether; } } -- cgit v1.2.3 From e251cdcf47667ad3e7c88446d8b26cb3ae1bd0f2 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Thu, 28 Jun 2018 15:19:53 +0200 Subject: test: ensure compiled tests do not use var-keyword in preparation of var-keyword removal --- test/libsolidity/SolidityExpressionCompiler.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'test/libsolidity/SolidityExpressionCompiler.cpp') diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 5d5fb218..2668dfdf 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(literal_true) { char const* sourceCode = R"( contract test { - function f() { var x = true; } + function f() { bool x = true; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(literal_false) { char const* sourceCode = R"( contract test { - function f() { var x = false; } + function f() { bool x = false; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -201,7 +201,7 @@ BOOST_AUTO_TEST_CASE(int_literal) { char const* sourceCode = R"( contract test { - function f() { var x = 0x12345678901234567890; } + function f() { uint x = 0x12345678901234567890; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(int_with_wei_ether_subdenomination) char const* sourceCode = R"( contract test { constructor() { - var x = 1 wei; + uint x = 1 wei; } } )"; @@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE(int_with_szabo_ether_subdenomination) { char const* sourceCode = R"( contract test { - constructor() { - var x = 1 szabo; + function test () { + uint x = 1 szabo; } } )"; @@ -247,7 +247,7 @@ BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination) contract test { constructor() { - var x = 1 finney; + uint x = 1 finney; } } )"; @@ -262,7 +262,7 @@ BOOST_AUTO_TEST_CASE(int_with_ether_ether_subdenomination) char const* sourceCode = R"( contract test { constructor() { - var x = 1 ether; + uint x = 1 ether; } } )"; @@ -276,7 +276,7 @@ BOOST_AUTO_TEST_CASE(comparison) { char const* sourceCode = R"( contract test { - function f() { var x = (0x10aa < 0x11aa) != true; } + function f() { bool x = (0x10aa < 0x11aa) != true; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -294,7 +294,7 @@ BOOST_AUTO_TEST_CASE(short_circuiting) { char const* sourceCode = R"( contract test { - function f() { var x = true != (4 <= 8 + 10 || 9 != 2); } + function f() { bool x = true != (4 <= 8 + 10 || 9 != 2); } } )"; bytes code = compileFirstExpression(sourceCode); @@ -490,7 +490,7 @@ BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals) // have been applied char const* sourceCode = R"( contract test { - function f() { var x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; } + function f() { uint8 x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; } } )"; bytes code = compileFirstExpression(sourceCode); -- cgit v1.2.3 From 8202d512e0bd4e6b4a19ed483afff288514e75bd Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Wed, 4 Jul 2018 11:42:05 +0200 Subject: Enforcing error on msg.gas and block.blockhash() --- test/libsolidity/SolidityExpressionCompiler.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'test/libsolidity/SolidityExpressionCompiler.cpp') diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 2668dfdf..2ea0247e 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -522,33 +522,18 @@ BOOST_AUTO_TEST_CASE(blockhash) BOOST_AUTO_TEST_CASE(gas_left) { char const* sourceCode = R"( - contract test { - function f() returns (uint256 val) { - return msg.gas; - } - } - )"; - bytes code = compileFirstExpression( - sourceCode, {}, {}, - {make_shared("msg", make_shared(MagicType::Kind::Message))} - ); - - bytes expectation({byte(Instruction::GAS)}); - BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); - - sourceCode = R"( contract test { function f() returns (uint256 val) { return gasleft(); } } )"; - code = compileFirstExpression( + bytes code = compileFirstExpression( sourceCode, {}, {}, {make_shared("gasleft", make_shared(strings(), strings{"uint256"}, FunctionType::Kind::GasLeft))} ); - expectation = bytes({byte(Instruction::GAS)}); + bytes expectation = bytes({byte(Instruction::GAS)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } -- cgit v1.2.3 From fc2b006fe1266339776820ee0dd2c756bc9766d5 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Fri, 29 Jun 2018 16:52:41 +0200 Subject: Updates unit test to specify visibility. --- test/libsolidity/SolidityExpressionCompiler.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/libsolidity/SolidityExpressionCompiler.cpp') diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 2ea0247e..949045ea 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(literal_true) { char const* sourceCode = R"( contract test { - function f() { bool x = true; } + function f() public { bool x = true; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -384,7 +384,7 @@ BOOST_AUTO_TEST_CASE(unary_inc_dec) { char const* sourceCode = R"( contract test { - function f(uint a) returns (uint x) { x = --a ^ (a-- ^ (++a ^ a++)); } + function f(uint a) public returns (uint x) { x = --a ^ (a-- ^ (++a ^ a++)); } } )"; bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "x"}}); @@ -509,9 +509,9 @@ BOOST_AUTO_TEST_CASE(blockhash) } )"; - auto blockhashFun = make_shared(strings{"uint256"}, strings{"bytes32"}, + auto blockhashFun = make_shared(strings{"uint256"}, strings{"bytes32"}, FunctionType::Kind::BlockHash, false, StateMutability::View); - + bytes code = compileFirstExpression(sourceCode, {}, {}, {make_shared("blockhash", blockhashFun)}); bytes expectation({byte(Instruction::PUSH1), 0x03, @@ -523,7 +523,7 @@ BOOST_AUTO_TEST_CASE(gas_left) { char const* sourceCode = R"( contract test { - function f() returns (uint256 val) { + function f() public returns (uint256 val) { return gasleft(); } } -- cgit v1.2.3 From 4116704442aff035acb5b707c6b211ac1f5524fe Mon Sep 17 00:00:00 2001 From: Cryptomental Date: Tue, 10 Jul 2018 09:18:19 +0200 Subject: test: Fix typos. Fix typos using codespell. Refs: #4442 --- test/libsolidity/SolidityExpressionCompiler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/libsolidity/SolidityExpressionCompiler.cpp') diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 949045ea..26b7914f 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -77,7 +77,7 @@ Declaration const& resolveDeclaration( ) { ASTNode const* scope = &_sourceUnit; - // bracers are required, cause msvc couldnt handle this macro in for statement + // bracers are required, cause msvc couldn't handle this macro in for statement for (string const& namePart: _namespacedName) { auto declarations = _resolver.resolveName(namePart, scope); @@ -319,7 +319,7 @@ BOOST_AUTO_TEST_CASE(short_circuiting) BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } -BOOST_AUTO_TEST_CASE(arithmetics) +BOOST_AUTO_TEST_CASE(arithmetic) { char const* sourceCode = R"( contract test { -- cgit v1.2.3 From ab0de38f16a9eff13ee5a32a3408b890d87941f6 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 7 Nov 2018 12:04:46 +0100 Subject: Eliminate `byte`-typedef and use `uint8_t` in all their places instead. This change is made to (easily) be forward compatible with future C++ standards, in order to allow compiling the code with newer standards at some point in the future. * Removed the `using byte = uint8_t;` line from Common.h * Mechanically change all uses of `byte` to `uint8_t`. Tested with GCC 7.3 in C++11/14/17 modes :-) --- test/libsolidity/SolidityExpressionCompiler.cpp | 228 ++++++++++++------------ 1 file changed, 114 insertions(+), 114 deletions(-) (limited to 'test/libsolidity/SolidityExpressionCompiler.cpp') diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 26b7914f..309cbf0b 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -180,7 +180,7 @@ BOOST_AUTO_TEST_CASE(literal_true) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(Instruction::PUSH1), 0x1}); + bytes expectation({uint8_t(Instruction::PUSH1), 0x1}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(literal_false) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(Instruction::PUSH1), 0x0}); + bytes expectation({uint8_t(Instruction::PUSH1), 0x0}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE(int_literal) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(Instruction::PUSH10), 0x12, 0x34, 0x56, 0x78, 0x90, + bytes expectation({uint8_t(Instruction::PUSH10), 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -222,7 +222,7 @@ BOOST_AUTO_TEST_CASE(int_with_wei_ether_subdenomination) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(Instruction::PUSH1), 0x1}); + bytes expectation({uint8_t(Instruction::PUSH1), 0x1}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -237,7 +237,7 @@ BOOST_AUTO_TEST_CASE(int_with_szabo_ether_subdenomination) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(Instruction::PUSH5), 0xe8, 0xd4, 0xa5, 0x10, 0x00}); + bytes expectation({uint8_t(Instruction::PUSH5), 0xe8, 0xd4, 0xa5, 0x10, 0x00}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -253,7 +253,7 @@ BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(Instruction::PUSH7), 0x3, 0x8d, 0x7e, 0xa4, 0xc6, 0x80, 0x00}); + bytes expectation({uint8_t(Instruction::PUSH7), 0x3, 0x8d, 0x7e, 0xa4, 0xc6, 0x80, 0x00}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -268,7 +268,7 @@ BOOST_AUTO_TEST_CASE(int_with_ether_ether_subdenomination) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(Instruction::PUSH8), 0xd, 0xe0, 0xb6, 0xb3, 0xa7, 0x64, 0x00, 0x00}); + bytes expectation({uint8_t(Instruction::PUSH8), 0xd, 0xe0, 0xb6, 0xb3, 0xa7, 0x64, 0x00, 0x00}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -281,12 +281,12 @@ BOOST_AUTO_TEST_CASE(comparison) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(Instruction::PUSH1), 0x1, byte(Instruction::ISZERO), byte(Instruction::ISZERO), - byte(Instruction::PUSH2), 0x11, 0xaa, - byte(Instruction::PUSH2), 0x10, 0xaa, - byte(Instruction::LT), byte(Instruction::ISZERO), byte(Instruction::ISZERO), - byte(Instruction::EQ), - byte(Instruction::ISZERO)}); + bytes expectation({uint8_t(Instruction::PUSH1), 0x1, uint8_t(Instruction::ISZERO), uint8_t(Instruction::ISZERO), + uint8_t(Instruction::PUSH2), 0x11, 0xaa, + uint8_t(Instruction::PUSH2), 0x10, 0xaa, + uint8_t(Instruction::LT), uint8_t(Instruction::ISZERO), uint8_t(Instruction::ISZERO), + uint8_t(Instruction::EQ), + uint8_t(Instruction::ISZERO)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -299,23 +299,23 @@ BOOST_AUTO_TEST_CASE(short_circuiting) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(Instruction::PUSH1), 0x12, // 8 + 10 - byte(Instruction::PUSH1), 0x4, - byte(Instruction::GT), - byte(Instruction::ISZERO), // after this we have 4 <= 8 + 10 - byte(Instruction::DUP1), - byte(Instruction::PUSH1), 0x11, - byte(Instruction::JUMPI), // short-circuit if it is true - byte(Instruction::POP), - byte(Instruction::PUSH1), 0x2, - byte(Instruction::PUSH1), 0x9, - byte(Instruction::EQ), - byte(Instruction::ISZERO), // after this we have 9 != 2 - byte(Instruction::JUMPDEST), - byte(Instruction::ISZERO), byte(Instruction::ISZERO), - byte(Instruction::PUSH1), 0x1, byte(Instruction::ISZERO), byte(Instruction::ISZERO), - byte(Instruction::EQ), - byte(Instruction::ISZERO)}); + bytes expectation({uint8_t(Instruction::PUSH1), 0x12, // 8 + 10 + uint8_t(Instruction::PUSH1), 0x4, + uint8_t(Instruction::GT), + uint8_t(Instruction::ISZERO), // after this we have 4 <= 8 + 10 + uint8_t(Instruction::DUP1), + uint8_t(Instruction::PUSH1), 0x11, + uint8_t(Instruction::JUMPI), // short-circuit if it is true + uint8_t(Instruction::POP), + uint8_t(Instruction::PUSH1), 0x2, + uint8_t(Instruction::PUSH1), 0x9, + uint8_t(Instruction::EQ), + uint8_t(Instruction::ISZERO), // after this we have 9 != 2 + uint8_t(Instruction::JUMPDEST), + uint8_t(Instruction::ISZERO), uint8_t(Instruction::ISZERO), + uint8_t(Instruction::PUSH1), 0x1, uint8_t(Instruction::ISZERO), uint8_t(Instruction::ISZERO), + uint8_t(Instruction::EQ), + uint8_t(Instruction::ISZERO)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -327,37 +327,37 @@ BOOST_AUTO_TEST_CASE(arithmetic) } )"; bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); - bytes expectation({byte(Instruction::PUSH1), 0x1, - byte(Instruction::PUSH1), 0x2, - byte(Instruction::PUSH1), 0x3, - byte(Instruction::PUSH1), 0x4, - byte(Instruction::PUSH1), 0x5, - byte(Instruction::PUSH1), 0x6, - byte(Instruction::PUSH1), 0x7, - byte(Instruction::PUSH1), 0x8, - byte(Instruction::DUP9), - byte(Instruction::XOR), - byte(Instruction::AND), - byte(Instruction::OR), - byte(Instruction::SUB), - byte(Instruction::ADD), - byte(Instruction::DUP2), - byte(Instruction::ISZERO), - byte(Instruction::ISZERO), - byte(Instruction::PUSH1), 0x1d, - byte(Instruction::JUMPI), - byte(Instruction::INVALID), - byte(Instruction::JUMPDEST), - byte(Instruction::MOD), - byte(Instruction::DUP2), - byte(Instruction::ISZERO), - byte(Instruction::ISZERO), - byte(Instruction::PUSH1), 0x26, - byte(Instruction::JUMPI), - byte(Instruction::INVALID), - byte(Instruction::JUMPDEST), - byte(Instruction::DIV), - byte(Instruction::MUL)}); + bytes expectation({uint8_t(Instruction::PUSH1), 0x1, + uint8_t(Instruction::PUSH1), 0x2, + uint8_t(Instruction::PUSH1), 0x3, + uint8_t(Instruction::PUSH1), 0x4, + uint8_t(Instruction::PUSH1), 0x5, + uint8_t(Instruction::PUSH1), 0x6, + uint8_t(Instruction::PUSH1), 0x7, + uint8_t(Instruction::PUSH1), 0x8, + uint8_t(Instruction::DUP9), + uint8_t(Instruction::XOR), + uint8_t(Instruction::AND), + uint8_t(Instruction::OR), + uint8_t(Instruction::SUB), + uint8_t(Instruction::ADD), + uint8_t(Instruction::DUP2), + uint8_t(Instruction::ISZERO), + uint8_t(Instruction::ISZERO), + uint8_t(Instruction::PUSH1), 0x1d, + uint8_t(Instruction::JUMPI), + uint8_t(Instruction::INVALID), + uint8_t(Instruction::JUMPDEST), + uint8_t(Instruction::MOD), + uint8_t(Instruction::DUP2), + uint8_t(Instruction::ISZERO), + uint8_t(Instruction::ISZERO), + uint8_t(Instruction::PUSH1), 0x26, + uint8_t(Instruction::JUMPI), + uint8_t(Instruction::INVALID), + uint8_t(Instruction::JUMPDEST), + uint8_t(Instruction::DIV), + uint8_t(Instruction::MUL)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -370,13 +370,13 @@ BOOST_AUTO_TEST_CASE(unary_operators) )"; bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); - bytes expectation({byte(Instruction::PUSH1), 0x2, - byte(Instruction::DUP2), - byte(Instruction::PUSH1), 0x0, - byte(Instruction::SUB), - byte(Instruction::NOT), - byte(Instruction::EQ), - byte(Instruction::ISZERO)}); + bytes expectation({uint8_t(Instruction::PUSH1), 0x2, + uint8_t(Instruction::DUP2), + uint8_t(Instruction::PUSH1), 0x0, + uint8_t(Instruction::SUB), + uint8_t(Instruction::NOT), + uint8_t(Instruction::EQ), + uint8_t(Instruction::ISZERO)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -390,47 +390,47 @@ BOOST_AUTO_TEST_CASE(unary_inc_dec) bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "x"}}); // Stack: a, x - bytes expectation({byte(Instruction::DUP2), - byte(Instruction::DUP1), - byte(Instruction::PUSH1), 0x1, - byte(Instruction::ADD), + bytes expectation({uint8_t(Instruction::DUP2), + uint8_t(Instruction::DUP1), + uint8_t(Instruction::PUSH1), 0x1, + uint8_t(Instruction::ADD), // Stack here: a x a (a+1) - byte(Instruction::SWAP3), - byte(Instruction::POP), // first ++ + uint8_t(Instruction::SWAP3), + uint8_t(Instruction::POP), // first ++ // Stack here: (a+1) x a - byte(Instruction::DUP3), - byte(Instruction::PUSH1), 0x1, - byte(Instruction::ADD), + uint8_t(Instruction::DUP3), + uint8_t(Instruction::PUSH1), 0x1, + uint8_t(Instruction::ADD), // Stack here: (a+1) x a (a+2) - byte(Instruction::SWAP3), - byte(Instruction::POP), + uint8_t(Instruction::SWAP3), + uint8_t(Instruction::POP), // Stack here: (a+2) x a - byte(Instruction::DUP3), // second ++ - byte(Instruction::XOR), + uint8_t(Instruction::DUP3), // second ++ + uint8_t(Instruction::XOR), // Stack here: (a+2) x a^(a+2) - byte(Instruction::DUP3), - byte(Instruction::DUP1), - byte(Instruction::PUSH1), 0x1, - byte(Instruction::SWAP1), - byte(Instruction::SUB), + uint8_t(Instruction::DUP3), + uint8_t(Instruction::DUP1), + uint8_t(Instruction::PUSH1), 0x1, + uint8_t(Instruction::SWAP1), + uint8_t(Instruction::SUB), // Stack here: (a+2) x a^(a+2) (a+2) (a+1) - byte(Instruction::SWAP4), - byte(Instruction::POP), // first -- - byte(Instruction::XOR), + uint8_t(Instruction::SWAP4), + uint8_t(Instruction::POP), // first -- + uint8_t(Instruction::XOR), // Stack here: (a+1) x a^(a+2)^(a+2) - byte(Instruction::DUP3), - byte(Instruction::PUSH1), 0x1, - byte(Instruction::SWAP1), - byte(Instruction::SUB), + uint8_t(Instruction::DUP3), + uint8_t(Instruction::PUSH1), 0x1, + uint8_t(Instruction::SWAP1), + uint8_t(Instruction::SUB), // Stack here: (a+1) x a^(a+2)^(a+2) a - byte(Instruction::SWAP3), - byte(Instruction::POP), // second ++ + uint8_t(Instruction::SWAP3), + uint8_t(Instruction::POP), // second ++ // Stack here: a x a^(a+2)^(a+2) - byte(Instruction::DUP3), // will change - byte(Instruction::XOR), - byte(Instruction::SWAP1), - byte(Instruction::POP), - byte(Instruction::DUP1)}); + uint8_t(Instruction::DUP3), // will change + uint8_t(Instruction::XOR), + uint8_t(Instruction::SWAP1), + uint8_t(Instruction::POP), + uint8_t(Instruction::DUP1)}); // Stack here: a x a^(a+2)^(a+2)^a BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -445,16 +445,16 @@ BOOST_AUTO_TEST_CASE(assignment) bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "b"}}); // Stack: a, b - bytes expectation({byte(Instruction::PUSH1), 0x2, - byte(Instruction::DUP2), - byte(Instruction::DUP4), - byte(Instruction::ADD), + bytes expectation({uint8_t(Instruction::PUSH1), 0x2, + uint8_t(Instruction::DUP2), + uint8_t(Instruction::DUP4), + uint8_t(Instruction::ADD), // Stack here: a b 2 a+b - byte(Instruction::SWAP3), - byte(Instruction::POP), - byte(Instruction::DUP3), + uint8_t(Instruction::SWAP3), + uint8_t(Instruction::POP), + uint8_t(Instruction::DUP3), // Stack here: a+b b 2 a+b - byte(Instruction::MUL)}); + uint8_t(Instruction::MUL)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -467,7 +467,7 @@ BOOST_AUTO_TEST_CASE(negative_literals_8bits) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation(bytes({byte(Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x80)); + bytes expectation(bytes({uint8_t(Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x80)); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -480,7 +480,7 @@ BOOST_AUTO_TEST_CASE(negative_literals_16bits) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation(bytes({byte(Instruction::PUSH32)}) + bytes(30, 0xff) + bytes{0xf5, 0x43}); + bytes expectation(bytes({uint8_t(Instruction::PUSH32)}) + bytes(30, 0xff) + bytes{0xf5, 0x43}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -495,7 +495,7 @@ BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals) )"; bytes code = compileFirstExpression(sourceCode); - bytes expectation(bytes({byte(Instruction::PUSH1), 0xbf})); + bytes expectation(bytes({uint8_t(Instruction::PUSH1), 0xbf})); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -514,8 +514,8 @@ BOOST_AUTO_TEST_CASE(blockhash) bytes code = compileFirstExpression(sourceCode, {}, {}, {make_shared("blockhash", blockhashFun)}); - bytes expectation({byte(Instruction::PUSH1), 0x03, - byte(Instruction::BLOCKHASH)}); + bytes expectation({uint8_t(Instruction::PUSH1), 0x03, + uint8_t(Instruction::BLOCKHASH)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -533,7 +533,7 @@ BOOST_AUTO_TEST_CASE(gas_left) {make_shared("gasleft", make_shared(strings(), strings{"uint256"}, FunctionType::Kind::GasLeft))} ); - bytes expectation = bytes({byte(Instruction::GAS)}); + bytes expectation = bytes({uint8_t(Instruction::GAS)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } -- cgit v1.2.3