aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp12
-rw-r--r--test/libsolidity/SolidityScanner.cpp5
-rw-r--r--test/libsolidity/StandardCompiler.cpp2
-rw-r--r--test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address_payable.sol7
-rw-r--r--test/libsolidity/syntaxTests/multiline_comments.sol13
-rw-r--r--test/libsolidity/syntaxTests/string/string_escapes.sol7
-rw-r--r--test/libsolidity/syntaxTests/string/string_new_line.sol9
-rw-r--r--test/libsolidity/syntaxTests/string/string_terminated_by_backslash.sol8
-rw-r--r--test/libsolidity/syntaxTests/string/string_unterminated.sol7
-rw-r--r--test/libsolidity/syntaxTests/string/string_unterminated_no_new_line.sol4
-rw-r--r--test/libsolidity/syntaxTests/types/address/address_to_payable_address_double.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/address/bytes_long_to_payable_address.sol8
-rw-r--r--test/libsolidity/syntaxTests/types/address/bytes_short_to_payable_address.sol8
-rw-r--r--test/libsolidity/syntaxTests/types/address/bytes_to_payable_address.sol5
-rw-r--r--test/libsolidity/syntaxTests/types/address/uint_to_payable_address.sol5
-rw-r--r--test/libsolidity/syntaxTests/unicode_escape_literals.sol31
-rw-r--r--test/libsolidity/syntaxTests/unterminatedBlocks/one_dot.sol4
-rw-r--r--test/libsolidity/syntaxTests/unterminatedBlocks/one_dot_x.sol5
-rw-r--r--test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot.sol4
-rw-r--r--test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot_x.sol5
-rw-r--r--test/libsolidity/syntaxTests/upper_case_hex_literals.sol9
21 files changed, 159 insertions, 6 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index af8465fc..b2e2b63b 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -396,7 +396,7 @@ BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
});
if (!dev::test::Options::get().evmVersion().supportsReturndata())
- expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible")));
+ expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible VMs.")));
CHECK_ALLOW_MULTI(text, expectations);
}
@@ -407,10 +407,12 @@ BOOST_AUTO_TEST_CASE(create2_as_variable)
)";
// This needs special treatment, because the message mentions the EVM version,
// so cannot be run via isoltest.
- CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
- {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"},
- {Error::Type::Warning, "The \"create2\" instruction is not supported by the VM version"},
- }));
+ vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
+ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
+ });
+ if (!dev::test::Options::get().evmVersion().hasCreate2())
+ expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"create2\" instruction is only available for Constantinople-compatible VMs.")));
+ CHECK_ALLOW_MULTI(text, expectations);
}
BOOST_AUTO_TEST_CASE(getter_is_memory_type)
diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp
index 3a210f94..93db236b 100644
--- a/test/libsolidity/SolidityScanner.cpp
+++ b/test/libsolidity/SolidityScanner.cpp
@@ -105,6 +105,11 @@ BOOST_AUTO_TEST_CASE(hex_numbers)
BOOST_CHECK_EQUAL(scanner.currentLiteral(), "0x765432536763762734623472346");
BOOST_CHECK_EQUAL(scanner.next(), Token::Semicolon);
BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+ scanner.reset(CharStream("0x1234"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number);
+ BOOST_CHECK_EQUAL(scanner.currentLiteral(), "0x1234");
+ scanner.reset(CharStream("0X1234"), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Illegal);
}
BOOST_AUTO_TEST_CASE(octal_numbers)
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index 3aa1dc24..d34bacda 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -640,7 +640,7 @@ BOOST_AUTO_TEST_CASE(libraries_invalid_entry)
}
)";
Json::Value result = compile(input);
- BOOST_CHECK(containsError(result, "JSONError", "library entry is not a JSON object."));
+ BOOST_CHECK(containsError(result, "JSONError", "Library entry is not a JSON object."));
}
BOOST_AUTO_TEST_CASE(libraries_invalid_hex)
diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address_payable.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address_payable.sol
new file mode 100644
index 00000000..adffb14b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address_payable.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public view returns (address payable) {
+ return address(this.f);
+ }
+}
+// ----
+// TypeError: (85-100): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.
diff --git a/test/libsolidity/syntaxTests/multiline_comments.sol b/test/libsolidity/syntaxTests/multiline_comments.sol
new file mode 100644
index 00000000..480fde6c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/multiline_comments.sol
@@ -0,0 +1,13 @@
+/*
+ * This is a multi-line comment
+ * it should create no problems
+ *
+*/
+
+contract test {
+ /*
+ * this is another multi-line comment
+ *
+ */
+}
+// ----
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
diff --git a/test/libsolidity/syntaxTests/types/address/address_to_payable_address_double.sol b/test/libsolidity/syntaxTests/types/address/address_to_payable_address_double.sol
new file mode 100644
index 00000000..1e755033
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/address_to_payable_address_double.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(address a) public pure returns (address payable) {
+ return address(address(a));
+ }
+}
+// ----
+// TypeError: (94-113): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.
diff --git a/test/libsolidity/syntaxTests/types/address/bytes_long_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/bytes_long_to_payable_address.sol
new file mode 100644
index 00000000..ef87ac55
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/bytes_long_to_payable_address.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f(bytes32 x) public pure returns (address payable) {
+ return address(x);
+ }
+}
+// ----
+// TypeError: (94-104): Explicit type conversion not allowed from "bytes32" to "address".
+// TypeError: (94-104): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.
diff --git a/test/libsolidity/syntaxTests/types/address/bytes_short_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/bytes_short_to_payable_address.sol
new file mode 100644
index 00000000..2aa60251
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/bytes_short_to_payable_address.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f(bytes10 x) public pure returns (address payable) {
+ return address(x);
+ }
+}
+// ----
+// TypeError: (94-104): Explicit type conversion not allowed from "bytes10" to "address".
+// TypeError: (94-104): Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.
diff --git a/test/libsolidity/syntaxTests/types/address/bytes_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/bytes_to_payable_address.sol
new file mode 100644
index 00000000..5b6a6714
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/bytes_to_payable_address.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(bytes20 x) public pure returns (address payable) {
+ return address(x);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/address/uint_to_payable_address.sol b/test/libsolidity/syntaxTests/types/address/uint_to_payable_address.sol
new file mode 100644
index 00000000..9a33985a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/address/uint_to_payable_address.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(uint x) public pure returns (address payable) {
+ return address(x);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/unicode_escape_literals.sol b/test/libsolidity/syntaxTests/unicode_escape_literals.sol
new file mode 100644
index 00000000..a340487b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/unicode_escape_literals.sol
@@ -0,0 +1,31 @@
+contract test {
+
+ function oneByteUTF8() public pure returns (bytes32) {
+ bytes32 usdollar = "aaa\u0024aaa";
+ return usdollar;
+ }
+
+ function twoBytesUTF8() public pure returns (bytes32) {
+ bytes32 cent = "aaa\u00A2aaa";
+ return cent;
+ }
+
+ function threeBytesUTF8() public pure returns (bytes32) {
+ bytes32 eur = "aaa\u20ACaaa";
+ return eur;
+ }
+
+ function together() public pure returns (bytes32) {
+ bytes32 res = "\u0024\u00A2\u20AC";
+ return res;
+ }
+
+ // this function returns an invalid unicode character
+ function invalidLiteral() public pure returns(bytes32) {
+ bytes32 invalid = "\u00xx";
+ return invalid;
+ }
+
+}
+// ----
+// ParserError: (678-681): Expected primary expression.
diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot.sol
new file mode 100644
index 00000000..a678f004
--- /dev/null
+++ b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot.sol
@@ -0,0 +1,4 @@
+contract c {
+ function f() pure public { 1.
+// ----
+// ParserError: (47-47): Expected identifier but got end of source \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot_x.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot_x.sol
new file mode 100644
index 00000000..3cc59374
--- /dev/null
+++ b/test/libsolidity/syntaxTests/unterminatedBlocks/one_dot_x.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() pure public { 1.x; }
+}
+// ----
+// TypeError: (47-50): Member "x" not found or not visible after argument-dependent lookup in int_const 1. \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot.sol
new file mode 100644
index 00000000..6ba2b4c2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot.sol
@@ -0,0 +1,4 @@
+contract c {
+ function f() pure public { 0.
+// ----
+// ParserError: (47-47): Expected identifier but got end of source \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot_x.sol b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot_x.sol
new file mode 100644
index 00000000..8648bce2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/unterminatedBlocks/zero_dot_x.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() pure public { 0.x; }
+}
+// ----
+// TypeError: (47-50): Member "x" not found or not visible after argument-dependent lookup in int_const 0. \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/upper_case_hex_literals.sol b/test/libsolidity/syntaxTests/upper_case_hex_literals.sol
new file mode 100644
index 00000000..0842c2ec
--- /dev/null
+++ b/test/libsolidity/syntaxTests/upper_case_hex_literals.sol
@@ -0,0 +1,9 @@
+contract test {
+
+ function f() public pure returns (uint256) {
+ uint256 a = 0x1234aAbcC;
+ uint256 b = 0x1234ABCDEF;
+ return a + b;
+ }
+}
+// ----