aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-03-16 19:45:12 +0800
committerchriseth <chris@ethereum.org>2018-04-12 04:00:21 +0800
commit4e1ea0866d889daa1144d7c4d89b16cd03cf7dc2 (patch)
treea3c92f12965608079f0a5a4dec546326b898ecb9 /test/libsolidity/syntaxTests
parent2ad1acaf721072d27783d586048d6377be6c3f99 (diff)
downloaddexon-solidity-4e1ea0866d889daa1144d7c4d89b16cd03cf7dc2.tar.gz
dexon-solidity-4e1ea0866d889daa1144d7c4d89b16cd03cf7dc2.tar.zst
dexon-solidity-4e1ea0866d889daa1144d7c4d89b16cd03cf7dc2.zip
Extract modifier tests.
Diffstat (limited to 'test/libsolidity/syntaxTests')
-rw-r--r--test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol6
-rw-r--r--test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol9
-rw-r--r--test/libsolidity/syntaxTests/modifiers/function_modifier_double_invocation.sol4
-rw-r--r--test/libsolidity/syntaxTests/modifiers/function_modifier_invocation.sol5
-rw-r--r--test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol4
-rw-r--r--test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol7
-rw-r--r--test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_parameters.sol5
-rw-r--r--test/libsolidity/syntaxTests/modifiers/function_overrides_modifier.sol5
-rw-r--r--test/libsolidity/syntaxTests/modifiers/illegal_modifier_override.sol4
-rw-r--r--test/libsolidity/syntaxTests/modifiers/invalid_function_modifier_type.sol6
-rw-r--r--test/libsolidity/syntaxTests/modifiers/legal_modifier_override.sol2
-rw-r--r--test/libsolidity/syntaxTests/modifiers/modifier_overrides_function.sol5
-rw-r--r--test/libsolidity/syntaxTests/modifiers/modifier_returns_value.sol6
-rw-r--r--test/libsolidity/syntaxTests/modifiers/modifier_without_underscore.sol5
14 files changed, 73 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol
new file mode 100644
index 00000000..a2a82521
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol
@@ -0,0 +1,6 @@
+contract C { function C(uint a) public {} }
+contract B is C {
+ function B() C(2) C(2) public {}
+}
+// ----
+// DeclarationError: Base constructor already provided.
diff --git a/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol b/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol
new file mode 100644
index 00000000..fac9b319
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol
@@ -0,0 +1,9 @@
+// This caused a segfault in an earlier version
+contract C {
+ function C() public {}
+}
+contract D is C {
+ function D() C(5) public {}
+}
+// ----
+// TypeError: Wrong argument count for modifier invocation: 1 arguments given but expected 0.
diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_double_invocation.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_double_invocation.sol
new file mode 100644
index 00000000..75624192
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_double_invocation.sol
@@ -0,0 +1,4 @@
+contract B {
+ function f(uint x) mod(x) mod(2) public pure { }
+ modifier mod(uint a) { if (a > 0) _; }
+}
diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation.sol
new file mode 100644
index 00000000..e15fcf49
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation.sol
@@ -0,0 +1,5 @@
+contract B {
+ function f() mod1(2, true) mod2("0123456") pure public { }
+ modifier mod1(uint a, bool b) { if (b) _; }
+ modifier mod2(bytes7 a) { while (a == "1234567") _; }
+}
diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol
new file mode 100644
index 00000000..00031924
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol
@@ -0,0 +1,4 @@
+contract B {
+ function f() mod(x) pure public { uint x = 7; }
+ modifier mod(uint a) { if (a > 0) _; }
+}
diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol
new file mode 100644
index 00000000..52439f2b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol
@@ -0,0 +1,7 @@
+pragma experimental "v0.5.0";
+contract B {
+ function f() mod(x) pure public { uint x = 7; }
+ modifier mod(uint a) { if (a > 0) _; }
+}
+// ----
+// DeclarationError: Undeclared identifier.
diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_parameters.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_parameters.sol
new file mode 100644
index 00000000..de2a8f48
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_parameters.sol
@@ -0,0 +1,5 @@
+contract B {
+ function f(uint8 a) mod1(a, true) mod2(r) pure public returns (bytes7 r) { }
+ modifier mod1(uint a, bool b) { if (b) _; }
+ modifier mod2(bytes7 a) { while (a == "1234567") _; }
+}
diff --git a/test/libsolidity/syntaxTests/modifiers/function_overrides_modifier.sol b/test/libsolidity/syntaxTests/modifiers/function_overrides_modifier.sol
new file mode 100644
index 00000000..25485bec
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/function_overrides_modifier.sol
@@ -0,0 +1,5 @@
+contract A { function mod(uint a) public { } }
+contract B is A { modifier mod(uint a) { _; } }
+// ----
+// DeclarationError: Identifier already declared.
+// TypeError: Override changes function to modifier.
diff --git a/test/libsolidity/syntaxTests/modifiers/illegal_modifier_override.sol b/test/libsolidity/syntaxTests/modifiers/illegal_modifier_override.sol
new file mode 100644
index 00000000..f77a529b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/illegal_modifier_override.sol
@@ -0,0 +1,4 @@
+contract A { modifier mod(uint a) { _; } }
+contract B is A { modifier mod(uint8 a) { _; } }
+// ----
+// TypeError: Override changes modifier signature.
diff --git a/test/libsolidity/syntaxTests/modifiers/invalid_function_modifier_type.sol b/test/libsolidity/syntaxTests/modifiers/invalid_function_modifier_type.sol
new file mode 100644
index 00000000..8d7d1f9f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/invalid_function_modifier_type.sol
@@ -0,0 +1,6 @@
+contract B {
+ function f() mod1(true) public { }
+ modifier mod1(uint a) { if (a > 0) _; }
+}
+// ----
+// TypeError: Invalid type for argument in modifier invocation. Invalid implicit conversion from bool to uint256 requested.
diff --git a/test/libsolidity/syntaxTests/modifiers/legal_modifier_override.sol b/test/libsolidity/syntaxTests/modifiers/legal_modifier_override.sol
new file mode 100644
index 00000000..51c3fd80
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/legal_modifier_override.sol
@@ -0,0 +1,2 @@
+contract A { modifier mod(uint a) { _; } }
+contract B is A { modifier mod(uint a) { _; } }
diff --git a/test/libsolidity/syntaxTests/modifiers/modifier_overrides_function.sol b/test/libsolidity/syntaxTests/modifiers/modifier_overrides_function.sol
new file mode 100644
index 00000000..ebf36a0d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/modifier_overrides_function.sol
@@ -0,0 +1,5 @@
+contract A { modifier mod(uint a) { _; } }
+contract B is A { function mod(uint a) public { } }
+// ----
+// DeclarationError: Identifier already declared.
+// TypeError: Override changes modifier to function.
diff --git a/test/libsolidity/syntaxTests/modifiers/modifier_returns_value.sol b/test/libsolidity/syntaxTests/modifiers/modifier_returns_value.sol
new file mode 100644
index 00000000..0ae00b66
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/modifier_returns_value.sol
@@ -0,0 +1,6 @@
+contract A {
+ function f(uint a) mod(2) public returns (uint r) { }
+ modifier mod(uint a) { _; return 7; }
+}
+// ----
+// TypeError: Return arguments not allowed.
diff --git a/test/libsolidity/syntaxTests/modifiers/modifier_without_underscore.sol b/test/libsolidity/syntaxTests/modifiers/modifier_without_underscore.sol
new file mode 100644
index 00000000..ae44c4c7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/modifiers/modifier_without_underscore.sol
@@ -0,0 +1,5 @@
+contract test {
+ modifier m() {}
+}
+// ----
+// SyntaxError: Modifier body does not contain '_'.