Extracted some test cases from SolidityEndToEnd.cpp

This commit is contained in:
nishant-sachdeva
2021-11-29 21:27:43 +05:30
parent e0c85c6f58
commit 49d9f334aa
8 changed files with 168 additions and 210 deletions
@@ -0,0 +1,25 @@
contract Test {
bytes32 constant public b = "abcdefghijklmnopq";
string constant public x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca";
constructor() {
string memory xx = x;
bytes32 bb = b;
}
function getB() public returns (bytes32) { return b; }
function getX() public returns (string memory) { return x; }
function getX2() public returns (string memory r) { r = x; }
function unused() public returns (uint) {
"unusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunusedunused";
return 2;
}
}
// ====
// compileViaYul: also
// ----
// b() -> 0x6162636465666768696a6b6c6d6e6f7071000000000000000000000000000000
// x() -> 0x20, 0x35, 0x616265666768696a6b6c6d6e6f70716162636465666768696a6b6c6d6e6f7071, 44048183304486788312148433451363384677562177293131179093971701692629931524096
// getB() -> 0x6162636465666768696a6b6c6d6e6f7071000000000000000000000000000000
// getX() -> 0x20, 0x35, 0x616265666768696a6b6c6d6e6f70716162636465666768696a6b6c6d6e6f7071, 44048183304486788312148433451363384677562177293131179093971701692629931524096
// getX2() -> 0x20, 0x35, 0x616265666768696a6b6c6d6e6f70716162636465666768696a6b6c6d6e6f7071, 44048183304486788312148433451363384677562177293131179093971701692629931524096
// unused() -> 2
@@ -0,0 +1,20 @@
contract Main {
string public s;
function set(string calldata _s) external {
s = _s;
}
function get1() public returns (string memory r) {
return s;
}
function get2() public returns (string memory r) {
r = s;
}
}
// ====
// compileToEwasm: also
// compileViaYul: also
// ----
// set(string): 0x20, 5, "Julia" ->
// get1() -> 0x20, 5, "Julia"
// get2() -> 0x20, 5, "Julia"
// s() -> 0x20, 5, "Julia"