Skip to content

Commit 1a9e66f

Browse files
committed
Tests
1 parent cdf243a commit 1a9e66f

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
contract C {
2+
uint32[] s;
3+
constructor()
4+
{
5+
s.push();
6+
s.push();
7+
}
8+
function f() external returns (uint)
9+
{
10+
(s[1], s) = (4, [0]);
11+
s = [0];
12+
s.push();
13+
return s[1];
14+
// used to return 4 via IR.
15+
}
16+
}
17+
// ----
18+
// constructor()
19+
// gas irOptimized: 237351
20+
// gas legacy: 221315
21+
// gas legacyOptimized: 185247
22+
// f() -> 0
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
contract C {
2+
string log;
3+
function() external[] fs;
4+
function() external[] gs;
5+
6+
function a() external {
7+
log = string.concat(log, "[a called]");
8+
}
9+
function b() external {
10+
log = string.concat(log, "[b called]");
11+
}
12+
13+
function f(function() external[] calldata x) external {
14+
fs = x;
15+
}
16+
function g(function() external[] memory x) public {
17+
fs = x;
18+
}
19+
function test() external returns (string memory) {
20+
log = "";
21+
function() external[] memory x = new function() external[](2);
22+
x[0] = this.a;
23+
x[1] = this.b;
24+
this.f(x);
25+
fs[0]();
26+
fs[1]();
27+
return log;
28+
}
29+
function test2() external returns (string memory) {
30+
log = "";
31+
function() external[] memory x = new function() external[](2);
32+
x[0] = this.b;
33+
x[1] = this.a;
34+
g(x);
35+
fs[0]();
36+
fs[1]();
37+
return log;
38+
}
39+
function test3() external returns (string memory) {
40+
log = "";
41+
gs = fs;
42+
gs[0]();
43+
gs[1]();
44+
return log;
45+
}
46+
}
47+
// ----
48+
// test() -> 0x20, 0x14, "[a called][b called]"
49+
// gas irOptimized: 116724
50+
// gas legacy: 120707
51+
// gas legacyOptimized: 119241
52+
// test2() -> 0x20, 0x14, "[b called][a called]"
53+
// test3() -> 0x20, 0x14, "[b called][a called]"
54+
// gas irOptimized: 103304
55+
// gas legacy: 104648
56+
// gas legacyOptimized: 104075

0 commit comments

Comments
 (0)