aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBalajiganapathi S <balajiganapathi.s@gmail.com>2017-10-25 16:12:07 +0800
committerChristian Parpart <christian@ethereum.org>2018-08-08 18:05:51 +0800
commit09a36cba0223c16248335703412cee019c7aa59f (patch)
treeae444498ba2265538c54d4af63742b8bec32da43 /test
parent0000bfc604b985c47ab153f4172596b860c7cce8 (diff)
downloaddexon-solidity-09a36cba0223c16248335703412cee019c7aa59f.tar
dexon-solidity-09a36cba0223c16248335703412cee019c7aa59f.tar.gz
dexon-solidity-09a36cba0223c16248335703412cee019c7aa59f.tar.bz2
dexon-solidity-09a36cba0223c16248335703412cee019c7aa59f.tar.lz
dexon-solidity-09a36cba0223c16248335703412cee019c7aa59f.tar.xz
dexon-solidity-09a36cba0223c16248335703412cee019c7aa59f.tar.zst
dexon-solidity-09a36cba0223c16248335703412cee019c7aa59f.zip
Add stricter hex underscore rules
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp16
-rw-r--r--test/libsolidity/SolidityScanner.cpp2
2 files changed, 17 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index a6c1372b..12da1fa1 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -12836,6 +12836,22 @@ BOOST_AUTO_TEST_CASE(write_storage_external)
ABI_CHECK(callContractFunction("h()"), encodeArgs(12));
}
+BOOST_AUTO_TEST_CASE(test_underscore_in_hex)
+{
+ char const* sourceCode = R"(
+ contract test {
+ function f(bool cond) returns (uint) {
+ uint32 x = 0x1234_ab;
+ uint y = 0x1234_abcd_1234;
+ return cond ? x : y;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("f(bool)", true), encodeArgs(u256(0x1234ab)));
+ ABI_CHECK(callContractFunction("f(bool)", false), encodeArgs(u256(0x1234abcd1234)));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp
index b650d918..9ad738ae 100644
--- a/test/libsolidity/SolidityScanner.cpp
+++ b/test/libsolidity/SolidityScanner.cpp
@@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE(underscores_in_hex)
BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier);
BOOST_CHECK_EQUAL(scanner.next(), Token::Assign);
BOOST_CHECK_EQUAL(scanner.next(), Token::Number);
- BOOST_CHECK_EQUAL(scanner.currentLiteral(), "0xab19cf");
+ BOOST_CHECK_EQUAL(scanner.currentLiteral(), "0xab_19cf");
BOOST_CHECK_EQUAL(scanner.next(), Token::Semicolon);
BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
}