mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
update to the tests
This commit is contained in:
parent
dd43ce1578
commit
3d7188ac7b
@ -0,0 +1,24 @@
|
||||
pragma experimental SMTChecker;
|
||||
contract C {
|
||||
|
||||
function g() public pure {}
|
||||
|
||||
function f() public view {
|
||||
uint x = 0;
|
||||
bool success = false;
|
||||
try this.g() {
|
||||
success = true;
|
||||
x = 1;
|
||||
} catch Error (string memory /*reason*/) {
|
||||
x = 2;
|
||||
} catch (bytes memory /*reason*/) {
|
||||
x = 3;
|
||||
}
|
||||
assert(x > 0 && x < 4); // should hold
|
||||
assert(x == 0); // should fail
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// ----
|
||||
// Warning 4661: (338-352): BMC: Assertion violation happens here.
|
@ -0,0 +1,28 @@
|
||||
pragma experimental SMTChecker;
|
||||
contract C {
|
||||
|
||||
struct S {
|
||||
uint x;
|
||||
int y;
|
||||
}
|
||||
|
||||
function g() public pure returns (bool b, S memory s) {
|
||||
b = true;
|
||||
s.x = 42;
|
||||
s.y = -1;
|
||||
}
|
||||
|
||||
function f() public view {
|
||||
bool success = false;
|
||||
try this.g() returns (bool b, S memory s) {
|
||||
success = true;
|
||||
assert(b && s.x == 42 && s.y == -1); // should hold
|
||||
} catch {
|
||||
}
|
||||
assert(success); // fails, not guaranteed that there will be no error
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// SMTEngine: bmc
|
||||
// ----
|
||||
// Warning 4661: (368-383): BMC: Assertion violation happens here.
|
@ -0,0 +1,13 @@
|
||||
pragma experimental SMTChecker;
|
||||
contract C {
|
||||
function f() public returns (uint) {
|
||||
while(1==1)
|
||||
try this.f() returns (uint b) {
|
||||
b = 2;
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6321: (75-79): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6838: (91-95): BMC: Condition is always true.
|
@ -0,0 +1,22 @@
|
||||
pragma experimental SMTChecker;
|
||||
contract C {
|
||||
|
||||
function g() public pure {}
|
||||
|
||||
function f() public view {
|
||||
uint x = 0;
|
||||
bool success = false;
|
||||
try this.g() {
|
||||
success = true;
|
||||
x = 1;
|
||||
} catch Error (string memory /*reason*/) {
|
||||
x = 2;
|
||||
} catch (bytes memory /*reason*/) {
|
||||
x = 3;
|
||||
}
|
||||
assert(x > 0 && x < 4); // should hold
|
||||
assert(x == 0); // should fail
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (338-352): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nC.constructor()\nC.f()
|
@ -0,0 +1,26 @@
|
||||
pragma experimental SMTChecker;
|
||||
contract C {
|
||||
|
||||
struct S {
|
||||
uint x;
|
||||
int y;
|
||||
}
|
||||
|
||||
function g() public pure returns (bool b, S memory s) {
|
||||
b = true;
|
||||
s.x = 42;
|
||||
s.y = -1;
|
||||
}
|
||||
|
||||
function f() public view {
|
||||
bool success = false;
|
||||
try this.g() returns (bool b, S memory s) {
|
||||
success = true;
|
||||
assert(b && s.x == 42 && s.y == -1);
|
||||
} catch {
|
||||
}
|
||||
assert(success); // fails, not guaranteed that there will be no error
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6328: (353-368): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nC.constructor()\nC.f()
|
Loading…
Reference in New Issue
Block a user