@@ -1827,6 +1827,53 @@ BOOST_AUTO_TEST_CASE(struct_referencing)
18271827 )
18281828}
18291829
1830+ BOOST_AUTO_TEST_CASE (enum_referencing)
1831+ {
1832+ char const * sourceCode = R"(
1833+ interface I {
1834+ enum Direction { A, B, Left, Right }
1835+ }
1836+ library L {
1837+ enum Direction { Left, Right }
1838+ function f() public pure returns (Direction) {
1839+ return Direction.Right;
1840+ }
1841+ function g() public pure returns (I.Direction) {
1842+ return I.Direction.Right;
1843+ }
1844+ }
1845+ contract C is I {
1846+ function f() public pure returns (Direction) {
1847+ return Direction.Right;
1848+ }
1849+ function g() public pure returns (I.Direction) {
1850+ return I.Direction.Right;
1851+ }
1852+ function h() public pure returns (L.Direction) {
1853+ return L.Direction.Right;
1854+ }
1855+ function x() public pure returns (L.Direction) {
1856+ return L.f();
1857+ }
1858+ function y() public pure returns (I.Direction) {
1859+ return L.g();
1860+ }
1861+ }
1862+ )" ;
1863+ ALSO_VIA_YUL (
1864+ DISABLE_EWASM_TESTRUN ()
1865+ compileAndRun (sourceCode, 0 , " L" );
1866+ ABI_CHECK (callContractFunction (" f()" ), encodeArgs (1 ));
1867+ ABI_CHECK (callContractFunction (" g()" ), encodeArgs (3 ));
1868+ compileAndRun (sourceCode, 0 , " C" , bytes (), map<string, h160>{{" :L" , m_contractAddress}});
1869+ ABI_CHECK (callContractFunction (" f()" ), encodeArgs (3 ));
1870+ ABI_CHECK (callContractFunction (" g()" ), encodeArgs (3 ));
1871+ ABI_CHECK (callContractFunction (" h()" ), encodeArgs (1 ));
1872+ ABI_CHECK (callContractFunction (" x()" ), encodeArgs (1 ));
1873+ ABI_CHECK (callContractFunction (" y()" ), encodeArgs (3 ));
1874+ )
1875+ }
1876+
18301877BOOST_AUTO_TEST_CASE (bytes_in_arguments)
18311878{
18321879 char const * sourceCode = R"(
@@ -2017,6 +2064,31 @@ BOOST_AUTO_TEST_CASE(failing_send)
20172064 BOOST_REQUIRE (callContractFunction (" callHelper(address)" , c_helperAddress) == encodeArgs (true , 20 ));
20182065}
20192066
2067+ BOOST_AUTO_TEST_CASE (return_string)
2068+ {
2069+ char const * sourceCode = R"(
2070+ contract Main {
2071+ string public s;
2072+ function set(string calldata _s) external {
2073+ s = _s;
2074+ }
2075+ function get1() public returns (string memory r) {
2076+ return s;
2077+ }
2078+ function get2() public returns (string memory r) {
2079+ r = s;
2080+ }
2081+ }
2082+ )" ;
2083+ compileAndRun (sourceCode, 0 , " Main" );
2084+ string s (" Julia" );
2085+ bytes args = encodeArgs (u256 (0x20 ), u256 (s.length ()), s);
2086+ BOOST_REQUIRE (callContractFunction (" set(string)" , asString (args)) == encodeArgs ());
2087+ ABI_CHECK (callContractFunction (" get1()" ), args);
2088+ ABI_CHECK (callContractFunction (" get2()" ), args);
2089+ ABI_CHECK (callContractFunction (" s()" ), args);
2090+ }
2091+
20202092BOOST_AUTO_TEST_CASE (return_multiple_strings_of_various_sizes)
20212093{
20222094 char const * sourceCode = R"(
0 commit comments