Extract modifier tests.

This commit is contained in:
chriseth
2018-04-11 22:00:21 +02:00
parent 2ad1acaf72
commit 4e1ea0866d
15 changed files with 73 additions and 158 deletions
@@ -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.
@@ -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.
@@ -0,0 +1,4 @@
contract B {
function f(uint x) mod(x) mod(2) public pure { }
modifier mod(uint a) { if (a > 0) _; }
}
@@ -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") _; }
}
@@ -0,0 +1,4 @@
contract B {
function f() mod(x) pure public { uint x = 7; }
modifier mod(uint a) { if (a > 0) _; }
}
@@ -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.
@@ -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") _; }
}
@@ -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.
@@ -0,0 +1,4 @@
contract A { modifier mod(uint a) { _; } }
contract B is A { modifier mod(uint8 a) { _; } }
// ----
// TypeError: Override changes modifier signature.
@@ -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.
@@ -0,0 +1,2 @@
contract A { modifier mod(uint a) { _; } }
contract B is A { modifier mod(uint a) { _; } }
@@ -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.
@@ -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.
@@ -0,0 +1,5 @@
contract test {
modifier m() {}
}
// ----
// SyntaxError: Modifier body does not contain '_'.