aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-11-11 01:16:21 +0800
committerchriseth <c@ethdev.com>2016-11-16 21:37:18 +0800
commite543bd34c0b4884b5a27555f698f50af6a1c0b81 (patch)
treeef2c12e4767a3d38603323212face114213ca4b4 /test
parentee3efa67a8d3eb4077786fd745c1925a916419f5 (diff)
downloaddexon-solidity-e543bd34c0b4884b5a27555f698f50af6a1c0b81.tar
dexon-solidity-e543bd34c0b4884b5a27555f698f50af6a1c0b81.tar.gz
dexon-solidity-e543bd34c0b4884b5a27555f698f50af6a1c0b81.tar.bz2
dexon-solidity-e543bd34c0b4884b5a27555f698f50af6a1c0b81.tar.lz
dexon-solidity-e543bd34c0b4884b5a27555f698f50af6a1c0b81.tar.xz
dexon-solidity-e543bd34c0b4884b5a27555f698f50af6a1c0b81.tar.zst
dexon-solidity-e543bd34c0b4884b5a27555f698f50af6a1c0b81.zip
Stored combined creation and runtime tags.
Includes a change to Assembly to allow tags from sub-assemblies to be used. Sorry, this get a bit bigger than I thought.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp63
-rw-r--r--test/libsolidity/SolidityExpressionCompiler.cpp2
2 files changed, 64 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index b05316dd..8f49b9c4 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -7777,6 +7777,48 @@ BOOST_AUTO_TEST_CASE(store_function_in_constructor)
BOOST_CHECK(callContractFunction("result_in_constructor()") == encodeArgs(u256(4)));
}
+// TODO: store bound internal library functions
+
+BOOST_AUTO_TEST_CASE(store_internal_unused_function_in_constructor)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function () internal returns (uint) x;
+ function C () {
+ x = unused;
+ }
+ function unused() internal returns (uint) {
+ return 7;
+ }
+ function t() returns (uint) {
+ return x();
+ }
+ }
+ )";
+
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("t()") == encodeArgs(u256(7)));
+}
+
+BOOST_AUTO_TEST_CASE(store_internal_unused_library_function_in_constructor)
+{
+ char const* sourceCode = R"(
+ library L { function x() internal returns (uint) { return 7; } }
+ contract C {
+ function () internal returns (uint) x;
+ function C () {
+ x = L.x;
+ }
+ function t() returns (uint) {
+ return x();
+ }
+ }
+ )";
+
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("t()") == encodeArgs(u256(7)));
+}
+
BOOST_AUTO_TEST_CASE(same_function_in_construction_and_runtime)
{
char const* sourceCode = R"(
@@ -7799,6 +7841,27 @@ BOOST_AUTO_TEST_CASE(same_function_in_construction_and_runtime)
BOOST_CHECK(callContractFunction("initial()") == encodeArgs(u256(4)));
}
+BOOST_AUTO_TEST_CASE(same_function_in_construction_and_runtime_equality_check)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function (uint) internal returns (uint) x;
+ function C() {
+ x = double;
+ }
+ function test() returns (bool) {
+ return x == double;
+ }
+ function double(uint _arg) returns (uint _ret) {
+ _ret = _arg * 2;
+ }
+ }
+ )";
+
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("test()") == encodeArgs(true));
+}
+
BOOST_AUTO_TEST_CASE(function_type_library_internal)
{
char const* sourceCode = R"(
diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp
index 09d556a5..e9a05745 100644
--- a/test/libsolidity/SolidityExpressionCompiler.cpp
+++ b/test/libsolidity/SolidityExpressionCompiler.cpp
@@ -136,7 +136,7 @@ bytes compileFirstExpression(
FirstExpressionExtractor extractor(*contract);
BOOST_REQUIRE(extractor.expression() != nullptr);
- CompilerContext context { CompilationMode::Runtime /* probably simpler */ };
+ CompilerContext context;
context.resetVisitedNodes(contract);
context.setInheritanceHierarchy(inheritanceHierarchy);
unsigned parametersSize = _localVariables.size(); // assume they are all one slot on the stack