Commit 97ceaa42 authored by LianaHus's avatar LianaHus

- added visibility specifiers

- pragma solidity 0.4.* -> 0.5.0
parent 00408be9
pragma solidity ^0.4.7;
pragma solidity ^0.5.0;
contract SimpleStorage {
uint public storedData;
......
pragma solidity ^0.4.7;
ppragma solidity ^0.5.0;
import "remix_tests.sol";
import "./simple_storage.sol";
contract MyTest2 {
SimpleStorage foo;
uint i = 0;
SimpleStorage storage foo;
uint storage i = 0;
function beforeAll() {
function beforeAll() public {
foo = new SimpleStorage();
}
function beforeEach() {
function beforeEach() public {
if (i == 1) {
foo.set(200);
}
......
pragma solidity ^0.4.7;
pragma solidity ^0.5.0;
import "./simple_storage.sol";
contract MyTest {
SimpleStorage foo;
uint i = 0;
SimpleStorage storage foo;
uint storage i = 0;
function beforeAll() {
function beforeAll() public {
foo = new SimpleStorage();
}
function beforeEach() {
function beforeEach() public {
if (i == 1) {
foo.set(200);
}
......
module.exports = `
pragma solidity ^0.4.7;
pragma solidity ^0.5.0;
library Assert {
......@@ -8,107 +8,107 @@ library Assert {
string message
);
function ok(bool a, string message) public returns (bool result) {
function ok(bool a, string memory message) public returns (bool result) {
result = a;
emit AssertionEvent(result, message);
}
function equal(uint a, uint b, string message) public returns (bool result) {
function equal(uint a, uint b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEvent(result, message);
}
function equal(int a, int b, string message) public returns (bool result) {
function equal(int a, int b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEvent(result, message);
}
function equal(bool a, bool b, string message) public returns (bool result) {
function equal(bool a, bool b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEvent(result, message);
}
// TODO: only for certain versions of solc
//function equal(fixed a, fixed b, string message) public returns (bool result) {
//function equal(fixed a, fixed b, string memory message) public returns (bool result) {
// result = (a == b);
// emit AssertionEvent(result, message);
//}
// TODO: only for certain versions of solc
//function equal(ufixed a, ufixed b, string message) public returns (bool result) {
//function equal(ufixed a, ufixed b, string memory message) public returns (bool result) {
// result = (a == b);
// emit AssertionEvent(result, message);
//}
function equal(address a, address b, string message) public returns (bool result) {
function equal(address a, address b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEvent(result, message);
}
function equal(bytes32 a, bytes32 b, string message) public returns (bool result) {
function equal(bytes32 a, bytes32 b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEvent(result, message);
}
function equal(string a, string b, string message) public returns (bool result) {
result = (keccak256(a) == keccak256(b));
AssertionEvent(result, message);
function equal(string memory a, string memory b, string memory message) public returns (bool result) {
result = (keccak256(abi.encode(a)) == keccak256(abi.encode(b)));
emit AssertionEvent(result, message);
}
function notEqual(uint a, uint b, string message) public returns (bool result) {
function notEqual(uint a, uint b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEvent(result, message);
}
function notEqual(int a, int b, string message) public returns (bool result) {
function notEqual(int a, int b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEvent(result, message);
}
function notEqual(bool a, bool b, string message) public returns (bool result) {
function notEqual(bool a, bool b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEvent(result, message);
}
// TODO: only for certain versions of solc
//function notEqual(fixed a, fixed b, string message) public returns (bool result) {
//function notEqual(fixed a, fixed b, string memory message) public returns (bool result) {
// result = (a != b);
// emit AssertionEvent(result, message);
//}
// TODO: only for certain versions of solc
//function notEqual(ufixed a, ufixed b, string message) public returns (bool result) {
//function notEqual(ufixed a, ufixed b, string memory message) public returns (bool result) {
// result = (a != b);
// emit AssertionEvent(result, message);
//}
function notEqual(address a, address b, string message) public returns (bool result) {
function notEqual(address a, address b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEvent(result, message);
}
function notEqual(bytes32 a, bytes32 b, string message) public returns (bool result) {
function notEqual(bytes32 a, bytes32 b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEvent(result, message);
}
function notEqual(string a, string b, string message) public returns (bool result) {
result = (keccak256(a) != keccak256(b));
AssertionEvent(result, message);
function notEqual(string memory a, string memory b, string memory message) public returns (bool result) {
result = (keccak256(abi.encode(a)) != keccak256(abi.encode(b)));
emit AssertionEvent(result, message);
}
/*----------------- Greater than --------------------*/
function greaterThan(uint a, uint b, string message) public view returns (bool result) {
function greaterThan(uint a, uint b, string memory message) public returns (bool result) {
result = (a > b);
emit AssertionEvent(result, message);
}
function greaterThan(int a, int b, string message) public view returns (bool result) {
function greaterThan(int a, int b, string memory message) public returns (bool result) {
result = (a > b);
emit AssertionEvent(result, message);
}
// TODO: safely compare between uint and int
function greaterThan(uint a, int b, string message) public view returns (bool result) {
function greaterThan(uint a, int b, string memory message) public returns (bool result) {
if(b < int(0)) {
// int is negative uint "a" always greater
result = true;
......@@ -117,7 +117,7 @@ library Assert {
}
emit AssertionEvent(result, message);
}
function greaterThan(int a, uint b, string message) public view returns (bool result) {
function greaterThan(int a, uint b, string memory message) public returns (bool result) {
if(a < int(0)) {
// int is negative uint "b" always greater
result = false;
......@@ -127,17 +127,17 @@ library Assert {
emit AssertionEvent(result, message);
}
/*----------------- Lesser than --------------------*/
function lesserThan(uint a, uint b, string message) public view returns (bool result) {
function lesserThan(uint a, uint b, string memory message) public returns (bool result) {
result = (a < b);
emit AssertionEvent(result, message);
}
function lesserThan(int a, int b, string message) public view returns (bool result) {
function lesserThan(int a, int b, string memory message) public returns (bool result) {
result = (a < b);
emit AssertionEvent(result, message);
}
// TODO: safely compare between uint and int
function lesserThan(uint a, int b, string message) public view returns (bool result) {
function lesserThan(uint a, int b, string memory message) public returns (bool result) {
if(b < int(0)) {
// int is negative int "b" always lesser
result = false;
......@@ -147,7 +147,7 @@ library Assert {
emit AssertionEvent(result, message);
}
function lesserThan(int a, uint b, string message) public view returns (bool result) {
function lesserThan(int a, uint b, string memory message) public returns (bool result) {
if(a < int(0)) {
// int is negative int "a" always lesser
result = true;
......
pragma solidity ^0.4.7;
pragma solidity ^0.5.0;
contract SimpleStorage {
uint public storedData;
......
pragma solidity ^0.4.7;
pragma solidity ^0.5.0;
import "./simple_storage.sol";
contract MyTest {
SimpleStorage foo;
function beforeAll() {
function beforeAll() public {
foo = new SimpleStorage();
}
......
pragma solidity ^0.4.7;
pragma solidity ^0.5.0;
contract SimpleStorage {
uint public storedData;
......
pragma solidity ^0.4.7;
pragma solidity ^0.5.0;
import "./simple_storage.sol";
contract MyTest {
SimpleStorage foo;
uint i = 0;
function beforeEach() {
function beforeEach() public {
foo = new SimpleStorage();
if (i == 1) {
foo.set(200);
......
pragma solidity ^0.4.7;
pragma solidity ^0.5.0;
contract SimpleString {
string public storedData;
......@@ -6,7 +6,7 @@ contract SimpleString {
storedData = "Hello world!";
}
function get() public view returns (string retVal) {
function get() public view returns (string memory retVal) {
return storedData;
}
}
pragma solidity ^0.4.7;
pragma solidity ^0.5.0;
import "./simple_string.sol";
contract StringTest {
SimpleString foo;
function beforeAll() {
function beforeAll() public {
foo = new SimpleString();
}
function initialValueShouldBeHello() public view returns (bool) {
function initialValueShouldBeHello() public returns (bool) {
return Assert.equal(foo.get(), "Hello world!", "initial value is not correct");
}
function valueShouldNotBeHelloWorld() public viewview returns (bool) {
function valueShouldNotBeHelloWorld() public returns (bool) {
return Assert.notEqual(foo.get(), "Hello wordl!", "initial value is not correct");
}
function valueShouldBeHelloWorld() public view returns (bool) {
function valueShouldBeHelloWorld() public returns (bool) {
return Assert.equal(foo.get(), "Hello wordl!", "initial value is not correct");
}
}
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;
contract IntegerTest {
// GREATER THAN [>] tests
function _2_shouldBeGreaterThan_1() public view returns (bool) {
function _2_shouldBeGreaterThan_1() public returns (bool) {
return Assert.greaterThan(uint(2), uint(1), "2 is greater than 1");
}
function _0_shouldBeGreaterThan_neg_1() public view returns (bool) {
function _0_shouldBeGreaterThan_neg_1() public returns (bool) {
return Assert.greaterThan(uint(0), int(-1), "0 is greater than -1");
}
function _neg_1_shouldNotBeGreaterThan_1() public view returns (bool) {
function _neg_1_shouldNotBeGreaterThan_1() public returns (bool) {
return Assert.greaterThan(int(-1), uint(1), "-1 is not greater than 1");
}
function _1_shouldBeGreaterThan_neg_1() public view returns (bool) {
function _1_shouldBeGreaterThan_neg_1() public returns (bool) {
return Assert.greaterThan(uint(1), int(-1), "1 is greater than -1");
}
// LESSER THAN [<] tests
function _1_shouldBeLesserThan_2() public view returns (bool) {
function _1_shouldBeLesserThan_2() public returns (bool) {
return Assert.lesserThan(uint(1), uint(2), "1 is lesser than 2");
}
function _neg_1_shouldBeLesserThan_0() public view returns (bool) {
function _neg_1_shouldBeLesserThan_0() public returns (bool) {
return Assert.lesserThan(int(-1), uint(0), "-1 is lesser than 0");
}
function _neg_2_shouldBeLesserThan_neg_1() public view returns (bool) {
function _neg_2_shouldBeLesserThan_neg_1() public returns (bool) {
return Assert.lesserThan(int(-2), int(-1), "-2 is lesser than -1");
}
function _0_shouldNotBeLesserThan_neg_1() public view returns (bool) {
function _0_shouldNotBeLesserThan_neg_1() public returns (bool) {
return Assert.lesserThan(uint(0), int(-1), "0 is not lesser than -1");
}
}
......@@ -123,9 +123,10 @@ describe('testRunner', function () {
})
it('should returns 3 messages', function () {
console.log(tests)
assert.deepEqual(tests, [
{ type: 'contract', value: 'StringTest', filename: 'simple_string_test.sol' },
{ type: 'testFailure', value: 'Value should be hello world', time: 1, context: 'StringTest', "errMsg": "function returned false" },
{ type: 'testFailure', value: 'Value should be hello world', time: 1, context: 'StringTest', "errMsg": "initial value is not correct" },
{ type: 'testPass', value: 'Value should not be hello world', time: 1, context: 'StringTest' },
{ type: 'testPass', value: 'Initial value should be hello', time: 1, context: 'StringTest' },
])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment