From 845bcf8db09c536c157a7575981daa42b6e6e938 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Thu, 10 Sep 2015 14:26:34 +0200 Subject: - added tests to test empty comment - fixed skipSingleLineComment - some style fixes --- test/libsolidity/SolidityNatspecJSON.cpp | 16 ++++++++++++++++ test/libsolidity/SolidityParser.cpp | 10 ++++++++++ test/libsolidity/SolidityScanner.cpp | 10 ++++++++++ 3 files changed, 36 insertions(+) (limited to 'test/libsolidity') diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index 8a133f5f..5d20fe7b 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -527,6 +527,22 @@ BOOST_AUTO_TEST_CASE(natspec_multiline_notice_without_tag) checkNatspec(sourceCode, natspec, true); } +BOOST_AUTO_TEST_CASE(empty_comment) +{ + char const* sourceCode = R"( + // + contract test + {} + )"; + char const* natspec = R"ABCDEF( + { + "methods" : {} + } + )ABCDEF"; + + checkNatspec(sourceCode, natspec, true); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 3cb5aa4b..14b9e9e4 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -914,6 +914,16 @@ BOOST_AUTO_TEST_CASE(location_specifiers_with_var) BOOST_CHECK_THROW(parseText(text), ParserError); } +BOOST_AUTO_TEST_CASE(empty_comment) +{ + char const* text = R"( + // + contract test + {} + )"; + BOOST_CHECK_NO_THROW(parseText(text)); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp index 431f233e..dadcd903 100644 --- a/test/libsolidity/SolidityScanner.cpp +++ b/test/libsolidity/SolidityScanner.cpp @@ -281,6 +281,16 @@ BOOST_AUTO_TEST_CASE(time_after) BOOST_CHECK_EQUAL(scanner.currentToken(), Token::After); } +BOOST_AUTO_TEST_CASE(empty_comment) +{ + Scanner scanner(CharStream("//\ncontract{}")); + BOOST_CHECK_EQUAL(scanner.currentCommentLiteral(), ""); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Contract); + BOOST_CHECK_EQUAL(scanner.next(), Token::LBrace); + BOOST_CHECK_EQUAL(scanner.next(), Token::RBrace); + +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit v1.2.3