aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/libjulia/ExpressionSplitter.cpp (renamed from test/libjulia/ExpressionBreaker.cpp)6
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp25
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/575_member_member_getter_call_without_parentheses.sol19
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/576_member_getter_call_without_parentheses.sol17
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/577_member_getter_call_without_parentheses_missing_function.sol15
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/578_private_member_getter_call_without_parentheses.sol17
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/579_member_getter_call_without_parentheses_private_function.sol17
-rw-r--r--test/tools/fuzzer.cpp38
8 files changed, 140 insertions, 14 deletions
diff --git a/test/libjulia/ExpressionBreaker.cpp b/test/libjulia/ExpressionSplitter.cpp
index de8d2251..9707fa86 100644
--- a/test/libjulia/ExpressionBreaker.cpp
+++ b/test/libjulia/ExpressionSplitter.cpp
@@ -20,7 +20,7 @@
#include <test/libjulia/Common.h>
-#include <libjulia/optimiser/ExpressionBreaker.h>
+#include <libjulia/optimiser/ExpressionSplitter.h>
#include <libjulia/optimiser/NameCollector.h>
#include <libsolidity/inlineasm/AsmPrinter.h>
@@ -43,12 +43,12 @@ do\
auto result = parse(_original, false);\
NameDispenser nameDispenser;\
nameDispenser.m_usedNames = NameCollector(*result.first).names();\
- ExpressionBreaker{nameDispenser}(*result.first);\
+ ExpressionSplitter{nameDispenser}(*result.first);\
BOOST_CHECK_EQUAL(assembly::AsmPrinter{}(*result.first), format(_expectation, false));\
}\
while(false)
-BOOST_AUTO_TEST_SUITE(YulExpressionBreaker)
+BOOST_AUTO_TEST_SUITE(YulExpressionSplitter)
BOOST_AUTO_TEST_CASE(smoke_test)
{
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index f65c8b27..7a496e64 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -4519,6 +4519,31 @@ BOOST_AUTO_TEST_CASE(library_call_protection)
ABI_CHECK(callContractFunction("pu()"), encodeArgs(2));
}
+
+BOOST_AUTO_TEST_CASE(library_staticcall_delegatecall)
+{
+ char const* sourceCode = R"(
+ library Lib {
+ function x() public view returns (uint) {
+ return 1;
+ }
+ }
+ contract Test {
+ uint t;
+ function f() public returns (uint) {
+ t = 2;
+ return this.g();
+ }
+ function g() public view returns (uint) {
+ return Lib.x();
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Lib");
+ compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
+}
+
BOOST_AUTO_TEST_CASE(store_bytes)
{
// this test just checks that the copy loop does not mess up the stack
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/575_member_member_getter_call_without_parentheses.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/575_member_member_getter_call_without_parentheses.sol
new file mode 100644
index 00000000..61f43103
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/575_member_member_getter_call_without_parentheses.sol
@@ -0,0 +1,19 @@
+contract A{
+ function f() public pure{
+
+ }
+}
+contract B{
+ A public a;
+}
+contract C{
+ B public b;
+}
+contract D{
+ C c;
+ function f() public view{
+ c.b.a.f();
+ }
+}
+// ----
+// TypeError: (170-175): Member "a" not found or not visible after argument-dependent lookup in function () view external returns (contract B). Did you intend to call the function?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/576_member_getter_call_without_parentheses.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/576_member_getter_call_without_parentheses.sol
new file mode 100644
index 00000000..bdc5fdc7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/576_member_getter_call_without_parentheses.sol
@@ -0,0 +1,17 @@
+contract A{
+ function f() public pure{
+
+ }
+}
+contract B{
+ A public a;
+}
+contract C{
+ B b;
+ function f() public view{
+ b.a.f();
+ }
+}
+
+// ----
+// TypeError: (140-145): Member "f" not found or not visible after argument-dependent lookup in function () view external returns (contract A). Did you intend to call the function?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/577_member_getter_call_without_parentheses_missing_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/577_member_getter_call_without_parentheses_missing_function.sol
new file mode 100644
index 00000000..d204d926
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/577_member_getter_call_without_parentheses_missing_function.sol
@@ -0,0 +1,15 @@
+contract A{
+
+}
+contract B{
+ A public a;
+}
+contract C{
+ B b;
+ function f() public view{
+ b.a.f();
+ }
+}
+
+// ----
+// TypeError: (104-109): Member "f" not found or not visible after argument-dependent lookup in function () view external returns (contract A). Did you intend to call the function?
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/578_private_member_getter_call_without_parentheses.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/578_private_member_getter_call_without_parentheses.sol
new file mode 100644
index 00000000..e71da372
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/578_private_member_getter_call_without_parentheses.sol
@@ -0,0 +1,17 @@
+contract A{
+ function f() public pure{
+
+ }
+}
+contract B{
+ A private a;
+}
+contract C{
+ B b;
+ function f() public view{
+ b.a.f();
+ }
+}
+
+// ----
+// TypeError: (141-144): Member "a" not found or not visible after argument-dependent lookup in contract B.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/579_member_getter_call_without_parentheses_private_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/579_member_getter_call_without_parentheses_private_function.sol
new file mode 100644
index 00000000..18932238
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/579_member_getter_call_without_parentheses_private_function.sol
@@ -0,0 +1,17 @@
+contract A{
+ function f() private pure{
+
+ }
+}
+contract B{
+ A public a;
+}
+contract C{
+ B b;
+ function f() public view{
+ b.a.f();
+ }
+}
+
+// ----
+// TypeError: (141-146): Member "f" not found or not visible after argument-dependent lookup in function () view external returns (contract A). Did you intend to call the function?
diff --git a/test/tools/fuzzer.cpp b/test/tools/fuzzer.cpp
index f7b42b25..bb020f8c 100644
--- a/test/tools/fuzzer.cpp
+++ b/test/tools/fuzzer.cpp
@@ -28,6 +28,7 @@
#include <boost/program_options.hpp>
#include <string>
+#include <sstream>
#include <iostream>
using namespace std;
@@ -48,15 +49,17 @@ string contains(string const& _haystack, vector<string> const& _needles)
return "";
}
-void testConstantOptimizer()
+void testConstantOptimizer(string const& input)
{
if (!quiet)
cout << "Testing constant optimizer" << endl;
vector<u256> numbers;
- while (!cin.eof())
+ stringstream sin(input);
+
+ while (!sin.eof())
{
h256 data;
- cin.read(reinterpret_cast<char*>(data.data()), 32);
+ sin.read(reinterpret_cast<char*>(data.data()), 32);
numbers.push_back(u256(data));
}
if (!quiet)
@@ -108,20 +111,18 @@ void runCompiler(string input)
}
}
-void testStandardCompiler()
+void testStandardCompiler(string const& input)
{
if (!quiet)
cout << "Testing compiler via JSON interface." << endl;
- string input = readStandardInput();
runCompiler(input);
}
-void testCompiler(bool optimize)
+void testCompiler(string const& input, bool optimize)
{
if (!quiet)
cout << "Testing compiler " << (optimize ? "with" : "without") << " optimizer." << endl;
- string input = readStandardInput();
Json::Value config = Json::objectValue;
config["language"] = "Solidity";
@@ -168,15 +169,24 @@ Allowed options)",
"Expects a binary string of up to 32 bytes on stdin."
)
(
+ "input-file",
+ po::value<string>(),
+ "input file"
+ )
+ (
"without-optimizer",
"Run without optimizations. Cannot be used together with standard-json."
);
+ // All positional options should be interpreted as input files
+ po::positional_options_description filesPositions;
+ filesPositions.add("input-file", 1);
+
po::variables_map arguments;
try
{
po::command_line_parser cmdLineParser(argc, argv);
- cmdLineParser.options(options);
+ cmdLineParser.options(options).positional(filesPositions);
po::store(cmdLineParser.run(), arguments);
}
catch (po::error const& _exception)
@@ -185,17 +195,23 @@ Allowed options)",
return 1;
}
+ string input;
+ if (arguments.count("input-file"))
+ input = readFileAsString(arguments["input-file"].as<string>());
+ else
+ input = readStandardInput();
+
if (arguments.count("quiet"))
quiet = true;
if (arguments.count("help"))
cout << options;
else if (arguments.count("const-opt"))
- testConstantOptimizer();
+ testConstantOptimizer(input);
else if (arguments.count("standard-json"))
- testStandardCompiler();
+ testStandardCompiler(input);
else
- testCompiler(!arguments.count("without-optimizer"));
+ testCompiler(input, !arguments.count("without-optimizer"));
return 0;
}