forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SMTChecker] Support unary inc/dec for array/mapping access
- Loading branch information
Leonardo Alt
committed
Apr 2, 2019
1 parent
7c880a2
commit aa9b9aa
Showing
9 changed files
with
127 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
pragma experimental SMTChecker; | ||
|
||
contract C | ||
{ | ||
function f() public pure { | ||
uint x = 2; | ||
uint a = ++x; | ||
assert(x == 3); | ||
assert(a == 3); | ||
uint b = x++; | ||
assert(x == 4); | ||
// Should fail. | ||
assert(b < 3); | ||
} | ||
} | ||
// ---- | ||
// Warning: (194-207): Assertion violation happens here |
18 changes: 18 additions & 0 deletions
18
test/libsolidity/smtCheckerTests/operators/unary_add_array.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pragma experimental SMTChecker; | ||
|
||
contract C | ||
{ | ||
uint[] array; | ||
function f(uint x) public { | ||
array[x] = 2; | ||
uint a = ++array[x]; | ||
assert(array[x] == 3); | ||
assert(a == 3); | ||
uint b = array[x]++; | ||
assert(array[x] == 4); | ||
// Should fail. | ||
assert(b < 3); | ||
} | ||
} | ||
// ---- | ||
// Warning: (240-253): Assertion violation happens here |
18 changes: 18 additions & 0 deletions
18
test/libsolidity/smtCheckerTests/operators/unary_add_mapping.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pragma experimental SMTChecker; | ||
|
||
contract C | ||
{ | ||
mapping (uint => uint) map; | ||
function f(uint x) public { | ||
map[x] = 2; | ||
uint a = ++map[x]; | ||
assert(map[x] == 3); | ||
assert(a == 3); | ||
uint b = map[x]++; | ||
assert(map[x] == 4); | ||
// Should fail. | ||
assert(b < 3); | ||
} | ||
} | ||
// ---- | ||
// Warning: (244-257): Assertion violation happens here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
pragma experimental SMTChecker; | ||
|
||
contract C | ||
{ | ||
function f() public pure { | ||
uint x = 5; | ||
uint a = --x; | ||
assert(x == 4); | ||
assert(a == 4); | ||
uint b = x--; | ||
assert(x == 3); | ||
// Should fail. | ||
assert(b > 4); | ||
} | ||
} | ||
// ---- | ||
// Warning: (194-207): Assertion violation happens here |
18 changes: 18 additions & 0 deletions
18
test/libsolidity/smtCheckerTests/operators/unary_sub_array.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pragma experimental SMTChecker; | ||
|
||
contract C | ||
{ | ||
uint[] array; | ||
function f(uint x) public { | ||
array[x] = 5; | ||
uint a = --array[x]; | ||
assert(array[x] == 4); | ||
assert(a == 4); | ||
uint b = array[x]--; | ||
assert(array[x] == 3); | ||
// Should fail. | ||
assert(b > 4); | ||
} | ||
} | ||
// ---- | ||
// Warning: (240-253): Assertion violation happens here |
18 changes: 18 additions & 0 deletions
18
test/libsolidity/smtCheckerTests/operators/unary_sub_mapping.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pragma experimental SMTChecker; | ||
|
||
contract C | ||
{ | ||
mapping (uint => uint) map; | ||
function f(uint x) public { | ||
map[x] = 5; | ||
uint a = --map[x]; | ||
assert(map[x] == 4); | ||
assert(a == 4); | ||
uint b = map[x]--; | ||
assert(map[x] == 3); | ||
// Should fail. | ||
assert(b > 4); | ||
} | ||
} | ||
// ---- | ||
// Warning: (244-257): Assertion violation happens here |