Commit 339f3ad5 authored by LianaHus's avatar LianaHus

constant -> view

parent fcc623bf
......@@ -17,11 +17,11 @@ contract MyTest2 {
i += 1;
}
function initialValueShouldBe100() public constant returns (bool) {
function initialValueShouldBe100() public view returns (bool) {
return Assert.equal(foo.get(), 100, "initial value is not correct");
}
function initialValueShouldBe200() public constant returns (bool) {
function initialValueShouldBe200() public view returns (bool) {
return Assert.equal(foo.get(), 200, "initial value is not correct");
}
......
......@@ -98,17 +98,17 @@ library Assert {
}
/*----------------- Greater than --------------------*/
function greaterThan(uint a, uint b, string message) public constant returns (bool result) {
function greaterThan(uint a, uint b, string message) public view returns (bool result) {
result = (a > b);
emit AssertionEvent(result, message);
}
function greaterThan(int a, int b, string message) public constant returns (bool result) {
function greaterThan(int a, int b, string message) public view 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 constant returns (bool result) {
function greaterThan(uint a, int b, string message) public view 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 constant returns (bool result) {
function greaterThan(int a, uint b, string message) public view 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 constant returns (bool result) {
function lesserThan(uint a, uint b, string message) public view returns (bool result) {
result = (a < b);
emit AssertionEvent(result, message);
}
function lesserThan(int a, int b, string message) public constant returns (bool result) {
function lesserThan(int a, int b, string message) public view 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 constant returns (bool result) {
function lesserThan(uint a, int b, string message) public view 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 constant returns (bool result) {
function lesserThan(int a, uint b, string message) public view returns (bool result) {
if(a < int(0)) {
// int is negative int "a" always lesser
result = true;
......
......@@ -8,12 +8,12 @@ contract MyTest {
foo = new SimpleStorage();
}
function initialValueShouldBe100() public constant returns (bool) {
function initialValueShouldBe100() public view returns (bool) {
//return Assert.equal(foo.get(), 100, "initial value is not correct");
return foo.get() == 100;
}
function initialValueShouldBe200() public constant returns (bool) {
function initialValueShouldBe200() public view returns (bool) {
//return Assert.equal(foo.get(), 200, "initial value is not correct");
return foo.get() == 200;
}
......
......@@ -13,12 +13,12 @@ contract MyTest {
i += 1;
}
function initialValueShouldBe100() public constant returns (bool) {
function initialValueShouldBe100() public view returns (bool) {
//return Assert.equal(foo.get(), 100, "initial value is not correct");
return foo.get() == 100;
}
function initialValueShouldBe200() public constant returns (bool) {
function initialValueShouldBe200() public view returns (bool) {
//return Assert.equal(foo.get(), 200, "initial value is not correct");
return foo.get() == 200;
}
......
......@@ -8,15 +8,15 @@ contract StringTest {
foo = new SimpleString();
}
function initialValueShouldBeHello() public constant returns (bool) {
function initialValueShouldBeHello() public view returns (bool) {
return Assert.equal(foo.get(), "Hello world!", "initial value is not correct");
}
function valueShouldNotBeHelloWorld() public constant returns (bool) {
function valueShouldNotBeHelloWorld() public viewview returns (bool) {
return Assert.notEqual(foo.get(), "Hello wordl!", "initial value is not correct");
}
function valueShouldBeHelloWorld() public constant returns (bool) {
function valueShouldBeHelloWorld() public view returns (bool) {
return Assert.equal(foo.get(), "Hello wordl!", "initial value is not correct");
}
}
......@@ -10,7 +10,7 @@ contract SafeMathTest {
safemathproxy = new SafeMathProxy();
}
function unsafeMultiplicationShouldOverflow() public constant returns (bool) {
function unsafeMultiplicationShouldOverflow() public view returns (bool) {
uint256 a = 4;
uint256 b = 2 ** 256 - 1;
return Assert.equal(
......@@ -20,7 +20,7 @@ contract SafeMathTest {
);
}
function safeMultiplicationShouldRevert() public constant returns (bool) {
function safeMultiplicationShouldRevert() public view returns (bool) {
uint256 a = 4;
uint256 b = 2 ** 256 - 1;
return Assert.equal(
......@@ -30,7 +30,7 @@ contract SafeMathTest {
);
}
function safeDivisionByZeroShouldRevert() public constant returns (bool) {
function safeDivisionByZeroShouldRevert() public view returns (bool) {
uint256 a = 4;
uint256 b = 0;
return Assert.equal(
......@@ -40,7 +40,7 @@ contract SafeMathTest {
);
}
function unsafeSubtractShouldUnderflow() public constant returns (bool) {
function unsafeSubtractShouldUnderflow() public view returns (bool) {
uint256 a = 0;
uint256 b = a - 1;
return Assert.equal(
......
......@@ -3,36 +3,36 @@ pragma solidity ^0.4.24;
contract IntegerTest {
// GREATER THAN [>] tests
function _2_shouldBeGreaterThan_1() public constant returns (bool) {
function _2_shouldBeGreaterThan_1() public view returns (bool) {
return Assert.greaterThan(uint(2), uint(1), "2 is greater than 1");
}
function _0_shouldBeGreaterThan_neg_1() public constant returns (bool) {
function _0_shouldBeGreaterThan_neg_1() public view returns (bool) {
return Assert.greaterThan(uint(0), int(-1), "0 is greater than -1");
}
function _neg_1_shouldNotBeGreaterThan_1() public constant returns (bool) {
function _neg_1_shouldNotBeGreaterThan_1() public view returns (bool) {
return Assert.greaterThan(int(-1), uint(1), "-1 is not greater than 1");
}
function _1_shouldBeGreaterThan_neg_1() public constant returns (bool) {
function _1_shouldBeGreaterThan_neg_1() public view returns (bool) {
return Assert.greaterThan(uint(1), int(-1), "1 is greater than -1");
}
// LESSER THAN [<] tests
function _1_shouldBeLesserThan_2() public constant returns (bool) {
function _1_shouldBeLesserThan_2() public view returns (bool) {
return Assert.lesserThan(uint(1), uint(2), "1 is lesser than 2");
}
function _neg_1_shouldBeLesserThan_0() public constant returns (bool) {
function _neg_1_shouldBeLesserThan_0() public view returns (bool) {
return Assert.lesserThan(int(-1), uint(0), "-1 is lesser than 0");
}
function _neg_2_shouldBeLesserThan_neg_1() public constant returns (bool) {
function _neg_2_shouldBeLesserThan_neg_1() public view returns (bool) {
return Assert.lesserThan(int(-2), int(-1), "-2 is lesser than -1");
}
function _0_shouldNotBeLesserThan_neg_1() public constant returns (bool) {
function _0_shouldNotBeLesserThan_neg_1() public view returns (bool) {
return Assert.lesserThan(uint(0), int(-1), "0 is not lesser than -1");
}
}
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