aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/smtCheckerTests/loops
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/smtCheckerTests/loops')
-rw-r--r--test/libsolidity/smtCheckerTests/loops/for_loop_1.sol8
-rw-r--r--test/libsolidity/smtCheckerTests/loops/for_loop_2.sol8
-rw-r--r--test/libsolidity/smtCheckerTests/loops/for_loop_3.sol8
-rw-r--r--test/libsolidity/smtCheckerTests/loops/for_loop_4.sol10
-rw-r--r--test/libsolidity/smtCheckerTests/loops/for_loop_5.sol12
-rw-r--r--test/libsolidity/smtCheckerTests/loops/for_loop_6.sol12
-rw-r--r--test/libsolidity/smtCheckerTests/loops/while_loop_simple_1.sol13
-rw-r--r--test/libsolidity/smtCheckerTests/loops/while_loop_simple_2.sol9
-rw-r--r--test/libsolidity/smtCheckerTests/loops/while_loop_simple_3.sol11
-rw-r--r--test/libsolidity/smtCheckerTests/loops/while_loop_simple_4.sol11
-rw-r--r--test/libsolidity/smtCheckerTests/loops/while_loop_simple_5.sol12
11 files changed, 114 insertions, 0 deletions
diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_1.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_1.sol
new file mode 100644
index 00000000..8988efad
--- /dev/null
+++ b/test/libsolidity/smtCheckerTests/loops/for_loop_1.sol
@@ -0,0 +1,8 @@
+pragma experimental SMTChecker;
+contract C {
+ function f(uint x) public pure {
+ require(x == 2);
+ for (;;) {}
+ assert(x == 2);
+ }
+}
diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_2.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_2.sol
new file mode 100644
index 00000000..58c9f3a7
--- /dev/null
+++ b/test/libsolidity/smtCheckerTests/loops/for_loop_2.sol
@@ -0,0 +1,8 @@
+pragma experimental SMTChecker;
+contract C {
+ function f(uint x) public pure {
+ for (; x == 2; ) {
+ assert(x == 2);
+ }
+ }
+}
diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_3.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_3.sol
new file mode 100644
index 00000000..8bf9bdc7
--- /dev/null
+++ b/test/libsolidity/smtCheckerTests/loops/for_loop_3.sol
@@ -0,0 +1,8 @@
+pragma experimental SMTChecker;
+contract C {
+ function f(uint x) public pure {
+ for (uint y = 2; x < 10; ) {
+ assert(y == 2);
+ }
+ }
+}
diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_4.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_4.sol
new file mode 100644
index 00000000..4d082026
--- /dev/null
+++ b/test/libsolidity/smtCheckerTests/loops/for_loop_4.sol
@@ -0,0 +1,10 @@
+pragma experimental SMTChecker;
+contract C {
+ function f(uint x) public pure {
+ for (uint y = 2; x < 10; y = 3) {
+ assert(y == 2);
+ }
+ }
+}
+// ----
+// Warning: (136-150): Assertion violation happens here
diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_5.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_5.sol
new file mode 100644
index 00000000..2c84960f
--- /dev/null
+++ b/test/libsolidity/smtCheckerTests/loops/for_loop_5.sol
@@ -0,0 +1,12 @@
+pragma experimental SMTChecker;
+contract C {
+ function f(uint x) public pure {
+ uint y;
+ for (y = 2; x < 10; ) {
+ y = 3;
+ }
+ assert(y == 3);
+ }
+}
+// ----
+// Warning: (167-181): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require().
diff --git a/test/libsolidity/smtCheckerTests/loops/for_loop_6.sol b/test/libsolidity/smtCheckerTests/loops/for_loop_6.sol
new file mode 100644
index 00000000..90c4c328
--- /dev/null
+++ b/test/libsolidity/smtCheckerTests/loops/for_loop_6.sol
@@ -0,0 +1,12 @@
+pragma experimental SMTChecker;
+contract C {
+ function f(uint x) public pure {
+ uint y;
+ for (y = 2; x < 10; ) {
+ y = 3;
+ }
+ assert(y == 2);
+ }
+}
+// ----
+// Warning: (167-181): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require().
diff --git a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_1.sol b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_1.sol
new file mode 100644
index 00000000..074be86f
--- /dev/null
+++ b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_1.sol
@@ -0,0 +1,13 @@
+pragma experimental SMTChecker;
+// Check that variables are cleared
+contract C {
+ function f(uint x) public pure {
+ x = 2;
+ while (x > 1) {
+ x = 2;
+ }
+ assert(x == 2);
+ }
+}
+// ----
+// Warning: (194-208): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require().
diff --git a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_2.sol b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_2.sol
new file mode 100644
index 00000000..92a3f0fe
--- /dev/null
+++ b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_2.sol
@@ -0,0 +1,9 @@
+pragma experimental SMTChecker;
+// Check that condition is assumed.
+contract C {
+ function f(uint x) public pure {
+ while (x == 2) {
+ assert(x == 2);
+ }
+ }
+}
diff --git a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_3.sol b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_3.sol
new file mode 100644
index 00000000..a37df888
--- /dev/null
+++ b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_3.sol
@@ -0,0 +1,11 @@
+pragma experimental SMTChecker;
+// Check that condition is not assumed after the body anymore
+contract C {
+ function f(uint x) public pure {
+ while (x == 2) {
+ }
+ assert(x == 2);
+ }
+}
+// ----
+// Warning: (187-201): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require().
diff --git a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_4.sol b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_4.sol
new file mode 100644
index 00000000..f71da865
--- /dev/null
+++ b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_4.sol
@@ -0,0 +1,11 @@
+pragma experimental SMTChecker;
+// Check that negation of condition is not assumed after the body anymore
+contract C {
+ function f(uint x) public pure {
+ while (x == 2) {
+ }
+ assert(x != 2);
+ }
+}
+// ----
+// Warning: (199-213): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require().
diff --git a/test/libsolidity/smtCheckerTests/loops/while_loop_simple_5.sol b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_5.sol
new file mode 100644
index 00000000..41559c99
--- /dev/null
+++ b/test/libsolidity/smtCheckerTests/loops/while_loop_simple_5.sol
@@ -0,0 +1,12 @@
+pragma experimental SMTChecker;
+// Check that side-effects of condition are taken into account
+contract C {
+ function f(uint x, uint y) public pure {
+ x = 7;
+ while ((x = y) > 0) {
+ }
+ assert(x == 7);
+ }
+}
+// ----
+// Warning: (216-230): Assertion violation happens here\nNote that some information is erased after the execution of loops.\nYou can re-introduce information using require().