aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-09 23:54:13 +0800
committerchriseth <chris@ethereum.org>2018-02-27 19:17:25 +0800
commit000599038202154afe62b144a44dd81178fc539c (patch)
treef30401d30b2e2df774d3ad70008388de15b42d18 /test/libsolidity
parent69f5f2eb65969c8aa1ee0438601c0a0938f2d0a5 (diff)
downloaddexon-solidity-000599038202154afe62b144a44dd81178fc539c.tar.gz
dexon-solidity-000599038202154afe62b144a44dd81178fc539c.tar.zst
dexon-solidity-000599038202154afe62b144a44dd81178fc539c.zip
Tests for new scoping behaviour.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index a8adde1e..be042655 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -91,6 +91,50 @@ BOOST_AUTO_TEST_CASE(double_variable_declaration)
}));
}
+BOOST_AUTO_TEST_CASE(scoping)
+{
+ char const* text = R"(
+ contract test {
+ function f() public {
+ {
+ uint256 x;
+ }
+ x = 2;
+ }
+ }
+ )";
+ CHECK_ERROR(text, DeclarationError, "Undeclared identifier");
+}
+
+BOOST_AUTO_TEST_CASE(scoping_for)
+{
+ char const* text = R"(
+ contract test {
+ function f() public {
+ for (uint x = 0; x < 10; x ++){
+ x = 2;
+ }
+ }
+ }
+ )";
+ CHECK_SUCCESS(text);
+}
+
+BOOST_AUTO_TEST_CASE(scoping_for2)
+{
+ char const* text = R"(
+ contract test {
+ function f() public {
+ for (uint x = 0; x < 10; x ++){
+ x = 2;
+ }
+ x = 4;
+ }
+ }
+ )";
+ CHECK_ERROR(text, DeclarationError, "Undeclared identifier");
+}
+
BOOST_AUTO_TEST_CASE(name_shadowing)
{
char const* text = R"(