Skip to content

Commit 93dd8ad

Browse files
committed
Tests.
1 parent 290b1c3 commit 93dd8ad

24 files changed

+162
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
contract C {
2+
constructor() {
3+
uint256 x;
4+
assembly { x := 0 }
5+
f();
6+
}
7+
function f() internal pure {
8+
assembly "evmasm" ("memory-safe") { mstore(0, 0) }
9+
assembly ("memory-safe") { mstore(0, 0) }
10+
}
11+
function g() public pure {
12+
assembly { mstore(0, 0) }
13+
}
14+
}
15+
// ----
16+
// :C(creation) true
17+
// :C(runtime) false
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
contract C {
2+
constructor() {
3+
uint256 x;
4+
assembly { x := 0 }
5+
f();
6+
}
7+
function f() internal pure {
8+
assembly { mstore(0, 0) }
9+
}
10+
function g() public pure {
11+
assembly "evmasm" ("memory-safe") { mstore(0, 0) }
12+
}
13+
}
14+
// ----
15+
// :C(creation) false
16+
// :C(runtime) true
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function safe() pure returns (uint256 x) {
2+
assembly { x := 42 }
3+
assembly "evmasm" ("memory-safe") { mstore(0, 0) }
4+
}
5+
function unsafe() pure returns (uint256 x) {
6+
assembly { pop(mload(0)) }
7+
}
8+
contract C {
9+
constructor() {
10+
unsafe();
11+
}
12+
function f() public pure {
13+
safe();
14+
}
15+
}
16+
contract D {
17+
constructor() {
18+
safe();
19+
}
20+
function f() public pure {
21+
unsafe();
22+
}
23+
}
24+
// ----
25+
// :C(creation) false
26+
// :C(runtime) true
27+
// :D(creation) true
28+
// :D(runtime) false

0 commit comments

Comments
 (0)