aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-12-18 22:56:26 +0800
committerchriseth <c@ethdev.com>2015-12-18 23:50:14 +0800
commit54e3637d234653e0f0e282220e3a628766a86adb (patch)
tree24673c46220072ed53017d15215507e200273778 /test/libsolidity
parent938ed70935a434babb8c52e6a2985b98216b37c6 (diff)
downloaddexon-solidity-54e3637d234653e0f0e282220e3a628766a86adb.tar.gz
dexon-solidity-54e3637d234653e0f0e282220e3a628766a86adb.tar.zst
dexon-solidity-54e3637d234653e0f0e282220e3a628766a86adb.zip
Add structs and enums to contract types.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp15
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp15
2 files changed, 30 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index f625f533..d57360dc 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -5377,6 +5377,21 @@ BOOST_AUTO_TEST_CASE(library_stray_values)
BOOST_CHECK(callContractFunction("f(uint256)", u256(33)) == encodeArgs(u256(42)));
}
+BOOST_AUTO_TEST_CASE(cross_contract_types)
+{
+ char const* sourceCode = R"(
+ contract Lib { struct S {uint a; uint b; } }
+ contract Test {
+ function f() returns (uint r) {
+ var x = Lib.S({a: 2, b: 3});
+ r = x.b;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Test");
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(3)));
+}
+
BOOST_AUTO_TEST_CASE(simple_throw)
{
char const* sourceCode = R"(
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 1242e801..fc03dc7c 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -1348,6 +1348,21 @@ BOOST_AUTO_TEST_CASE(enum_member_access)
BOOST_CHECK(success(text));
}
+BOOST_AUTO_TEST_CASE(enum_member_access_accross_contracts)
+{
+ char const* text = R"(
+ contract Interface {
+ enum MyEnum { One, Two }
+ }
+ contract Impl {
+ function test() returns (Interface.MyEnum) {
+ return Interface.MyEnum.One;
+ }
+ }
+ )";
+ BOOST_CHECK(success(text));
+}
+
BOOST_AUTO_TEST_CASE(enum_invalid_member_access)
{
char const* text = R"(