aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/cmdlineTests.sh12
-rw-r--r--test/compilationTests/corion/moduleHandler.sol50
-rw-r--r--test/compilationTests/corion/multiOwner.sol6
-rw-r--r--test/compilationTests/corion/schelling.sol2
-rw-r--r--test/compilationTests/milestonetracker/MilestoneTracker.sol4
-rwxr-xr-xtest/externalTests.sh16
-rw-r--r--test/libsolidity/ABIEncoderTests.cpp7
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp274
-rw-r--r--test/libsolidity/SolidityParser.cpp22
-rw-r--r--test/libsolidity/SyntaxTest.cpp13
-rw-r--r--test/libsolidity/syntaxTests/deprecated_functions.sol4
-rw-r--r--test/libsolidity/syntaxTests/deprecated_functions_050.sol15
-rw-r--r--test/libsolidity/syntaxTests/tight_packing_literals.sol21
-rw-r--r--test/libsolidity/syntaxTests/tight_packing_literals_fine.sol14
-rwxr-xr-xtest/solcjsTests.sh5
-rw-r--r--test/tools/isoltest.cpp27
16 files changed, 254 insertions, 238 deletions
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index 74b6a5a7..e8ff69de 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -37,10 +37,6 @@ FULLARGS="--optimize --ignore-missing --combined-json abi,asm,ast,bin,bin-runtim
echo "Checking that the bug list is up to date..."
"$REPO_ROOT"/scripts/update_bugs_by_version.py
-echo "Checking that StandardToken.sol, owned.sol and mortal.sol produce bytecode..."
-output=$("$REPO_ROOT"/build/solc/solc --bin "$REPO_ROOT"/std/*.sol 2>/dev/null | grep "ffff" | wc -l)
-test "${output//[[:blank:]]/}" = "3"
-
function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
function printError() { echo "$(tput setaf 1)$1$(tput sgr0)"; }
@@ -113,14 +109,6 @@ do
done
)
-printTask "Compiling all files in std and examples..."
-
-for f in "$REPO_ROOT"/std/*.sol
-do
- echo "$f"
- compileWithoutWarning "$f"
-done
-
printTask "Compiling all examples from the documentation..."
TMPDIR=$(mktemp -d)
(
diff --git a/test/compilationTests/corion/moduleHandler.sol b/test/compilationTests/corion/moduleHandler.sol
index 682f81dd..3aefce30 100644
--- a/test/compilationTests/corion/moduleHandler.sol
+++ b/test/compilationTests/corion/moduleHandler.sol
@@ -54,11 +54,11 @@ contract moduleHandler is multiOwner, announcementTypes {
require( owners[msg.sender] );
require( modules.length == 0 );
foundationAddress = foundation;
- addModule( modules_s(Token, sha3('Token'), false, false), ! forReplace);
- addModule( modules_s(Premium, sha3('Premium'), false, false), ! forReplace);
- addModule( modules_s(Publisher, sha3('Publisher'), false, true), ! forReplace);
- addModule( modules_s(Schelling, sha3('Schelling'), false, true), ! forReplace);
- addModule( modules_s(Provider, sha3('Provider'), true, true), ! forReplace);
+ addModule( modules_s(Token, keccak256('Token'), false, false), ! forReplace);
+ addModule( modules_s(Premium, keccak256('Premium'), false, false), ! forReplace);
+ addModule( modules_s(Publisher, keccak256('Publisher'), false, true), ! forReplace);
+ addModule( modules_s(Schelling, keccak256('Schelling'), false, true), ! forReplace);
+ addModule( modules_s(Provider, keccak256('Provider'), true, true), ! forReplace);
}
function addModule(modules_s input, bool call) internal {
/*
@@ -117,7 +117,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@id Index of module.
@found Was there any result or not.
*/
- bytes32 _name = sha3(name);
+ bytes32 _name = keccak256(name);
for ( uint256 a=0 ; a<modules.length ; a++ ) {
if ( modules[a].name == _name ) {
return (true, true, a);
@@ -151,9 +151,9 @@ contract moduleHandler is multiOwner, announcementTypes {
*/
var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
require( _success );
- if ( ! ( _found && modules[_id].name == sha3('Publisher') )) {
+ if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("replaceModule", sha3(name, addr, callCallback))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("replaceModule", keccak256(name, addr, callCallback))) ) {
return true;
}
}
@@ -169,7 +169,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function callReplaceCallback(string moduleName, address newModule) external returns (bool success) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("callReplaceCallback", sha3(moduleName, newModule))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("callReplaceCallback", keccak256(moduleName, newModule))) ) {
return true;
}
var (_success, _found, _id) = getModuleIDByName(moduleName);
@@ -190,13 +190,13 @@ contract moduleHandler is multiOwner, announcementTypes {
*/
var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
require( _success );
- if ( ! ( _found && modules[_id].name == sha3('Publisher') )) {
+ if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("newModule", sha3(name, addr, schellingEvent, transferEvent))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("newModule", keccak256(name, addr, schellingEvent, transferEvent))) ) {
return true;
}
}
- addModule( modules_s(addr, sha3(name), schellingEvent, transferEvent), true);
+ addModule( modules_s(addr, keccak256(name), schellingEvent, transferEvent), true);
return true;
}
function dropModule(string name, bool callCallback) external returns (bool success) {
@@ -209,9 +209,9 @@ contract moduleHandler is multiOwner, announcementTypes {
*/
var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
require( _success );
- if ( ! ( _found && modules[_id].name == sha3('Publisher') )) {
+ if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("replaceModule", sha3(name, callCallback))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("replaceModule", keccak256(name, callCallback))) ) {
return true;
}
}
@@ -226,7 +226,7 @@ contract moduleHandler is multiOwner, announcementTypes {
function callDisableCallback(string moduleName) external returns (bool success) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("callDisableCallback", sha3(moduleName))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("callDisableCallback", keccak256(moduleName))) ) {
return true;
}
var (_success, _found, _id) = getModuleIDByName(moduleName);
@@ -248,7 +248,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@bool Was the function successfull?
*/
var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
- require( _success && _found && modules[_id].name == sha3('Token') );
+ require( _success && _found && modules[_id].name == keccak256('Token') );
for ( uint256 a=0 ; a<modules.length ; a++ ) {
if ( modules[a].transferEvent && abstractModule(modules[a].addr).isActive() ) {
require( abstractModule(modules[a].addr).transferEvent(from, to, value) );
@@ -267,7 +267,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@bool Was the function successfull?
*/
var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
- require( _success && _found && modules[_id].name == sha3('Schelling') );
+ require( _success && _found && modules[_id].name == keccak256('Schelling') );
for ( uint256 a=0 ; a<modules.length ; a++ ) {
if ( modules[a].schellingEvent && abstractModule(modules[a].addr).isActive() ) {
require( abstractModule(modules[a].addr).newSchellingRoundEvent(roundID, reward) );
@@ -287,9 +287,9 @@ contract moduleHandler is multiOwner, announcementTypes {
*/
var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
require( _success );
- if ( ! ( _found && modules[_id].name == sha3('Publisher') )) {
+ if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("replaceModuleHandler", sha3(newHandler))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("replaceModuleHandler", keccak256(newHandler))) ) {
return true;
}
}
@@ -353,7 +353,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@success Was the function successfull?
*/
var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
- require( _success && _found && modules[_id].name == sha3('Provider') );
+ require( _success && _found && modules[_id].name == keccak256('Provider') );
(_success, _found, _id) = getModuleIDByName('Token');
require( _success && _found );
require( token(modules[_id].addr).mint(to, value) );
@@ -385,7 +385,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@success Was the function successfull?
*/
var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
- require( _success && _found && modules[_id].name == sha3('Provider') );
+ require( _success && _found && modules[_id].name == keccak256('Provider') );
(_success, _found, _id) = getModuleIDByName('Token');
require( _success && _found );
require( token(modules[_id].addr).processTransactionFee(from, value) );
@@ -400,7 +400,7 @@ contract moduleHandler is multiOwner, announcementTypes {
@success Was the function successfull?
*/
var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
- require( _success && _found && modules[_id].name == sha3('Schelling') );
+ require( _success && _found && modules[_id].name == keccak256('Schelling') );
(_success, _found, _id) = getModuleIDByName('Token');
require( _success && _found );
require( token(modules[_id].addr).burn(from, value) );
@@ -417,9 +417,9 @@ contract moduleHandler is multiOwner, announcementTypes {
*/
var (_success, _found, _id) = getModuleIDByAddress(msg.sender);
require( _success );
- if ( ! ( _found && modules[_id].name == sha3('Publisher') )) {
+ if ( ! ( _found && modules[_id].name == keccak256('Publisher') )) {
require( block.number < debugModeUntil );
- if ( ! insertAndCheckDo(calcDoHash("configureModule", sha3(moduleName, aType, value))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("configureModule", keccak256(moduleName, aType, value))) ) {
return true;
}
}
@@ -437,7 +437,7 @@ contract moduleHandler is multiOwner, announcementTypes {
*/
require( owners[msg.sender] );
if ( forever ) {
- if ( ! insertAndCheckDo(calcDoHash("freezing", sha3(forever))) ) {
+ if ( ! insertAndCheckDo(calcDoHash("freezing", keccak256(forever))) ) {
return;
}
}
diff --git a/test/compilationTests/corion/multiOwner.sol b/test/compilationTests/corion/multiOwner.sol
index 9aae0ebd..b8436c8b 100644
--- a/test/compilationTests/corion/multiOwner.sol
+++ b/test/compilationTests/corion/multiOwner.sol
@@ -21,12 +21,12 @@ contract multiOwner is safeMath {
Externals
*/
function insertOwner(address addr) external {
- if ( insertAndCheckDo(calcDoHash("insertOwner", sha3(addr))) ) {
+ if ( insertAndCheckDo(calcDoHash("insertOwner", keccak256(addr))) ) {
_addOwner(addr);
}
}
function dropOwner(address addr) external {
- if ( insertAndCheckDo(calcDoHash("dropOwner", sha3(addr))) ) {
+ if ( insertAndCheckDo(calcDoHash("dropOwner", keccak256(addr))) ) {
_delOwner(addr);
}
}
@@ -42,7 +42,7 @@ contract multiOwner is safeMath {
return ownerCount * 75 / 100;
}
function calcDoHash(string job, bytes32 data) public constant returns (bytes32 hash) {
- return sha3(job, data);
+ return keccak256(job, data);
}
function validDoHash(bytes32 doHash) public constant returns (bool valid) {
return doDB[doHash].length > 0;
diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol
index 8c8e093c..b74cfb46 100644
--- a/test/compilationTests/corion/schelling.sol
+++ b/test/compilationTests/corion/schelling.sol
@@ -335,7 +335,7 @@ contract schelling is module, announcementTypes, schellingVars {
require( voter.status == voterStatus.afterPrepareVote );
require( voter.roundID < currentRound );
- if ( sha3(vote) == voter.hash ) {
+ if ( keccak256(vote) == voter.hash ) {
delete voter.hash;
if (round.blockHeight+roundBlockDelay/2 >= block.number) {
if ( bytes(vote)[0] == aboveChar ) {
diff --git a/test/compilationTests/milestonetracker/MilestoneTracker.sol b/test/compilationTests/milestonetracker/MilestoneTracker.sol
index 318330df..2f0d58cb 100644
--- a/test/compilationTests/milestonetracker/MilestoneTracker.sol
+++ b/test/compilationTests/milestonetracker/MilestoneTracker.sol
@@ -196,7 +196,7 @@ contract MilestoneTracker {
}
/// @notice `onlyDonor` Approves the proposed milestone list
- /// @param _hashProposals The sha3() of the proposed milestone list's
+ /// @param _hashProposals The keccak256() of the proposed milestone list's
/// bytecode; this confirms that the `donor` knows the set of milestones
/// they are approving
function acceptProposedMilestones(bytes32 _hashProposals
@@ -205,7 +205,7 @@ contract MilestoneTracker {
uint i;
if (!changingMilestones) throw;
- if (sha3(proposedMilestones) != _hashProposals) throw;
+ if (keccak256(proposedMilestones) != _hashProposals) throw;
// Cancel all the unfinished milestones
for (i=0; i<milestones.length; i++) {
diff --git a/test/externalTests.sh b/test/externalTests.sh
index 1565d04f..3599e069 100755
--- a/test/externalTests.sh
+++ b/test/externalTests.sh
@@ -40,14 +40,24 @@ function test_truffle
{
name="$1"
repo="$2"
+ branch="$3"
echo "Running $name tests..."
DIR=$(mktemp -d)
(
- git clone --depth 1 "$repo" "$DIR"
+ if [ -n "$branch" ]
+ then
+ echo "Cloning $branch of $repo..."
+ git clone --depth 1 "$repo" -b "$branch" "$DIR"
+ else
+ echo "Cloning $repo..."
+ git clone --depth 1 "$repo" "$DIR"
+ fi
cd "$DIR"
+ echo "Current commit hash: `git rev-parse HEAD`"
npm install
find . -name soljson.js -exec cp "$SOLJSON" {} \;
if [ "$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/'
fi
@@ -57,5 +67,5 @@ function test_truffle
}
# Using our temporary fork here. Hopefully to be merged into upstream after the 0.5.0 release.
-test_truffle Gnosis https://github.com/axic/pm-contracts.git -b solidity-050
-test_truffle Zeppelin https://github.com/axic/openzeppelin-solidity.git -b solidity-050
+test_truffle Zeppelin https://github.com/axic/openzeppelin-solidity.git solidity-050
+test_truffle Gnosis https://github.com/axic/pm-contracts.git solidity-050
diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp
index 49db9ce1..5f15b28f 100644
--- a/test/libsolidity/ABIEncoderTests.cpp
+++ b/test/libsolidity/ABIEncoderTests.cpp
@@ -374,15 +374,12 @@ BOOST_AUTO_TEST_CASE(calldata)
)";
string s("abcdef");
string t("abcdefgggggggggggggggggggggggggggggggggggggggghhheeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeggg");
- bool newEncoder = false;
BOTH_ENCODERS(
compileAndRun(sourceCode);
callContractFunction("f(bytes)", 0x20, s.size(), s);
- // The old encoder did not pad to multiples of 32 bytes
- REQUIRE_LOG_DATA(encodeArgs(0x20, s.size()) + (newEncoder ? encodeArgs(s) : asBytes(s)));
+ REQUIRE_LOG_DATA(encodeArgs(0x20, s.size(), s));
callContractFunction("f(bytes)", 0x20, t.size(), t);
- REQUIRE_LOG_DATA(encodeArgs(0x20, t.size()) + (newEncoder ? encodeArgs(t) : asBytes(t)));
- newEncoder = true;
+ REQUIRE_LOG_DATA(encodeArgs(0x20, t.size(), t));
)
}
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index b53a9294..236d83ef 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -1971,25 +1971,6 @@ BOOST_AUTO_TEST_CASE(log_in_constructor)
BOOST_CHECK_EQUAL(m_logs[0].topics[0], h256(u256(2)));
}
-BOOST_AUTO_TEST_CASE(suicide)
-{
- char const* sourceCode = R"(
- contract test {
- function test() payable {}
- function a(address receiver) returns (uint ret) {
- suicide(receiver);
- return 10;
- }
- }
- )";
- u256 amount(130);
- compileAndRun(sourceCode, amount);
- u160 address(23);
- ABI_CHECK(callContractFunction("a(address)", address), bytes());
- BOOST_CHECK(!addressHasCode(m_contractAddress));
- BOOST_CHECK_EQUAL(balanceAt(address), amount);
-}
-
BOOST_AUTO_TEST_CASE(selfdestruct)
{
char const* sourceCode = R"(
@@ -2028,23 +2009,6 @@ BOOST_AUTO_TEST_CASE(keccak256)
testContractAgainstCpp("a(bytes32)", f, u256(-1));
}
-BOOST_AUTO_TEST_CASE(sha3)
-{
- char const* sourceCode = R"(
- contract test {
- // to confuse the optimiser
- function b(bytes32 input) returns (bytes32) {
- return sha3(input);
- }
- function a(bytes32 input) returns (bool) {
- return keccak256(input) == b(input);
- }
- }
- )";
- compileAndRun(sourceCode);
- BOOST_REQUIRE(callContractFunction("a(bytes32)", u256(42)) == encodeArgs(true));
-}
-
BOOST_AUTO_TEST_CASE(sha256)
{
char const* sourceCode = R"(
@@ -3493,7 +3457,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data)
callContractFunction("deposit()");
BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
- BOOST_CHECK_EQUAL(toHex(m_logs[0].data), toHex(encodeArgs(10, 0x60, 15, 4) + FixedHash<4>(dev::keccak256("deposit()")).asBytes()));
+ BOOST_CHECK_EQUAL(toHex(m_logs[0].data), toHex(encodeArgs(10, 0x60, 15, 4, asString(FixedHash<4>(dev::keccak256("deposit()")).asBytes()))));
BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(uint256,bytes,uint256)")));
}
@@ -3760,27 +3724,6 @@ BOOST_AUTO_TEST_CASE(iterated_keccak256_with_bytes)
));
}
-BOOST_AUTO_TEST_CASE(sha3_multiple_arguments)
-{
- char const* sourceCode = R"(
- contract c {
- function foo(uint a, uint b, uint c) returns (bytes32 d)
- {
- d = sha3(a, b, c);
- }
- }
- )";
- compileAndRun(sourceCode);
-
- ABI_CHECK(callContractFunction("foo(uint256,uint256,uint256)", 10, 12, 13), encodeArgs(
- dev::keccak256(
- toBigEndian(u256(10)) +
- toBigEndian(u256(12)) +
- toBigEndian(u256(13))
- )
- ));
-}
-
BOOST_AUTO_TEST_CASE(generic_call)
{
char const* sourceCode = R"**(
@@ -4021,7 +3964,8 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes_length)
compileAndRun(sourceCode, 0, "sender");
// No additional data, just function selector
- ABI_CHECK(callContractFunction("viaCalldata()"), encodeArgs(4));
+ ABI_CHECK(callContractFunction("viaCalldata()"), encodeArgs(0x20));
+ // Should be this with 0.5.0: encodeArgs(4));
ABI_CHECK(callContractFunction("viaMemory()"), encodeArgs(0x20));
// Should be this with 0.5.0: encodeArgs(4));
ABI_CHECK(callContractFunction("viaStorage()"), encodeArgs(0x20));
@@ -4029,7 +3973,8 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes_length)
// Some additional unpadded data
bytes unpadded = asBytes(string("abc"));
- ABI_CHECK(callContractFunctionNoEncoding("viaCalldata()", unpadded), encodeArgs(7));
+ ABI_CHECK(callContractFunctionNoEncoding("viaCalldata()", unpadded), encodeArgs(0x20));
+ // Should be this with 0.5.0: encodeArgs(7));
ABI_CHECK(callContractFunctionNoEncoding("viaMemory()", unpadded), encodeArgs(0x20));
// Should be this with 0.5.0: encodeArgs(7));
ABI_CHECK(callContractFunctionNoEncoding("viaStorage()", unpadded), encodeArgs(0x20));
@@ -10487,6 +10432,7 @@ BOOST_AUTO_TEST_CASE(shift_right)
ABI_CHECK(callContractFunction("f(uint256,uint256)", u256(0x4266), u256(8)), encodeArgs(u256(0x42)));
ABI_CHECK(callContractFunction("f(uint256,uint256)", u256(0x4266), u256(16)), encodeArgs(u256(0)));
ABI_CHECK(callContractFunction("f(uint256,uint256)", u256(0x4266), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(uint256,uint256)", u256(1)<<255, u256(5)), encodeArgs(u256(1)<<250));
}
BOOST_AUTO_TEST_CASE(shift_right_garbled)
@@ -10507,6 +10453,39 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled)
ABI_CHECK(callContractFunction("f(uint8,uint8)", u256(0x0), u256(0x1004)), encodeArgs(u256(0xf)));
}
+BOOST_AUTO_TEST_CASE(shift_right_garbled_signed)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f(int8 a, uint8 b) returns (int) {
+ assembly {
+ a := 0xfffffff0
+ }
+ // Higher bits should be signextended before the shift
+ return a >> b;
+ }
+ function g(int8 a, uint8 b) returns (int) {
+ assembly {
+ a := 0xf0
+ }
+ // Higher bits should be signextended before the shift
+ return a >> b;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(3)), encodeArgs(u256(-2)));
+ ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(4)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(0xFF)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(0x1003)), encodeArgs(u256(-2)));
+ ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(0x1004)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("g(int8,uint8)", u256(0x0), u256(3)), encodeArgs(u256(-2)));
+ ABI_CHECK(callContractFunction("g(int8,uint8)", u256(0x0), u256(4)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("g(int8,uint8)", u256(0x0), u256(0xFF)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("g(int8,uint8)", u256(0x0), u256(0x1003)), encodeArgs(u256(-2)));
+ ABI_CHECK(callContractFunction("g(int8,uint8)", u256(0x0), u256(0x1004)), encodeArgs(u256(-1)));
+}
+
BOOST_AUTO_TEST_CASE(shift_right_uint32)
{
char const* sourceCode = R"(
@@ -10583,16 +10562,73 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(0)), encodeArgs(u256(-4266)));
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(17)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(0)), encodeArgs(u256(-4267)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(1)), encodeArgs(u256(-2134)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(17)), encodeArgs(u256(-1)));
+}
+
+BOOST_AUTO_TEST_CASE(shift_right_negative_literal)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f1() pure returns (bool) {
+ return (-4266 >> 0) == -4266;
+ }
+ function f2() pure returns (bool) {
+ return (-4266 >> 1) == -2133;
+ }
+ function f3() pure returns (bool) {
+ return (-4266 >> 4) == -267;
+ }
+ function f4() pure returns (bool) {
+ return (-4266 >> 8) == -17;
+ }
+ function f5() pure returns (bool) {
+ return (-4266 >> 16) == -1;
+ }
+ function f6() pure returns (bool) {
+ return (-4266 >> 17) == -1;
+ }
+ function g1() pure returns (bool) {
+ return (-4267 >> 0) == -4267;
+ }
+ function g2() pure returns (bool) {
+ return (-4267 >> 1) == -2134;
+ }
+ function g3() pure returns (bool) {
+ return (-4267 >> 4) == -267;
+ }
+ function g4() pure returns (bool) {
+ return (-4267 >> 8) == -17;
+ }
+ function g5() pure returns (bool) {
+ return (-4267 >> 16) == -1;
+ }
+ function g6() pure returns (bool) {
+ return (-4267 >> 17) == -1;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f1()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("f2()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("f3()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("f4()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("f5()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("f6()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g1()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g2()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g3()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g4()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g5()"), encodeArgs(true));
+ ABI_CHECK(callContractFunction("g6()"), encodeArgs(true));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int8)
@@ -10607,16 +10643,16 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int8)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(0)), encodeArgs(u256(-66)));
ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(1)), encodeArgs(u256(-33)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(4)), encodeArgs(u256(-4)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(8)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(4)), encodeArgs(u256(-5)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(8)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-66), u256(17)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(0)), encodeArgs(u256(-67)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(1)), encodeArgs(u256(-33)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(4)), encodeArgs(u256(-4)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(8)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(1)), encodeArgs(u256(-34)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(4)), encodeArgs(u256(-5)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(8)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(-67), u256(17)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int8)
@@ -10630,10 +10666,10 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int8)
)";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(0)), encodeArgs(u256(-103)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(1)), encodeArgs(u256(-51)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(2)), encodeArgs(u256(-25)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(4)), encodeArgs(u256(-6)));
- ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(8)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(1)), encodeArgs(u256(-52)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(2)), encodeArgs(u256(-26)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(4)), encodeArgs(u256(-7)));
+ ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(8)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int16)
@@ -10647,10 +10683,10 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int16)
)";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(0)), encodeArgs(u256(-103)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(1)), encodeArgs(u256(-51)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(2)), encodeArgs(u256(-25)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(4)), encodeArgs(u256(-6)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(8)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(1)), encodeArgs(u256(-52)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(2)), encodeArgs(u256(-26)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(4)), encodeArgs(u256(-7)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(8)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int32)
@@ -10664,10 +10700,10 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int32)
)";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(0)), encodeArgs(u256(-103)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(1)), encodeArgs(u256(-51)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(2)), encodeArgs(u256(-25)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(4)), encodeArgs(u256(-6)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(8)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(1)), encodeArgs(u256(-52)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(2)), encodeArgs(u256(-26)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(4)), encodeArgs(u256(-7)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(8)), encodeArgs(u256(-1)));
}
@@ -10683,16 +10719,16 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int16)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(0)), encodeArgs(u256(-4266)));
ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4266), u256(17)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(0)), encodeArgs(u256(-4267)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(1)), encodeArgs(u256(-2134)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int16,int16)", u256(-4267), u256(17)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int32)
@@ -10707,16 +10743,16 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_int32)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(0)), encodeArgs(u256(-4266)));
ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4266), u256(17)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(0)), encodeArgs(u256(-4267)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(1)), encodeArgs(u256(-2134)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int32,int32)", u256(-4267), u256(17)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_assignment)
@@ -10732,16 +10768,16 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_assignment)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(0)), encodeArgs(u256(-4266)));
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4266), u256(17)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(0)), encodeArgs(u256(-4267)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(1)), encodeArgs(u256(-2133)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(4)), encodeArgs(u256(-266)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(8)), encodeArgs(u256(-16)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(16)), encodeArgs(u256(0)));
- ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(17)), encodeArgs(u256(0)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(1)), encodeArgs(u256(-2134)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(4)), encodeArgs(u256(-267)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(8)), encodeArgs(u256(-17)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(16)), encodeArgs(u256(-1)));
+ ABI_CHECK(callContractFunction("f(int256,int256)", u256(-4267), u256(17)), encodeArgs(u256(-1)));
}
BOOST_AUTO_TEST_CASE(shift_negative_rvalue)
@@ -11551,13 +11587,13 @@ BOOST_AUTO_TEST_CASE(delegatecall_return_value)
return value;
}
function get_delegated() external returns (bool) {
- return this.delegatecall(bytes4(sha3("get()")));
+ return this.delegatecall(bytes4(keccak256("get()")));
}
function assert0() external view {
assert(value == 0);
}
function assert0_delegated() external returns (bool) {
- return this.delegatecall(bytes4(sha3("assert0()")));
+ return this.delegatecall(bytes4(keccak256("assert0()")));
}
}
)DELIMITER";
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index 0797b53b..1ffbd771 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -491,28 +491,46 @@ BOOST_AUTO_TEST_CASE(keyword_is_reserved)
auto keywords = {
"abstract",
"after",
+ "alias",
+ "apply",
+ "auto",
"case",
"catch",
+ "copyof",
"default",
+ "define",
"final",
+ "immutable",
+ "implements",
"in",
"inline",
"let",
+ "macro",
"match",
+ "mutable",
"null",
"of",
+ "override",
+ "partial",
+ "promise",
+ "reference",
"relocatable",
+ "sealed",
+ "sizeof",
"static",
+ "supports",
"switch",
"try",
"type",
- "typeof"
+ "typedef",
+ "typeof",
+ "unchecked"
};
for (const auto& keyword: keywords)
{
auto text = std::string("contract ") + keyword + " {}";
- CHECK_PARSE_ERROR(text.c_str(), "Expected identifier but got reserved keyword");
+ CHECK_PARSE_ERROR(text.c_str(), string("Expected identifier but got reserved keyword '") + keyword + "'");
}
}
diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp
index 1c2355d5..430073a0 100644
--- a/test/libsolidity/SyntaxTest.cpp
+++ b/test/libsolidity/SyntaxTest.cpp
@@ -268,9 +268,16 @@ int SyntaxTest::registerTests(
[fullpath]
{
BOOST_REQUIRE_NO_THROW({
- stringstream errorStream;
- if (!SyntaxTest(fullpath.string()).run(errorStream))
- BOOST_ERROR("Test expectation mismatch.\n" + errorStream.str());
+ try
+ {
+ stringstream errorStream;
+ if (!SyntaxTest(fullpath.string()).run(errorStream))
+ BOOST_ERROR("Test expectation mismatch.\n" + errorStream.str());
+ }
+ catch (boost::exception const& _e)
+ {
+ BOOST_ERROR("Exception during syntax test: " << boost::diagnostic_information(_e));
+ }
});
},
_path.stem().string(),
diff --git a/test/libsolidity/syntaxTests/deprecated_functions.sol b/test/libsolidity/syntaxTests/deprecated_functions.sol
index 9df2b43c..ff3af7d2 100644
--- a/test/libsolidity/syntaxTests/deprecated_functions.sol
+++ b/test/libsolidity/syntaxTests/deprecated_functions.sol
@@ -8,5 +8,5 @@ contract test {
}
}
// ----
-// Warning: (58-64): "sha3" has been deprecated in favour of "keccak256"
-// Warning: (99-109): "suicide" has been deprecated in favour of "selfdestruct"
+// TypeError: (58-64): "sha3" has been deprecated in favour of "keccak256"
+// TypeError: (99-109): "suicide" has been deprecated in favour of "selfdestruct"
diff --git a/test/libsolidity/syntaxTests/deprecated_functions_050.sol b/test/libsolidity/syntaxTests/deprecated_functions_050.sol
deleted file mode 100644
index b28e5abb..00000000
--- a/test/libsolidity/syntaxTests/deprecated_functions_050.sol
+++ /dev/null
@@ -1,15 +0,0 @@
-pragma experimental "v0.5.0";
-contract test {
- function f() pure public {
- bytes32 x = sha3(uint8(1));
- x;
- }
- function g() public {
- suicide(1);
- }
-}
-// ----
-// TypeError: (88-102): "sha3" has been deprecated in favour of "keccak256"
-// TypeError: (88-102): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// TypeError: (88-102): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// TypeError: (137-147): "suicide" has been deprecated in favour of "selfdestruct"
diff --git a/test/libsolidity/syntaxTests/tight_packing_literals.sol b/test/libsolidity/syntaxTests/tight_packing_literals.sol
index a190adc3..d6c7f0ba 100644
--- a/test/libsolidity/syntaxTests/tight_packing_literals.sol
+++ b/test/libsolidity/syntaxTests/tight_packing_literals.sol
@@ -2,9 +2,6 @@ contract C {
function f() pure public returns (bytes32) {
return keccak256(1);
}
- function g() pure public returns (bytes32) {
- return sha3(1);
- }
function h() pure public returns (bytes32) {
return sha256(1);
}
@@ -20,14 +17,10 @@ contract C {
// Warning: (87-88): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
// Warning: (77-89): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
// Warning: (77-89): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (161-168): "sha3" has been deprecated in favour of "keccak256"
-// Warning: (166-167): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (161-168): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (161-168): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (247-248): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (240-249): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (240-249): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (331-332): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (321-333): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (321-333): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (420-421): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
+// Warning: (168-169): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
+// Warning: (161-170): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (161-170): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
+// Warning: (252-253): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
+// Warning: (242-254): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (242-254): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
+// Warning: (341-342): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
index 2b9b688a..27665b52 100644
--- a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
+++ b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
@@ -2,9 +2,6 @@ contract C {
function f() pure public returns (bytes32) {
return keccak256(uint8(1));
}
- function g() pure public returns (bytes32) {
- return sha3(uint8(1));
- }
function h() pure public returns (bytes32) {
return sha256(uint8(1));
}
@@ -21,10 +18,7 @@ contract C {
// ----
// Warning: (77-96): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
// Warning: (77-96): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// Warning: (168-182): "sha3" has been deprecated in favour of "keccak256"
-// Warning: (168-182): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (168-182): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// Warning: (254-270): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (254-270): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// Warning: (342-361): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (342-361): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
+// Warning: (168-184): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (168-184): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
+// Warning: (256-275): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (256-275): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
diff --git a/test/solcjsTests.sh b/test/solcjsTests.sh
index 27797cb4..e0bbc5df 100755
--- a/test/solcjsTests.sh
+++ b/test/solcjsTests.sh
@@ -53,6 +53,11 @@ DIR=$(mktemp -d)
rm -f soljson.js
cp "$SOLJSON" soljson.js
+ # ensure to use always 0.5.0 sources
+ # FIXME: should be removed once the version bump in this repo is done
+ rm -rf test/DAO040
+ cp -R test/DAO test/DAO040
+
# Update version (needed for some tests)
echo "Updating package.json to version $VERSION"
npm version --no-git-tag-version $VERSION
diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp
index 100fcbf0..d4b99e9d 100644
--- a/test/tools/isoltest.cpp
+++ b/test/tools/isoltest.cpp
@@ -150,39 +150,22 @@ SyntaxTestTool::Result SyntaxTestTool::process()
m_test = unique_ptr<SyntaxTest>(new SyntaxTest(m_path.string()));
success = m_test->run(outputMessages, " ", m_formatted);
}
- catch(CompilerError const& _e)
+ catch(boost::exception const& _e)
{
FormattedScope(cout, m_formatted, {BOLD, RED}) <<
- "Exception: " << SyntaxTest::errorMessage(_e) << endl;
- return Result::Exception;
- }
- catch(InternalCompilerError const& _e)
- {
- FormattedScope(cout, m_formatted, {BOLD, RED}) <<
- "InternalCompilerError: " << SyntaxTest::errorMessage(_e) << endl;
- return Result::Exception;
- }
- catch(FatalError const& _e)
- {
- FormattedScope(cout, m_formatted, {BOLD, RED}) <<
- "FatalError: " << SyntaxTest::errorMessage(_e) << endl;
- return Result::Exception;
- }
- catch(UnimplementedFeatureError const& _e)
- {
- FormattedScope(cout, m_formatted, {BOLD, RED}) <<
- "UnimplementedFeatureError: " << SyntaxTest::errorMessage(_e) << endl;
+ "Exception during syntax test: " << boost::diagnostic_information(_e) << endl;
return Result::Exception;
}
catch (std::exception const& _e)
{
- FormattedScope(cout, m_formatted, {BOLD, RED}) << "Exception: " << _e.what() << endl;
+ FormattedScope(cout, m_formatted, {BOLD, RED}) <<
+ "Exception during syntax test: " << _e.what() << endl;
return Result::Exception;
}
catch(...)
{
FormattedScope(cout, m_formatted, {BOLD, RED}) <<
- "Unknown Exception" << endl;
+ "Unknown exception during syntax test." << endl;
return Result::Exception;
}