aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-07-26 00:02:40 +0800
committerGitHub <noreply@github.com>2018-07-26 00:02:40 +0800
commit5a1b6856b49cfd5a99294a35cd764fb0053dff60 (patch)
treed941a23b8fe58744181165f1f05a668d45548230 /test
parent05e608d77878200a9654271c4457d9a5eafcfa50 (diff)
parentb079f34c6545cfb3f4673336bbc3c2ea61c2148d (diff)
downloaddexon-solidity-5a1b6856b49cfd5a99294a35cd764fb0053dff60.tar.gz
dexon-solidity-5a1b6856b49cfd5a99294a35cd764fb0053dff60.tar.zst
dexon-solidity-5a1b6856b49cfd5a99294a35cd764fb0053dff60.zip
Merge pull request #4561 from ethereum/scanner-tests
Add comprehensive tests for the scanner
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityScanner.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp
index f455c5eb..42e1b18e 100644
--- a/test/libsolidity/SolidityScanner.cpp
+++ b/test/libsolidity/SolidityScanner.cpp
@@ -64,6 +64,14 @@ BOOST_AUTO_TEST_CASE(string_escapes)
BOOST_CHECK_EQUAL(scanner.currentLiteral(), "aa");
}
+BOOST_AUTO_TEST_CASE(string_escapes_all)
+{
+ Scanner scanner(CharStream(" { \"a\\x61\\b\\f\\n\\r\\t\\v\""));
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral);
+ BOOST_CHECK_EQUAL(scanner.currentLiteral(), "aa\b\f\n\r\t\v");
+}
+
BOOST_AUTO_TEST_CASE(string_escapes_with_zero)
{
Scanner scanner(CharStream(" { \"a\\x61\\x00abc\""));
@@ -199,7 +207,7 @@ BOOST_AUTO_TEST_CASE(locations)
BOOST_AUTO_TEST_CASE(ambiguities)
{
// test scanning of some operators which need look-ahead
- Scanner scanner(CharStream("<=""<""+ +=a++ =>""<<"));
+ Scanner scanner(CharStream("<=" "<" "+ +=a++ =>" "<<" ">>" " >>=" ">>>" ">>>=" " >>>>>=><<="));
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LessThanOrEqual);
BOOST_CHECK_EQUAL(scanner.next(), Token::LessThan);
BOOST_CHECK_EQUAL(scanner.next(), Token::Add);
@@ -208,6 +216,15 @@ BOOST_AUTO_TEST_CASE(ambiguities)
BOOST_CHECK_EQUAL(scanner.next(), Token::Inc);
BOOST_CHECK_EQUAL(scanner.next(), Token::Arrow);
BOOST_CHECK_EQUAL(scanner.next(), Token::SHL);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::SAR);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::AssignSar);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::SHR);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::AssignShr);
+ // the last "monster" token combination
+ BOOST_CHECK_EQUAL(scanner.next(), Token::SHR);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::AssignSar);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::GreaterThan);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::AssignShl);
}
BOOST_AUTO_TEST_CASE(documentation_comments_parsed_begin)