aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2014-11-21 22:35:17 +0800
committerchriseth <c@ethdev.com>2014-11-21 22:35:17 +0800
commit596e7030f7bcdc15803807cbde690236b35d6ec8 (patch)
tree648192839e100611fe501f6013b3f77a65a1029f
parenta879115143aa61ff13cc914ef8be76e8ee67a6f4 (diff)
parent70a5c84095ae7051b1ab92ed42b2d947ce4fe9a3 (diff)
downloaddexon-solidity-596e7030f7bcdc15803807cbde690236b35d6ec8.tar.gz
dexon-solidity-596e7030f7bcdc15803807cbde690236b35d6ec8.tar.zst
dexon-solidity-596e7030f7bcdc15803807cbde690236b35d6ec8.zip
Merge pull request #524 from LefterisJP/sol_parse_comments
Solidity scanner taking documentation comments into account
-rw-r--r--solidityScanner.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/solidityScanner.cpp b/solidityScanner.cpp
index d714699a..573affe6 100644
--- a/solidityScanner.cpp
+++ b/solidityScanner.cpp
@@ -153,6 +153,46 @@ 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"));
+ BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), " Send $(value / 1000) chocolates to the user");
+}
+
+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(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), " Send $(value / 1000) chocolates to the user");
+}
+
+BOOST_AUTO_TEST_CASE(comment_before_eos)
+{
+ Scanner scanner(CharStream("//"));
+ BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "");
+}
+
+BOOST_AUTO_TEST_CASE(documentation_comment_before_eos)
+{
+ Scanner scanner(CharStream("///"));
+ BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "");
+}
+
+BOOST_AUTO_TEST_CASE(comments_mixed_in_sequence)
+{
+ Scanner scanner(CharStream("hello_world ///documentation comment \n"
+ "//simple comment \n"
+ "<<"));
+ BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::SHL);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "documentation comment ");
+}
BOOST_AUTO_TEST_SUITE_END()