From faa0caae084363f6809341ddb63f75d6c682b175 Mon Sep 17 00:00:00 2001 From: herrBez Date: Sat, 15 Sep 2018 13:03:47 +0200 Subject: Add syntax tests to augment the test coverage of libsolidity/parsing/Scanner.cpp and libsolidity/parsing/Scanner.h Fix #4627 and PR #5003. - Add multiline comment test - Add upper case hex literal test - Add test for unicode escapes - Add test for strings with escaped newlines - Add test for string escapes - Add test for strings that do not terminate before end of file - Add test for unterminated blocks --- test/libsolidity/syntaxTests/string/string_escapes.sol | 7 +++++++ test/libsolidity/syntaxTests/string/string_new_line.sol | 9 +++++++++ .../syntaxTests/string/string_terminated_by_backslash.sol | 8 ++++++++ test/libsolidity/syntaxTests/string/string_unterminated.sol | 7 +++++++ .../syntaxTests/string/string_unterminated_no_new_line.sol | 4 ++++ 5 files changed, 35 insertions(+) create mode 100644 test/libsolidity/syntaxTests/string/string_escapes.sol create mode 100644 test/libsolidity/syntaxTests/string/string_new_line.sol create mode 100644 test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol create mode 100644 test/libsolidity/syntaxTests/string/string_unterminated.sol create mode 100644 test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol (limited to 'test/libsolidity/syntaxTests/string') diff --git a/test/libsolidity/syntaxTests/string/string_escapes.sol b/test/libsolidity/syntaxTests/string/string_escapes.sol new file mode 100644 index 00000000..51b90d73 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/string_escapes.sol @@ -0,0 +1,7 @@ +contract test { + function f() public pure returns (bytes32) { + bytes32 escapeCharacters = "\t\b\n\r\f\'\"\\\b"; + return escapeCharacters; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/string/string_new_line.sol b/test/libsolidity/syntaxTests/string/string_new_line.sol new file mode 100644 index 00000000..da2240f7 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/string_new_line.sol @@ -0,0 +1,9 @@ +contract test { + function f() public pure returns (bytes32) { + bytes32 escapeCharacters = "This a test + "; + return escapeCharacters; + } +} +// ---- +// ParserError: (100-112): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol b/test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol new file mode 100644 index 00000000..3eaba6af --- /dev/null +++ b/test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol @@ -0,0 +1,8 @@ +contract test { + function f() public pure returns (bytes32) { + bytes32 escapeCharacters = "text \"; + return escapeCharacters; + } +} +// ---- +// ParserError: (100-109): Expected primary expression. \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/string/string_unterminated.sol b/test/libsolidity/syntaxTests/string/string_unterminated.sol new file mode 100644 index 00000000..3291781e --- /dev/null +++ b/test/libsolidity/syntaxTests/string/string_unterminated.sol @@ -0,0 +1,7 @@ +contract test { + function f() public pure returns (bytes32) { + bytes32 escapeCharacters = "This a test + } +} +// ---- +// ParserError: (100-112): Expected primary expression. \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol b/test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol new file mode 100644 index 00000000..e7be50d2 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol @@ -0,0 +1,4 @@ +contract test { + function f() pure public { "abc\ +// ---- +// ParserError: (47-53): Expected primary expression. \ No newline at end of file -- cgit v1.2.3