aboutsummaryrefslogtreecommitdiffstats
path: root/SolidityExpressionCompiler.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-05 05:02:35 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-02-05 05:02:35 +0800
commit19c92ee1d2d488179daec6bfdd5ed48764e2c19e (patch)
tree8bea5b0c4de7e73b54b1511d0b1bfa382ee68fad /SolidityExpressionCompiler.cpp
parent458e65f3cb74dc112e11616e4860bafa7ad07149 (diff)
downloaddexon-solidity-19c92ee1d2d488179daec6bfdd5ed48764e2c19e.tar
dexon-solidity-19c92ee1d2d488179daec6bfdd5ed48764e2c19e.tar.gz
dexon-solidity-19c92ee1d2d488179daec6bfdd5ed48764e2c19e.tar.bz2
dexon-solidity-19c92ee1d2d488179daec6bfdd5ed48764e2c19e.tar.lz
dexon-solidity-19c92ee1d2d488179daec6bfdd5ed48764e2c19e.tar.xz
dexon-solidity-19c92ee1d2d488179daec6bfdd5ed48764e2c19e.tar.zst
dexon-solidity-19c92ee1d2d488179daec6bfdd5ed48764e2c19e.zip
Tests for ether subdenominations. Work in progress
Diffstat (limited to 'SolidityExpressionCompiler.cpp')
-rw-r--r--SolidityExpressionCompiler.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/SolidityExpressionCompiler.cpp b/SolidityExpressionCompiler.cpp
index a0cca3a3..71f40bd2 100644
--- a/SolidityExpressionCompiler.cpp
+++ b/SolidityExpressionCompiler.cpp
@@ -91,7 +91,16 @@ bytes compileFirstExpression(const string& _sourceCode, vector<vector<string>> _
{
Parser parser;
ASTPointer<SourceUnit> sourceUnit;
- BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared<Scanner>(CharStream(_sourceCode))));
+ try
+ {
+ sourceUnit = parser.parse(make_shared<Scanner>(CharStream(_sourceCode)));
+ }
+ catch(boost::exception const& _e)
+ {
+ 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);
@@ -177,6 +186,28 @@ 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)
+{
+ char const* sourceCode = R"(
+ contract c {
+ function c ()
+ {
+ a = 1 wei;
+ // b = 2 szabo;
+ // c = 3 finney;
+// b = 4 ether;
+ }
+ uint256 a;
+ uint256 b;
+ uint256 c;
+ uint256 d;
+ })";
+ bytes code = compileFirstExpression(sourceCode);
+
+ bytes expectation({byte(eth::Instruction::PUSH5), 0x38, 0xd4, 0xa5, 0x10, 0x00});
+ BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
+}
+
BOOST_AUTO_TEST_CASE(comparison)
{
char const* sourceCode = "contract test {\n"