aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-14 08:48:40 +0800
committerchriseth <chris@ethereum.org>2018-02-27 19:17:25 +0800
commit6b9dda06f3d85344a70efb2f868760a0dde9dc45 (patch)
tree860f6e2c040387261969907fc1214b6aa9bc234d /test
parente227bdbfa7157d2675c177c75d44e13f0bd82214 (diff)
downloaddexon-solidity-6b9dda06f3d85344a70efb2f868760a0dde9dc45.tar
dexon-solidity-6b9dda06f3d85344a70efb2f868760a0dde9dc45.tar.gz
dexon-solidity-6b9dda06f3d85344a70efb2f868760a0dde9dc45.tar.bz2
dexon-solidity-6b9dda06f3d85344a70efb2f868760a0dde9dc45.tar.lz
dexon-solidity-6b9dda06f3d85344a70efb2f868760a0dde9dc45.tar.xz
dexon-solidity-6b9dda06f3d85344a70efb2f868760a0dde9dc45.tar.zst
dexon-solidity-6b9dda06f3d85344a70efb2f868760a0dde9dc45.zip
Enable C99-scoping with the 0.5.0-experimental pragma.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index be042655..8586ebf8 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -84,16 +84,45 @@ BOOST_AUTO_TEST_CASE(double_variable_declaration)
}
}
)";
+ CHECK_ERROR(text, DeclarationError, "Identifier already declared");
+}
+
+BOOST_AUTO_TEST_CASE(double_variable_declaration_050)
+{
+ string text = R"(
+ pragma experimental "v0.5.0";
+ contract test {
+ function f() pure public {
+ uint256 x;
+ if (true) { uint256 x; }
+ }
+ }
+ )";
CHECK_WARNING_ALLOW_MULTI(text, (vector<string>{
"This declaration shadows an existing declaration.",
+ "Experimental features",
"Unused local variable",
"Unused local variable"
}));
}
+BOOST_AUTO_TEST_CASE(scoping_old)
+{
+ char const* text = R"(
+ contract test {
+ function f() pure public {
+ x = 4;
+ uint256 x = 2;
+ }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+}
+
BOOST_AUTO_TEST_CASE(scoping)
{
char const* text = R"(
+ pragma experimental "v0.5.0";
contract test {
function f() public {
{
@@ -109,6 +138,7 @@ BOOST_AUTO_TEST_CASE(scoping)
BOOST_AUTO_TEST_CASE(scoping_for)
{
char const* text = R"(
+ pragma experimental "v0.5.0";
contract test {
function f() public {
for (uint x = 0; x < 10; x ++){
@@ -123,6 +153,7 @@ BOOST_AUTO_TEST_CASE(scoping_for)
BOOST_AUTO_TEST_CASE(scoping_for2)
{
char const* text = R"(
+ pragma experimental "v0.5.0";
contract test {
function f() public {
for (uint x = 0; x < 10; x ++){
@@ -1052,7 +1083,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation)
{
char const* text = R"(
contract B {
- function f() mod1(2, true) mod2("0123456") public { }
+ function f() mod1(2, true) mod2("0123456") pure public { }
modifier mod1(uint a, bool b) { if (b) _; }
modifier mod2(bytes7 a) { while (a == "1234567") _; }
}
@@ -1087,7 +1118,19 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation_local_variables)
{
char const* text = R"(
contract B {
- function f() mod(x) public { uint x = 7; }
+ function f() mod(x) pure public { uint x = 7; }
+ modifier mod(uint a) { if (a > 0) _; }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+}
+
+BOOST_AUTO_TEST_CASE(function_modifier_invocation_local_variables050)
+{
+ char const* text = R"(
+ pragma experimental "v0.5.0";
+ contract B {
+ function f() mod(x) pure public { uint x = 7; }
modifier mod(uint a) { if (a > 0) _; }
}
)";