From f20a604c5a941ed5117d3e472b5ad93bed02fd97 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 11 Jan 2016 13:55:58 +0100 Subject: Allow aliases during import. --- test/libsolidity/Imports.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/libsolidity') diff --git a/test/libsolidity/Imports.cpp b/test/libsolidity/Imports.cpp index f0f67785..c074b332 100644 --- a/test/libsolidity/Imports.cpp +++ b/test/libsolidity/Imports.cpp @@ -101,6 +101,31 @@ BOOST_AUTO_TEST_CASE(simple_alias) BOOST_CHECK(c.compile()); } +BOOST_AUTO_TEST_CASE(complex_import) +{ + CompilerStack c; + c.addSource("a", "contract A {} contract B {} contract C { struct S { uint a; } }"); + c.addSource("b", "import \"a\" as x; import {B as b, C as c, C} from \"a\"; " + "contract D is b { function f(c.S var1, x.C.S var2, C.S var3) internal {} }"); + BOOST_CHECK(c.compile()); +} + +BOOST_AUTO_TEST_CASE(name_clash_in_import) +{ + CompilerStack c; + c.addSource("a", "contract A {}"); + c.addSource("b", "import \"a\"; contract A {} "); + BOOST_CHECK(!c.compile()); + c.addSource("b", "import \"a\" as A; contract A {} "); + BOOST_CHECK(!c.compile()); + c.addSource("b", "import {A as b} from \"a\"; contract b {} "); + BOOST_CHECK(!c.compile()); + c.addSource("b", "import {A} from \"a\"; contract A {} "); + BOOST_CHECK(!c.compile()); + c.addSource("b", "import {A} from \"a\"; contract B {} "); + BOOST_CHECK(c.compile()); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit