diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2014-11-19 01:50:40 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2014-11-19 08:58:32 +0800 |
commit | a461498300624766da2a3637e3b4bd483b67a01a (patch) | |
tree | 67fd20fa968ce83cb257f176d24e220a05e5b66e | |
parent | 00c21e4bccf901b449fc5b0643f6c848ee0ef847 (diff) | |
download | dexon-solidity-a461498300624766da2a3637e3b4bd483b67a01a.tar.gz dexon-solidity-a461498300624766da2a3637e3b4bd483b67a01a.tar.zst dexon-solidity-a461498300624766da2a3637e3b4bd483b67a01a.zip |
solidity scanner takes triple slash doc comments into account
- Conditionally scanning for the documentation comments and gettings their
contents.
- Adding tests for this functionality of the scanner
-rw-r--r-- | solidityScanner.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/solidityScanner.cpp b/solidityScanner.cpp index d714699a..28f52d3a 100644 --- a/solidityScanner.cpp +++ b/solidityScanner.cpp @@ -153,6 +153,50 @@ BOOST_AUTO_TEST_CASE(ambiguities) BOOST_CHECK_EQUAL(scanner.next(), Token::SHL); } +BOOST_AUTO_TEST_CASE(documentation_comments_parsed_begin) +{ + Scanner scanner(CharStream("/// Send $(value / 1000) chocolates to the user"), false); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::COMMENT_LITERAL); + BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), " Send $(value / 1000) chocolates to the user"); +} + +BOOST_AUTO_TEST_CASE(documentation_comments_skipped_begin) +{ + Scanner scanner(CharStream("/// Send $(value / 1000) chocolates to the user")); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS); +} + +BOOST_AUTO_TEST_CASE(documentation_comments_parsed) +{ + Scanner scanner(CharStream("some other tokens /// Send $(value / 1000) chocolates to the user")); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.next(false), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.next(false), Token::COMMENT_LITERAL); + BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), " Send $(value / 1000) chocolates to the user"); +} + +BOOST_AUTO_TEST_CASE(documentation_comments_skipped) +{ + Scanner scanner(CharStream("some other tokens /// Send $(value / 1000) chocolates to the user")); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); +} + +BOOST_AUTO_TEST_CASE(comment_before_eos) +{ + Scanner scanner(CharStream("//")); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS); +} + +BOOST_AUTO_TEST_CASE(documentation_comment_before_eos) +{ + Scanner scanner(CharStream("///"), false); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::COMMENT_LITERAL); + BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), ""); +} BOOST_AUTO_TEST_SUITE_END() |