Skip to content

Commit

Permalink
Add changelog entry and test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
ekpyron committed Apr 12, 2018
1 parent 6b0fcda commit 69dab20
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Features:
* General: Introduce new constructor syntax using the ``constructor`` keyword as experimental 0.5.0 feature.
* Inheritance: Error when using empty parentheses for base class constructors that require arguments as experimental 0.5.0 feature.
* Inheritance: Error when using no parentheses in modifier-style constructor calls as experimental 0.5.0 feature.
* Type System: Allow access to constants via contract name.

Bugfixes:
* Code Generator: Allow ``block.blockhash`` without being called.
Expand Down
18 changes: 18 additions & 0 deletions test/libsolidity/SolidityEndToEndTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7173,6 +7173,24 @@ BOOST_AUTO_TEST_CASE(cross_contract_types)
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(3)));
}

BOOST_AUTO_TEST_CASE(cross_contract_constants)
{
char const* sourceCode = R"(
contract C {
uint constant a = 33 * b + 4;
uint constant b = 44;
}
contract Test {
uint constant b = 66;
function f() returns (uint r) {
r = C.a;
}
}
)";
compileAndRun(sourceCode, 0, "Test");
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1456)));
}

BOOST_AUTO_TEST_CASE(simple_throw)
{
char const* sourceCode = R"(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
contract A {
uint constant a = 0x1;
}
contract C {
function f() public pure returns (uint) {
return A.a;
}
}
10 changes: 10 additions & 0 deletions test/libsolidity/syntaxTests/constants/cross_contract_base.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
contract A {
uint constant c = 0;
}
contract B is A {
}
contract C {
uint constant c = B.c;
}
// ----
// TypeError: (95-98): Member "c" not found or not visible after argument-dependent lookup in type(contract B)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
contract A {
uint constant c = B.c;
}
contract B {
uint constant c = A.c;
}
// ----
// Some Error: This should fail with some error!
10 changes: 10 additions & 0 deletions test/libsolidity/syntaxTests/constants/cross_contract_super.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
contract A {
uint constant c = 0;
}
contract B is A {
}
contract C {
uint constant c = B.super.c;
}
// ----
// TypeError: (95-102): Member "super" not found or not visible after argument-dependent lookup in type(contract B)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
contract A {
uint constant c = 0;
}
contract C {
uint constant c = A.this.c;
}
// ----
// TypeError: (75-81): Member "this" not found or not visible after argument-dependent lookup in type(contract A)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
contract A {
uint a = 0x1;
}
contract C {
function f() public pure returns (uint) {
return A.a;
}
}
// ----
// TypeError: (107-110): Member "a" not found or not visible after argument-dependent lookup in type(contract A)

0 comments on commit 69dab20

Please sign in to comment.