From 6014c3fe16e2d4c42c1bd710661885a5f787a715 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 14 Feb 2017 14:58:04 +0000 Subject: Add tests for scientific notation --- test/libsolidity/SolidityEndToEndTest.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/libsolidity/SolidityEndToEndTest.cpp') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index baed3f1e..21d9074d 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -9176,6 +9176,23 @@ BOOST_AUTO_TEST_CASE(revert) BOOST_CHECK(callContractFunction("a()") == encodeArgs(u256(42))); } +BOOST_AUTO_TEST_CASE(scientific_notation) +{ + char const* sourceCode = R"( + contract C { + function f() returns (uint) { + return 2e10 wei; + } + function g() returns (uint) { + return 200e-2 wei; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(20000000000))); + BOOST_CHECK(callContractFunction("g()") == encodeArgs(u256(2))); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit From b0a23fa77d4e5f16b3ab1a56000db45748a05838 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 15 Mar 2017 12:21:58 +0000 Subject: Add tests for fractional numbers in exponential notation --- test/libsolidity/SolidityEndToEndTest.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/libsolidity/SolidityEndToEndTest.cpp') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 21d9074d..ebc9f51e 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -9186,11 +9186,15 @@ BOOST_AUTO_TEST_CASE(scientific_notation) function g() returns (uint) { return 200e-2 wei; } + function h() returns (uint) { + return 2.5e1; + } } )"; compileAndRun(sourceCode, 0, "C"); BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(20000000000))); BOOST_CHECK(callContractFunction("g()") == encodeArgs(u256(2))); + BOOST_CHECK(callContractFunction("h()") == encodeArgs(u256(25))); } BOOST_AUTO_TEST_SUITE_END() -- cgit From b28be08b6d1aeb642fd35e32e2b7627e4eb7cd38 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 15 Mar 2017 13:00:58 +0000 Subject: Add tests for negative base --- test/libsolidity/SolidityEndToEndTest.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/libsolidity/SolidityEndToEndTest.cpp') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index ebc9f51e..16b4cc9e 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -9189,12 +9189,24 @@ BOOST_AUTO_TEST_CASE(scientific_notation) function h() returns (uint) { return 2.5e1; } + function i() returns (int) { + return -2e10; + } + function j() returns (int) { + return -200e-2; + } + function k() returns (int) { + return -2.5e1; + } } )"; compileAndRun(sourceCode, 0, "C"); BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(20000000000))); BOOST_CHECK(callContractFunction("g()") == encodeArgs(u256(2))); BOOST_CHECK(callContractFunction("h()") == encodeArgs(u256(25))); + BOOST_CHECK(callContractFunction("i()") == encodeArgs(u256(-20000000000))); + BOOST_CHECK(callContractFunction("j()") == encodeArgs(u256(-2))); + BOOST_CHECK(callContractFunction("k()") == encodeArgs(u256(-25))); } BOOST_AUTO_TEST_SUITE_END() -- cgit