diff options
author | chriseth <chris@ethereum.org> | 2018-05-31 00:51:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-31 00:51:52 +0800 |
commit | 0a1a8bfb09f996ad288baf4f195d621e143de7d9 (patch) | |
tree | c02a87fa814cad222cd138b54fc73f52251983b1 /test/libsolidity | |
parent | 0e3d4f773fb40c3368d968e165c24ff653860120 (diff) | |
parent | ac6871078940f0ae4a47380091fc46ed46a63d0a (diff) | |
download | dexon-solidity-0a1a8bfb09f996ad288baf4f195d621e143de7d9.tar.gz dexon-solidity-0a1a8bfb09f996ad288baf4f195d621e143de7d9.tar.zst dexon-solidity-0a1a8bfb09f996ad288baf4f195d621e143de7d9.zip |
Merge pull request #4172 from ethereum/trailing_dot
[BREAKING] Disallow trailing dot not followed by number
Diffstat (limited to 'test/libsolidity')
4 files changed, 38 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp index 020bce7f..f455c5eb 100644 --- a/test/libsolidity/SolidityScanner.cpp +++ b/test/libsolidity/SolidityScanner.cpp @@ -127,6 +127,26 @@ BOOST_AUTO_TEST_CASE(scientific_notation) BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); } +BOOST_AUTO_TEST_CASE(trailing_dot) +{ + Scanner scanner(CharStream("2.5")); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); + BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); + scanner.reset(CharStream("2.5e10"), ""); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); + BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); + scanner.reset(CharStream(".5"), ""); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); + BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); + scanner.reset(CharStream(".5e10"), ""); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); + BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); + scanner.reset(CharStream("2."), ""); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); + BOOST_CHECK_EQUAL(scanner.next(), Token::Period); + BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); +} + BOOST_AUTO_TEST_CASE(negative_numbers) { Scanner scanner(CharStream("var x = -.2 + -0x78 + -7.3 + 8.9 + 2e-2;")); diff --git a/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol b/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol new file mode 100644 index 00000000..7f26242c --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/trailing_dot1.sol @@ -0,0 +1,7 @@ +contract test { + uint256 a = 2.2e10; + uint256 b = .5E10; + uint256 c = 4.e-2; +} +// ---- +// TypeError: (70-73): Member "e" not found or not visible after argument-dependent lookup in int_const 4 diff --git a/test/libsolidity/syntaxTests/parsing/trailing_dot2.sol b/test/libsolidity/syntaxTests/parsing/trailing_dot2.sol new file mode 100644 index 00000000..38a7ab2d --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/trailing_dot2.sol @@ -0,0 +1,7 @@ +contract test { + uint256 a = 2.2e10; + uint256 b = .5E10; + uint256 c = 2 + 2.; +} +// ---- +// ParserError: (76-77): Expected identifier but got ';' diff --git a/test/libsolidity/syntaxTests/parsing/trailing_dot3.sol b/test/libsolidity/syntaxTests/parsing/trailing_dot3.sol new file mode 100644 index 00000000..6a126cb3 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/trailing_dot3.sol @@ -0,0 +1,4 @@ +contract test { + uint a = 2. +// ---- +// ParserError: (29-29): Expected identifier but got end of source |