aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests/tupleAssignments
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-05-04 22:10:25 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-05-08 22:13:32 +0800
commit07e862a145c1b900c3bd0bf5d193c3bd8acc6c75 (patch)
tree13c30495dde10fc7db92f1db20f66fd1fce4981a /test/libsolidity/syntaxTests/tupleAssignments
parentfe12f05c080bd143cfb656f71e54d586d0810c4f (diff)
downloaddexon-solidity-07e862a145c1b900c3bd0bf5d193c3bd8acc6c75.tar.gz
dexon-solidity-07e862a145c1b900c3bd0bf5d193c3bd8acc6c75.tar.zst
dexon-solidity-07e862a145c1b900c3bd0bf5d193c3bd8acc6c75.zip
Extract tests.
Diffstat (limited to 'test/libsolidity/syntaxTests/tupleAssignments')
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_memory.sol8
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_storage_pointers.sol10
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol9
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol10
-rw-r--r--test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_right.sol10
5 files changed, 47 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_memory.sol b/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_memory.sol
new file mode 100644
index 00000000..b20bbf90
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_memory.sol
@@ -0,0 +1,8 @@
+contract C {
+ struct S { uint a; uint b; }
+ function f() pure public {
+ S memory x;
+ S memory y;
+ (x, y) = (y, x);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_storage_pointers.sol b/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_storage_pointers.sol
new file mode 100644
index 00000000..5f7a18f7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/nowarn_swap_storage_pointers.sol
@@ -0,0 +1,10 @@
+ contract C {
+ struct S { uint a; uint b; }
+ S x; S y;
+ function f() public {
+ S storage x_local = x;
+ S storage y_local = y;
+ S storage z_local = x;
+ (x, y_local, x_local, z_local) = (y, x_local, y_local, y);
+ }
+ }
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol
new file mode 100644
index 00000000..e4c3e694
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol
@@ -0,0 +1,9 @@
+contract C {
+ struct S { uint a; uint b; }
+ S x; S y;
+ function f() public {
+ (x, y) = (y, x);
+ }
+}
+// ----
+// Warning: (79-94): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first.
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol
new file mode 100644
index 00000000..b2979804
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_left.sol
@@ -0,0 +1,10 @@
+contract C {
+ struct S { uint a; uint b; }
+ S x; S y;
+ function f() public {
+ (,x, y) = (1, 2, y, x);
+ }
+}
+// ----
+// Warning: (79-101): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first.
+// Warning: (79-101): Different number of components on the left hand side (3) than on the right hand side (4).
diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_right.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_right.sol
new file mode 100644
index 00000000..aa35d7d4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies_fill_right.sol
@@ -0,0 +1,10 @@
+contract C {
+ struct S { uint a; uint b; }
+ S x; S y;
+ function f() public {
+ (x, y, ) = (y, x, 1, 2);
+ }
+}
+// ----
+// Warning: (79-102): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first.
+// Warning: (79-102): Different number of components on the left hand side (3) than on the right hand side (4).