diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-14 22:58:04 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-03-15 21:06:26 +0800 |
commit | 6014c3fe16e2d4c42c1bd710661885a5f787a715 (patch) | |
tree | 361d3f39859bda1c1c469402bd7bf3ce7ee0e1f0 /test/libsolidity/SolidityScanner.cpp | |
parent | 924a8fff6bc517519eb91ca73adf06505b3f5a87 (diff) | |
download | dexon-solidity-6014c3fe16e2d4c42c1bd710661885a5f787a715.tar.gz dexon-solidity-6014c3fe16e2d4c42c1bd710661885a5f787a715.tar.zst dexon-solidity-6014c3fe16e2d4c42c1bd710661885a5f787a715.zip |
Add tests for scientific notation
Diffstat (limited to 'test/libsolidity/SolidityScanner.cpp')
-rw-r--r-- | test/libsolidity/SolidityScanner.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp index 3a5c6f24..020bce7f 100644 --- a/test/libsolidity/SolidityScanner.cpp +++ b/test/libsolidity/SolidityScanner.cpp @@ -115,9 +115,21 @@ BOOST_AUTO_TEST_CASE(octal_numbers) BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); } +BOOST_AUTO_TEST_CASE(scientific_notation) +{ + Scanner scanner(CharStream("var x = 2e10;")); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Var); + 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(), "2e10"); + BOOST_CHECK_EQUAL(scanner.next(), Token::Semicolon); + BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); +} + BOOST_AUTO_TEST_CASE(negative_numbers) { - Scanner scanner(CharStream("var x = -.2 + -0x78 + -7.3 + 8.9;")); + Scanner scanner(CharStream("var x = -.2 + -0x78 + -7.3 + 8.9 + 2e-2;")); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Var); BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); BOOST_CHECK_EQUAL(scanner.next(), Token::Assign); @@ -135,6 +147,9 @@ BOOST_AUTO_TEST_CASE(negative_numbers) BOOST_CHECK_EQUAL(scanner.next(), Token::Add); BOOST_CHECK_EQUAL(scanner.next(), Token::Number); BOOST_CHECK_EQUAL(scanner.currentLiteral(), "8.9"); + BOOST_CHECK_EQUAL(scanner.next(), Token::Add); + BOOST_CHECK_EQUAL(scanner.next(), Token::Number); + BOOST_CHECK_EQUAL(scanner.currentLiteral(), "2e-2"); BOOST_CHECK_EQUAL(scanner.next(), Token::Semicolon); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); } |