aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests/inline_arrays
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-30 02:47:44 +0800
committerchriseth <chris@ethereum.org>2018-11-30 02:49:38 +0800
commitf46dd91c208e99bf0eba240d34e976a46888ee4d (patch)
tree7450d0cbaa654403a624f93f4927a4f61568d576 /test/libsolidity/syntaxTests/inline_arrays
parent124a8def845186ba55ee8566b05cc617554dbcbc (diff)
downloaddexon-solidity-f46dd91c208e99bf0eba240d34e976a46888ee4d.tar.gz
dexon-solidity-f46dd91c208e99bf0eba240d34e976a46888ee4d.tar.zst
dexon-solidity-f46dd91c208e99bf0eba240d34e976a46888ee4d.zip
Move inline array tests.
Diffstat (limited to 'test/libsolidity/syntaxTests/inline_arrays')
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/dynamic_inline_array.sol8
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion.sol11
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion_strings.sol10
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_int_conversion.sol8
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_string_conversion.sol8
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type.sol7
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type_strings.sol7
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_fixed_types.sol8
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_rationals.sol8
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/invalid_types_in_inline_array.sol7
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/lvalues_as_inline_array.sol8
11 files changed, 90 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/inline_arrays/dynamic_inline_array.sol b/test/libsolidity/syntaxTests/inline_arrays/dynamic_inline_array.sol
new file mode 100644
index 00000000..e613758b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/dynamic_inline_array.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public {
+ uint8[4][4] memory dyn = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]];
+ }
+}
+// ----
+// Warning: (47-69): Unused local variable.
+// Warning: (17-135): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion.sol
new file mode 100644
index 00000000..023404f7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion.sol
@@ -0,0 +1,11 @@
+ contract C {
+ function f() public returns (uint) {
+ uint8 x = 7;
+ uint16 y = 8;
+ uint32 z = 9;
+ uint32[3] memory ending = [x, y, z];
+ return (ending[1]);
+ }
+ }
+// ----
+// Warning: (25-229): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion_strings.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion_strings.sol
new file mode 100644
index 00000000..025244d3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion_strings.sol
@@ -0,0 +1,10 @@
+contract C {
+ function f() public returns (string memory) {
+ string memory x = "Hello";
+ string memory y = "World";
+ string[2] memory z = [x, y];
+ return (z[0]);
+ }
+}
+// ----
+// Warning: (17-198): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_int_conversion.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_int_conversion.sol
new file mode 100644
index 00000000..e7036bdf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_int_conversion.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public returns (uint) {
+ uint8[4] memory z = [1,2,3,5];
+ return (z[0]);
+ }
+}
+// ----
+// Warning: (17-121): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_string_conversion.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_string_conversion.sol
new file mode 100644
index 00000000..4e92f6e1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_string_conversion.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public returns (string memory) {
+ string[2] memory z = ["Hello", "World"];
+ return (z[0]);
+ }
+}
+// ----
+// Warning: (17-140): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type.sol
new file mode 100644
index 00000000..4d3e6aed
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public returns (uint) {
+ return ([4,5,6][1]);
+ }
+}
+// ----
+// Warning: (17-88): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type_strings.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type_strings.sol
new file mode 100644
index 00000000..6d36942d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type_strings.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public returns (string memory) {
+ return (["foo", "man", "choo"][1]);
+ }
+}
+// ----
+// Warning: (17-112): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/inline_arrays/inline_array_fixed_types.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_fixed_types.sol
new file mode 100644
index 00000000..c46297c3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_fixed_types.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() public {
+ fixed[3] memory a = [fixed(3.5), fixed(-4.25), fixed(967.125)];
+ }
+}
+// ----
+// Warning: (50-67): Unused local variable.
+// Warning: (20-119): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/inline_arrays/inline_array_rationals.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_rationals.sol
new file mode 100644
index 00000000..bdc3c2c1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_rationals.sol
@@ -0,0 +1,8 @@
+contract test {
+ function f() public {
+ ufixed128x3[4] memory a = [ufixed128x3(3.5), 4.125, 2.5, 4.0];
+ }
+}
+// ----
+// Warning: (50-73): Unused local variable.
+// Warning: (20-118): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/inline_arrays/invalid_types_in_inline_array.sol b/test/libsolidity/syntaxTests/inline_arrays/invalid_types_in_inline_array.sol
new file mode 100644
index 00000000..03d7266a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/invalid_types_in_inline_array.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ uint[3] memory x = [45, 'foo', true];
+ }
+}
+// ----
+// TypeError: (66-83): Unable to deduce common type for array elements.
diff --git a/test/libsolidity/syntaxTests/inline_arrays/lvalues_as_inline_array.sol b/test/libsolidity/syntaxTests/inline_arrays/lvalues_as_inline_array.sol
new file mode 100644
index 00000000..5a39f550
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/lvalues_as_inline_array.sol
@@ -0,0 +1,8 @@
+contract C {
+ function f() public {
+ [1, 2, 3]++;
+ [1, 2, 3] = [4, 5, 6];
+ }
+}
+// ----
+// TypeError: (47-56): Inline array type cannot be declared as LValue.