aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityScanner.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-03-07 19:34:32 +0800
committerchriseth <c@ethdev.com>2017-03-07 19:34:32 +0800
commitbb06569dc66adbe853bf79273f2eff04d8e36ab6 (patch)
tree61d34de9f255d7ca7a2155063de5dd576f6e450b /test/libsolidity/SolidityScanner.cpp
parent573b885337aca75a025c08eea80bb109041e669e (diff)
downloaddexon-solidity-bb06569dc66adbe853bf79273f2eff04d8e36ab6.tar.gz
dexon-solidity-bb06569dc66adbe853bf79273f2eff04d8e36ab6.tar.zst
dexon-solidity-bb06569dc66adbe853bf79273f2eff04d8e36ab6.zip
Disallow octal literals.
Diffstat (limited to 'test/libsolidity/SolidityScanner.cpp')
-rw-r--r--test/libsolidity/SolidityScanner.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp
index eb2f042c..3a5c6f24 100644
--- a/test/libsolidity/SolidityScanner.cpp
+++ b/test/libsolidity/SolidityScanner.cpp
@@ -97,6 +97,24 @@ BOOST_AUTO_TEST_CASE(hex_numbers)
BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
}
+BOOST_AUTO_TEST_CASE(octal_numbers)
+{
+ Scanner scanner(CharStream("07"));
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Illegal);
+ scanner.reset(CharStream("007"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Illegal);
+ scanner.reset(CharStream("-07"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Sub);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal);
+ scanner.reset(CharStream("-.07"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Sub);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::Number);
+ scanner.reset(CharStream("0"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number);
+ scanner.reset(CharStream("0.1"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number);
+}
+
BOOST_AUTO_TEST_CASE(negative_numbers)
{
Scanner scanner(CharStream("var x = -.2 + -0x78 + -7.3 + 8.9;"));