diff --git a/test/libsolidity/analysis/FunctionCallGraph.cpp b/test/libsolidity/analysis/FunctionCallGraph.cpp index 7b67aeb44..624d50fb3 100644 --- a/test/libsolidity/analysis/FunctionCallGraph.cpp +++ b/test/libsolidity/analysis/FunctionCallGraph.cpp @@ -1702,6 +1702,72 @@ BOOST_AUTO_TEST_CASE(using_for) checkCallGraphExpectations(get<1>(graphs), expectedDeployedEdges); } +BOOST_AUTO_TEST_CASE(user_defined_binary_operator) +{ + unique_ptr compilerStack = parseAndAnalyzeContracts(R"( + type Int is int128; + using {add as +} for Int; + + function add(Int, Int) returns (Int) { + return Int.wrap(0); + } + + contract C { + function test() public { + Int.wrap(0) + Int.wrap(1); + } + } + )"s); + tuple graphs = collectGraphs(*compilerStack); + + map expectedCreationEdges = { + {"C", {}}, + }; + + map expectedDeployedEdges = { + {"C", { + {"Entry", "function C.test()"}, + {"function C.test()", "function add(Int,Int)"}, + }}, + }; + + checkCallGraphExpectations(get<0>(graphs), expectedCreationEdges); + checkCallGraphExpectations(get<1>(graphs), expectedDeployedEdges); +} + +BOOST_AUTO_TEST_CASE(user_defined_unary_operator) +{ + unique_ptr compilerStack = parseAndAnalyzeContracts(R"( + type Int is int128; + using {sub as -} for Int; + + function sub(Int) returns (Int) { + return Int.wrap(0); + } + + contract C { + function test() public { + -Int.wrap(1); + } + } + )"s); + tuple graphs = collectGraphs(*compilerStack); + + map expectedCreationEdges = { + {"C", {}}, + }; + + map expectedDeployedEdges = { + {"C", { + {"Entry", "function C.test()"}, + {"function C.test()", "function sub(Int)"}, + }}, + }; + + checkCallGraphExpectations(get<0>(graphs), expectedCreationEdges); + checkCallGraphExpectations(get<1>(graphs), expectedDeployedEdges); +} + BOOST_AUTO_TEST_CASE(getters) { unique_ptr compilerStack = parseAndAnalyzeContracts(R"(