mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fixes doxygen style multiline comment parsing for files with CRLF as line terminators.
This commit is contained in:
committed by
Christian Parpart
parent
45583895fc
commit
f85f6ba7e0
@@ -568,7 +568,7 @@ BOOST_AUTO_TEST_CASE(multiline_comment_at_eos)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(regular_line_break_in_single_line_comment)
|
||||
{
|
||||
for (auto const& nl: {"\r", "\n"})
|
||||
for (auto const& nl: {"\r", "\n", "\r\n"})
|
||||
{
|
||||
Scanner scanner(CharStream("// abc " + string(nl) + " def ", ""));
|
||||
BOOST_CHECK_EQUAL(scanner.currentCommentLiteral(), "");
|
||||
@@ -595,7 +595,7 @@ BOOST_AUTO_TEST_CASE(irregular_line_breaks_in_single_line_comment)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(regular_line_breaks_in_single_line_doc_comment)
|
||||
{
|
||||
for (auto const& nl: {"\r", "\n"})
|
||||
for (auto const& nl: {"\r", "\n", "\r\n"})
|
||||
{
|
||||
Scanner scanner(CharStream("/// abc " + string(nl) + " def ", ""));
|
||||
BOOST_CHECK_EQUAL(scanner.currentCommentLiteral(), "abc ");
|
||||
@@ -605,6 +605,22 @@ BOOST_AUTO_TEST_CASE(regular_line_breaks_in_single_line_doc_comment)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(regular_line_breaks_in_multiline_doc_comment)
|
||||
{
|
||||
// Test CR, LF, CRLF as line valid terminators for code comments.
|
||||
// Any accepted non-LF is being canonicalized to LF.
|
||||
for (auto const& nl : {"\r"s, "\n"s, "\r\n"s})
|
||||
{
|
||||
Scanner scanner{CharStream{"/// Hello" + nl + "/// World" + nl + "ident", ""}};
|
||||
auto const& lit = scanner.currentCommentLiteral();
|
||||
BOOST_CHECK_EQUAL(lit, "Hello\n World");
|
||||
BOOST_CHECK_EQUAL(scanner.currentCommentLiteral(), "Hello\n World");
|
||||
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Identifier);
|
||||
BOOST_CHECK_EQUAL(scanner.currentLiteral(), "ident");
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(irregular_line_breaks_in_single_line_doc_comment)
|
||||
{
|
||||
for (auto const& nl: {"\v", "\f", "\xE2\x80\xA8", "\xE2\x80\xA9"})
|
||||
@@ -622,9 +638,9 @@ BOOST_AUTO_TEST_CASE(irregular_line_breaks_in_single_line_doc_comment)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(regular_line_breaks_in_strings)
|
||||
{
|
||||
for (auto const& nl: {"\n", "\r"})
|
||||
for (auto const& nl: {"\r"s, "\n"s, "\r\n"s})
|
||||
{
|
||||
Scanner scanner(CharStream("\"abc " + string(nl) + " def\"", ""));
|
||||
Scanner scanner(CharStream("\"abc " + nl + " def\"", ""));
|
||||
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Illegal);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier);
|
||||
BOOST_CHECK_EQUAL(scanner.currentLiteral(), "def");
|
||||
|
||||
Reference in New Issue
Block a user