Skip to content

Commit

Permalink
add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
shangweilin committed Apr 10, 2019
1 parent 1f8b40f commit 7ebbdc1
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -3,4 +3,3 @@ driver-kompiled

/.build/*
!/.build/k

16 changes: 8 additions & 8 deletions tests/simple/example.sol → tests/simple/account_info.sol
@@ -1,7 +1,7 @@

contract Test {
int sv;

function whileTest(int a) public returns (int) {
int result = 0;
int index = 0;
Expand Down Expand Up @@ -31,19 +31,19 @@ contract Test {
"msg.sender" : #(3, 4)
},
"exec" : {
"code" :
#solidity(
"code" :
#solidity(
address addr1 = new Test(); // deploy the first instance of Test
addr1.transfer(4000); // initialize the balance of the first instance

address addr2 = new Test(); // deploy the second instance of Test
addr2. transfer(4000); // initialize the balance of the second instance

// Test t1 = new Test(addr1);
int sum = addr1.whileTest(4);
Test t1 = Test(addr1);
int sum = t1.whileTest(4);

// Test t2 = new Test(addr2);
int sum2 = addr2.whileTest(5);
Test t2 = Test(addr2);
int sum2 = t2.whileTest(5);

addr2.argTest(addr1, 10);

Expand All @@ -55,7 +55,7 @@ contract Test {
"mem" : #exists("sum", 10) ,
"mem" : #exists("balance1", 4010),
"mem" : #exists("balance2", 3990),
#Account(addr1) : { #exists("sv", 12), #balance(4010) },
#Account(addr1) : { #exists("sv", 12), #balance(4010) },
#Account(addr2) : { #balance(3990) }
}
}
Expand Down
90 changes: 90 additions & 0 deletions tests/simple/address_transfer_new_format.sol
@@ -0,0 +1,90 @@
contract Test {
int a;
uint b = 5;
bool c =false;

function f (int x, int m) public returns (int y) {
int sum;

if (x < 0 ) {
sum = 0;
}
else {
sum = x + f(x - 1, m);
b = b + 1;
}

return sum;
}
}

contract Move {
address target;

constructor(address addr) public {
target = addr;
}

function transferTest(int amount) public returns (bool result) {
if(this.balance > amount){
target.transfer(amount);
return true;
}
else{
return false;
}
}
}


{


"Test1" : {
"exec" : {
"code" : #solidity(
address addr = new Test();
addr.transfer(100);
int balance1 = addr.balance;

address addr2 = new Move(addr);
addr2.transfer(200);

Move t2 = Move(addr2);
bool result = t2.transferTest(10);
int balance2 = addr.balance;
int balance3 = addr2.balance;
)
},
"post" : {
"mem" : {
#exists("balance1", 100), #exists("balance2", 110),
#exists("balance3", 190), #exists("result", true)
}
}
},


"Test2" : {
"exec" : {
"code" : #solidity(
address addr = new Test();
addr.transfer(100);
int balance1 = addr.balance;

address addr2 = new Move(addr);
addr2.transfer(200);

Move t2 = Move(addr2);
bool result = t2.transferTest(300);
int balance2 = addr.balance;
int balance3 = addr2.balance;
)
},
"post" : {
"mem" : { #exists("balance1", 100), #exists("balance2", 100), #exists("balance3", 200), #exists("result", false) }
}
}


}
17 changes: 17 additions & 0 deletions tests/simple/t9.sol
@@ -0,0 +1,17 @@

{

"Test1" : {
"exec" : {
"code" : #solidity(
bool s ; int b; int a; a = 3; b = 4; s = a > b;
)
},
"post" : {
"mem" : #exists("s",false),
"mem" : #exists("a",3),
"mem" : #exists("b", 4)
}
}

}

0 comments on commit 7ebbdc1

Please sign in to comment.