aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-07-25 23:38:54 +0800
committerGitHub <noreply@github.com>2018-07-25 23:38:54 +0800
commit05e608d77878200a9654271c4457d9a5eafcfa50 (patch)
tree8b9567a9657e812e76f8a2e3cfb13c2fb2633273 /test/libsolidity
parentd04c2e069d851cf4b139f7043a38eebcaab07b14 (diff)
parent7b5e9128747ff6f8775cdd2aa2029039f9850c2b (diff)
downloaddexon-solidity-05e608d77878200a9654271c4457d9a5eafcfa50.tar.gz
dexon-solidity-05e608d77878200a9654271c4457d9a5eafcfa50.tar.zst
dexon-solidity-05e608d77878200a9654271c4457d9a5eafcfa50.zip
Merge pull request #4562 from ethereum/parser-tests
Add comprehensive tests for the parser
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/syntaxTests/emit_empty.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/assembly_evmasm_type.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/assembly_invalid_type.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/import_complex.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/import_complex_invalid_from.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/import_complex_without_from.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/import_invalid_token.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/import_simple.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol12
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/pragma_illegal.sol4
12 files changed, 61 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/emit_empty.sol b/test/libsolidity/syntaxTests/emit_empty.sol
new file mode 100644
index 00000000..819d88fe
--- /dev/null
+++ b/test/libsolidity/syntaxTests/emit_empty.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public {
+ emit;
+ }
+}
+// ----
+// ParserError: (45-46): Expected event name or path.
diff --git a/test/libsolidity/syntaxTests/parsing/assembly_evmasm_type.sol b/test/libsolidity/syntaxTests/parsing/assembly_evmasm_type.sol
new file mode 100644
index 00000000..28a07e63
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/assembly_evmasm_type.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() public pure {
+ assembly "evmasm" {}
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/assembly_invalid_type.sol b/test/libsolidity/syntaxTests/parsing/assembly_invalid_type.sol
new file mode 100644
index 00000000..c2d39279
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/assembly_invalid_type.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure {
+ assembly "failasm" {}
+ }
+}
+// ----
+// ParserError: (55-64): Only "evmasm" supported.
diff --git a/test/libsolidity/syntaxTests/parsing/import_complex.sol b/test/libsolidity/syntaxTests/parsing/import_complex.sol
new file mode 100644
index 00000000..8bbb0a88
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/import_complex.sol
@@ -0,0 +1,3 @@
+import {hello, world} from "hello";
+// ----
+// ParserError: (0-35): Source "hello" not found: File not supplied initially.
diff --git a/test/libsolidity/syntaxTests/parsing/import_complex_invalid_from.sol b/test/libsolidity/syntaxTests/parsing/import_complex_invalid_from.sol
new file mode 100644
index 00000000..c4667606
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/import_complex_invalid_from.sol
@@ -0,0 +1,3 @@
+import {hello, world} from function;
+// ----
+// ParserError: (27-35): Expected import path.
diff --git a/test/libsolidity/syntaxTests/parsing/import_complex_without_from.sol b/test/libsolidity/syntaxTests/parsing/import_complex_without_from.sol
new file mode 100644
index 00000000..961acb22
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/import_complex_without_from.sol
@@ -0,0 +1,3 @@
+import {hello, world};
+// ----
+// ParserError: (21-22): Expected "from".
diff --git a/test/libsolidity/syntaxTests/parsing/import_invalid_token.sol b/test/libsolidity/syntaxTests/parsing/import_invalid_token.sol
new file mode 100644
index 00000000..df837e28
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/import_invalid_token.sol
@@ -0,0 +1,3 @@
+import function;
+// ----
+// ParserError: (7-15): Expected string literal (path), "*" or alias list.
diff --git a/test/libsolidity/syntaxTests/parsing/import_simple.sol b/test/libsolidity/syntaxTests/parsing/import_simple.sol
new file mode 100644
index 00000000..5d61a8bb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/import_simple.sol
@@ -0,0 +1,3 @@
+import "hello";
+// ----
+// ParserError: (0-15): Source "hello" not found: File not supplied initially.
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol
new file mode 100644
index 00000000..d53208ef
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals_multi.sol
@@ -0,0 +1,12 @@
+contract Foo {
+ uint[] m_x;
+ function f() public view {
+ uint[] storage memory x = m_x;
+ uint[] memory storage calldata y;
+ x; y;
+ }
+}
+// ----
+// ParserError: (85-91): Location already specified.
+// ParserError: (123-130): Location already specified.
+// ParserError: (131-139): Location already specified.
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol
new file mode 100644
index 00000000..c6155c09
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params_multi.sol
@@ -0,0 +1,6 @@
+contract Foo {
+ function f(uint[] storage memory constant x, uint[] memory calldata y) internal { }
+}
+// ----
+// ParserError: (45-51): Location already specified.
+// ParserError: (78-86): Location already specified.
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol
new file mode 100644
index 00000000..e34df2b2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_state_variables_multi.sol
@@ -0,0 +1,5 @@
+contract Foo {
+ uint[] memory storage calldata x;
+}
+// ----
+// ParserError: (23-29): Expected identifier but got 'memory'
diff --git a/test/libsolidity/syntaxTests/parsing/pragma_illegal.sol b/test/libsolidity/syntaxTests/parsing/pragma_illegal.sol
new file mode 100644
index 00000000..3395f6be
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/pragma_illegal.sol
@@ -0,0 +1,4 @@
+pragma ``;
+// ----
+// ParserError: (7-8): Token incompatible with Solidity parser as part of pragma directive.
+// ParserError: (8-9): Token incompatible with Solidity parser as part of pragma directive.