aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/Imports.cpp37
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp76
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp27
3 files changed, 84 insertions, 56 deletions
diff --git a/test/libsolidity/Imports.cpp b/test/libsolidity/Imports.cpp
index bc6adc26..56895fdc 100644
--- a/test/libsolidity/Imports.cpp
+++ b/test/libsolidity/Imports.cpp
@@ -164,6 +164,43 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings)
BOOST_CHECK(c.compile());
}
+BOOST_AUTO_TEST_CASE(filename_with_period)
+{
+ CompilerStack c;
+ c.addSource("a/a.sol", "import \".b.sol\"; contract A is B {} pragma solidity >=0.0;");
+ c.addSource("a/.b.sol", "contract B {} pragma solidity >=0.0;");
+ BOOST_CHECK(!c.compile());
+}
+
+BOOST_AUTO_TEST_CASE(context_dependent_remappings_ensure_default_and_module_preserved)
+{
+ CompilerStack c;
+ c.setRemappings(vector<string>{"foo=vendor/foo_2.0.0", "vendor/bar:foo=vendor/foo_1.0.0", "bar=vendor/bar"});
+ c.addSource("main.sol", "import \"foo/foo.sol\"; import {Bar} from \"bar/bar.sol\"; contract Main is Foo2, Bar {} pragma solidity >=0.0;");
+ c.addSource("vendor/bar/bar.sol", "import \"foo/foo.sol\"; contract Bar {Foo1 foo;} pragma solidity >=0.0;");
+ c.addSource("vendor/foo_1.0.0/foo.sol", "contract Foo1 {} pragma solidity >=0.0;");
+ c.addSource("vendor/foo_2.0.0/foo.sol", "contract Foo2 {} pragma solidity >=0.0;");
+ BOOST_CHECK(c.compile());
+}
+
+BOOST_AUTO_TEST_CASE(context_dependent_remappings_order_independent)
+{
+ CompilerStack c;
+ c.setRemappings(vector<string>{"a:x/y/z=d", "a/b:x=e"});
+ c.addSource("a/main.sol", "import \"x/y/z/z.sol\"; contract Main is D {} pragma solidity >=0.0;");
+ c.addSource("a/b/main.sol", "import \"x/y/z/z.sol\"; contract Main is E {} pragma solidity >=0.0;");
+ c.addSource("d/z.sol", "contract D {} pragma solidity >=0.0;");
+ c.addSource("e/y/z/z.sol", "contract E {} pragma solidity >=0.0;");
+ BOOST_CHECK(c.compile());
+ CompilerStack d;
+ d.setRemappings(vector<string>{"a/b:x=e", "a:x/y/z=d"});
+ d.addSource("a/main.sol", "import \"x/y/z/z.sol\"; contract Main is D {} pragma solidity >=0.0;");
+ d.addSource("a/b/main.sol", "import \"x/y/z/z.sol\"; contract Main is E {} pragma solidity >=0.0;");
+ d.addSource("d/z.sol", "contract D {} pragma solidity >=0.0;");
+ d.addSource("e/y/z/z.sol", "contract E {} pragma solidity >=0.0;");
+ BOOST_CHECK(d.compile());
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 94d4fb7f..19161831 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2770,6 +2770,28 @@ BOOST_AUTO_TEST_CASE(event_no_arguments)
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit()")));
}
+BOOST_AUTO_TEST_CASE(event_access_through_base_name)
+{
+ char const* sourceCode = R"(
+ contract A {
+ event x();
+ }
+ contract B is A {
+ function f() returns (uint) {
+ A.x();
+ return 1;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ callContractFunction("f()");
+ BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
+ BOOST_CHECK(m_logs[0].data.empty());
+ BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("x()")));
+}
+
BOOST_AUTO_TEST_CASE(event_anonymous)
{
char const* sourceCode = R"(
@@ -4847,60 +4869,6 @@ BOOST_AUTO_TEST_CASE(proper_order_of_overwriting_of_attributes)
BOOST_CHECK(callContractFunction("ok()") == encodeArgs(false));
}
-BOOST_AUTO_TEST_CASE(proper_overwriting_accessor_by_function)
-{
- // bug #1798
- char const* sourceCode = R"(
- contract attribute {
- bool ok = false;
- }
- contract func {
- function ok() returns (bool) { return true; }
- }
-
- contract attr_func is attribute, func {
- function checkOk() returns (bool) { return ok(); }
- }
- contract func_attr is func, attribute {
- function checkOk() returns (bool) { return ok; }
- }
- )";
- compileAndRun(sourceCode, 0, "attr_func");
- BOOST_CHECK(callContractFunction("ok()") == encodeArgs(true));
- compileAndRun(sourceCode, 0, "func_attr");
- BOOST_CHECK(callContractFunction("checkOk()") == encodeArgs(false));
-}
-
-
-BOOST_AUTO_TEST_CASE(overwriting_inheritance)
-{
- // bug #1798
- char const* sourceCode = R"(
- contract A {
- function ok() returns (uint) { return 1; }
- }
- contract B {
- function ok() returns (uint) { return 2; }
- }
- contract C {
- uint ok = 6;
- }
- contract AB is A, B {
- function ok() returns (uint) { return 4; }
- }
- contract reversedE is C, AB {
- function checkOk() returns (uint) { return ok(); }
- }
- contract E is AB, C {
- function checkOk() returns (uint) { return ok; }
- }
- )";
- compileAndRun(sourceCode, 0, "reversedE");
- BOOST_CHECK(callContractFunction("checkOk()") == encodeArgs(4));
- compileAndRun(sourceCode, 0, "E");
- BOOST_CHECK(callContractFunction("checkOk()") == encodeArgs(6));
-}
-
BOOST_AUTO_TEST_CASE(struct_assign_reference_to_struct)
{
char const* sourceCode = R"(
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 576421fd..9f6ea2b3 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -1056,7 +1056,9 @@ BOOST_AUTO_TEST_CASE(modifier_overrides_function)
contract A { modifier mod(uint a) { _; } }
contract B is A { function mod(uint a) { } }
)";
- CHECK_ERROR(text, TypeError, "");
+ // Error: Identifier already declared.
+ // Error: Override changes modifier to function.
+ CHECK_ERROR_ALLOW_MULTI(text, DeclarationError, "");
}
BOOST_AUTO_TEST_CASE(function_overrides_modifier)
@@ -1065,7 +1067,9 @@ BOOST_AUTO_TEST_CASE(function_overrides_modifier)
contract A { function mod(uint a) { } }
contract B is A { modifier mod(uint a) { _; } }
)";
- CHECK_ERROR(text, TypeError, "");
+ // Error: Identifier already declared.
+ // Error: Override changes function to modifier.
+ CHECK_ERROR_ALLOW_MULTI(text, DeclarationError, "");
}
BOOST_AUTO_TEST_CASE(modifier_returns_value)
@@ -4304,6 +4308,25 @@ BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable)
CHECK_ERROR(text, TypeError, "");
}
+BOOST_AUTO_TEST_CASE(function_variable_mixin)
+{
+ // bug #1798 (cpp-ethereum), related to #1286 (solidity)
+ char const* text = R"(
+ contract attribute {
+ bool ok = false;
+ }
+ contract func {
+ function ok() returns (bool) { return true; }
+ }
+
+ contract attr_func is attribute, func {
+ function checkOk() returns (bool) { return ok(); }
+ }
+ )";
+ CHECK_ERROR(text, DeclarationError, "");
+}
+
+
BOOST_AUTO_TEST_CASE(payable_constant_conflict)
{
char const* text = R"(