aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/cmdlineTests.sh2
-rw-r--r--test/contracts/AuctionRegistrar.cpp2
-rw-r--r--test/contracts/FixedFeeRegistrar.cpp2
-rw-r--r--test/contracts/Wallet.cpp2
-rwxr-xr-xtest/externalTests.sh4
-rw-r--r--test/liblll/Compiler.cpp6
-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
27 files changed, 170 insertions, 13 deletions
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index f7577cb3..78e45429 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -177,6 +177,8 @@ do
then
echo " - $dir"
cd "$dir"
+ # Replace version pragmas
+ find . -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity [\^0-9\.]*/pragma solidity >=0.0/'
compileFull -w *.sol */*.sol
cd ..
fi
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index 70503605..eb274c09 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -40,7 +40,7 @@ namespace
{
static char const* registrarCode = R"DELIMITER(
-pragma solidity ^0.4.0;
+pragma solidity >=0.4.0 <0.6.0;
contract NameRegister {
function addr(string memory _name) public view returns (address o_owner);
diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp
index ae921a96..e82f389f 100644
--- a/test/contracts/FixedFeeRegistrar.cpp
+++ b/test/contracts/FixedFeeRegistrar.cpp
@@ -53,7 +53,7 @@ static char const* registrarCode = R"DELIMITER(
// @authors:
// Gav Wood <g@ethdev.com>
-pragma solidity ^0.4.0;
+pragma solidity >=0.4.0 <0.6.0;
contract Registrar {
event Changed(string indexed name);
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index e0e3045c..9fe02e46 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -56,7 +56,7 @@ static char const* walletCode = R"DELIMITER(
// some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the
// interior is executed.
-pragma solidity ^0.4.0;
+pragma solidity >=0.4.0 <0.6.0;
contract multiowned {
diff --git a/test/externalTests.sh b/test/externalTests.sh
index f2839083..0168fb03 100755
--- a/test/externalTests.sh
+++ b/test/externalTests.sh
@@ -56,10 +56,10 @@ function test_truffle
echo "Current commit hash: `git rev-parse HEAD`"
npm install
find . -name soljson.js -exec cp "$SOLJSON" {} \;
- if [ "$name" == "Gnosis" ]; then
+ if [ "$name" == "Zeppelin" -o "$name" == "Gnosis" ]; then
echo "Replaced fixed-version pragmas..."
# Replace fixed-version pragmas in Gnosis (part of Consensys best practice)
- find contracts test -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity 0/pragma solidity ^0/'
+ find contracts test -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity [\^0-9\.]*/pragma solidity >=0.0/'
fi
assertsol="node_modules/truffle/build/Assert.sol"
if [ -f "$assertsol" ]
diff --git a/test/liblll/Compiler.cpp b/test/liblll/Compiler.cpp
index 39f5e620..be798dc8 100644
--- a/test/liblll/Compiler.cpp
+++ b/test/liblll/Compiler.cpp
@@ -356,7 +356,8 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_functional)
"{ (SELFDESTRUCT 0) }"
};
- for (size_t i = 0; i < opcodes_bytecode.size(); i++) {
+ for (size_t i = 0; i < opcodes_bytecode.size(); i++)
+ {
vector<string> errors;
bytes code = lll::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors);
@@ -644,7 +645,8 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_asm)
"{ (asm SELFDESTRUCT) }"
};
- for (size_t i = 0; i < opcodes_bytecode.size(); i++) {
+ for (size_t i = 0; i < opcodes_bytecode.size(); i++)
+ {
vector<string> errors;
bytes code = lll::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors);
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;
+ }
+}
+// ----