|
|
@ -100,7 +100,6 @@ bytes compileFirstExpression(const string& _sourceCode, vector<vector<string>> _ |
|
|
|
auto msg = std::string("Parsing source code failed with: \n") + boost::diagnostic_information(_e); |
|
|
|
BOOST_FAIL(msg); |
|
|
|
} |
|
|
|
// BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared<Scanner>(CharStream(_sourceCode))));
|
|
|
|
|
|
|
|
vector<Declaration const*> declarations; |
|
|
|
declarations.reserve(_globalDeclarations.size() + 1); |
|
|
@ -186,25 +185,63 @@ BOOST_AUTO_TEST_CASE(int_literal) |
|
|
|
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); |
|
|
|
} |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(int_literals_with_ether_subdenominations) |
|
|
|
BOOST_AUTO_TEST_CASE(int_with_wei_ether_subdenomination) |
|
|
|
{ |
|
|
|
char const* sourceCode = R"( |
|
|
|
contract c { |
|
|
|
function c () |
|
|
|
contract test { |
|
|
|
function test () |
|
|
|
{ |
|
|
|
a = 1 wei; |
|
|
|
// b = 2 szabo;
|
|
|
|
// c = 3 finney;
|
|
|
|
// b = 4 ether;
|
|
|
|
var x = 1 wei; |
|
|
|
} |
|
|
|
uint256 a; |
|
|
|
uint256 b; |
|
|
|
uint256 c; |
|
|
|
uint256 d; |
|
|
|
})"; |
|
|
|
bytes code = compileFirstExpression(sourceCode); |
|
|
|
|
|
|
|
bytes expectation({byte(eth::Instruction::PUSH5), 0x38, 0xd4, 0xa5, 0x10, 0x00}); |
|
|
|
bytes expectation({byte(eth::Instruction::PUSH1), 0x1}); |
|
|
|
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); |
|
|
|
} |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(int_with_szabo_ether_subdenomination) |
|
|
|
{ |
|
|
|
char const* sourceCode = R"( |
|
|
|
contract test { |
|
|
|
function test () |
|
|
|
{ |
|
|
|
var x = 1 szabo; |
|
|
|
} |
|
|
|
})"; |
|
|
|
bytes code = compileFirstExpression(sourceCode); |
|
|
|
|
|
|
|
bytes expectation({byte(eth::Instruction::PUSH5), 0xe8, 0xd4, 0xa5, 0x10, 0x00}); |
|
|
|
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); |
|
|
|
} |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination) |
|
|
|
{ |
|
|
|
char const* sourceCode = R"( |
|
|
|
contract test { |
|
|
|
function test () |
|
|
|
{ |
|
|
|
var x = 1 finney; |
|
|
|
} |
|
|
|
})"; |
|
|
|
bytes code = compileFirstExpression(sourceCode); |
|
|
|
|
|
|
|
bytes expectation({byte(eth::Instruction::PUSH7), 0x3, 0x8d, 0x7e, 0xa4, 0xc6, 0x80, 0x00}); |
|
|
|
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); |
|
|
|
} |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(int_with_ether_ether_subdenomination) |
|
|
|
{ |
|
|
|
char const* sourceCode = R"( |
|
|
|
contract test { |
|
|
|
function test () |
|
|
|
{ |
|
|
|
var x = 1 ether; |
|
|
|
} |
|
|
|
})"; |
|
|
|
bytes code = compileFirstExpression(sourceCode); |
|
|
|
|
|
|
|
bytes expectation({byte(eth::Instruction::PUSH8), 0xd, 0xe0, 0xb6, 0xb3, 0xa7, 0x64, 0x00, 0x00}); |
|
|
|
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); |
|
|
|
} |
|
|
|
|
|
|
|