aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-08-15 18:31:26 +0800
committerGitHub <noreply@github.com>2018-08-15 18:31:26 +0800
commit6c0261e6abdac4370404d8782c5ab9759dd5ae13 (patch)
treeba9ed829543740457f39994a66f8c51681ddc0fb /test/libsolidity/syntaxTests
parentc7d2af2637e061de43cc6c53e12bf35d1ac66387 (diff)
parent6e139f7d1a82e90e3818d7f4475745f441c1d6f2 (diff)
downloaddexon-solidity-6c0261e6abdac4370404d8782c5ab9759dd5ae13.tar
dexon-solidity-6c0261e6abdac4370404d8782c5ab9759dd5ae13.tar.gz
dexon-solidity-6c0261e6abdac4370404d8782c5ab9759dd5ae13.tar.bz2
dexon-solidity-6c0261e6abdac4370404d8782c5ab9759dd5ae13.tar.lz
dexon-solidity-6c0261e6abdac4370404d8782c5ab9759dd5ae13.tar.xz
dexon-solidity-6c0261e6abdac4370404d8782c5ab9759dd5ae13.tar.zst
dexon-solidity-6c0261e6abdac4370404d8782c5ab9759dd5ae13.zip
Merge pull request #4390 from ethereum/abidecode
Add abi.decode
Diffstat (limited to 'test/libsolidity/syntaxTests')
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_calldata.sol8
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_invalid_arg_count.sol12
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory.sol7
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory_v2.sol10
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_nontuple.sol11
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_simple.sol5
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_singletontuple.sol6
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_storage.sol8
8 files changed, 67 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_calldata.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_calldata.sol
new file mode 100644
index 00000000..28d2f2e7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_calldata.sol
@@ -0,0 +1,8 @@
+// This restriction might be lifted in the future
+contract C {
+ function f() public pure {
+ abi.decode("abc", (bytes calldata));
+ }
+}
+// ----
+// ParserError: (121-129): Expected ',' but got 'calldata'
diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_invalid_arg_count.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_invalid_arg_count.sol
new file mode 100644
index 00000000..f903e1ed
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_invalid_arg_count.sol
@@ -0,0 +1,12 @@
+contract C {
+ function f() public pure {
+ abi.decode();
+ abi.decode(msg.data);
+ abi.decode(msg.data, uint, uint);
+ }
+}
+// ----
+// TypeError: (46-58): This function takes two arguments, but 0 were provided.
+// TypeError: (64-84): This function takes two arguments, but 1 were provided.
+// TypeError: (90-122): This function takes two arguments, but 3 were provided.
+// TypeError: (111-115): The second argument to "abi.decode" has to be a tuple of types.
diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory.sol
new file mode 100644
index 00000000..e4667e34
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure {
+ abi.decode("abc", (bytes memory, uint[][2] memory));
+ }
+}
+// ----
+// ParserError: (71-77): Expected ',' but got 'memory'
diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory_v2.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory_v2.sol
new file mode 100644
index 00000000..8a7462d1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_memory_v2.sol
@@ -0,0 +1,10 @@
+pragma experimental "ABIEncoderV2";
+
+contract C {
+ struct S { uint x; uint[] b; }
+ function f() public pure returns (S memory, bytes memory, uint[][2] memory) {
+ return abi.decode("abc", (S, bytes, uint[][2]));
+ }
+}
+// ----
+// Warning: (0-35): Experimental features are turned on. Do not use experimental features on live deployments.
diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_nontuple.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_nontuple.sol
new file mode 100644
index 00000000..d813c712
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_nontuple.sol
@@ -0,0 +1,11 @@
+contract C {
+ function f() public pure {
+ abi.decode("abc", uint);
+ abi.decode("abc", this);
+ abi.decode("abc", f());
+ }
+}
+// ----
+// TypeError: (64-68): The second argument to "abi.decode" has to be a tuple of types.
+// TypeError: (93-97): The second argument to "abi.decode" has to be a tuple of types.
+// TypeError: (122-125): The second argument to "abi.decode" has to be a tuple of types.
diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_simple.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_simple.sol
new file mode 100644
index 00000000..356ee91c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_simple.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() public pure returns (uint, bytes32, C) {
+ return abi.decode("abc", (uint, bytes32, C));
+ }
+}
diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_singletontuple.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_singletontuple.sol
new file mode 100644
index 00000000..57eccacf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_singletontuple.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f() public pure returns (uint) {
+ return abi.decode("abc", (uint));
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_storage.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_storage.sol
new file mode 100644
index 00000000..d9910b64
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_storage.sol
@@ -0,0 +1,8 @@
+// This restriction might be lifted in the future
+contract C {
+ function f() {
+ abi.decode("abc", (bytes storage));
+ }
+}
+// ----
+// ParserError: (109-116): Expected ',' but got 'storage'