mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add more semantic tests for balance/extcodehash
This commit is contained in:
parent
6479138dd4
commit
e93992257e
@ -0,0 +1,28 @@
|
||||
contract C {
|
||||
constructor() payable {}
|
||||
|
||||
function f() public returns (uint256 ret) {
|
||||
assembly {
|
||||
ret := balance(0)
|
||||
}
|
||||
}
|
||||
function g() public returns (uint256 ret) {
|
||||
assembly {
|
||||
ret := balance(1)
|
||||
}
|
||||
}
|
||||
function h() public returns (uint256 ret) {
|
||||
assembly {
|
||||
ret := balance(address())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// EVMVersion: >=constantinople
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// constructor(), 23 wei ->
|
||||
// f() -> 0
|
||||
// g() -> 1
|
||||
// h() -> 23
|
25
test/libsolidity/semanticTests/various/codehash_assembly.sol
Normal file
25
test/libsolidity/semanticTests/various/codehash_assembly.sol
Normal file
@ -0,0 +1,25 @@
|
||||
contract C {
|
||||
function f() public returns (bytes32 ret) {
|
||||
assembly {
|
||||
ret := extcodehash(0)
|
||||
}
|
||||
}
|
||||
function g() public returns (bytes32 ret) {
|
||||
assembly {
|
||||
ret := extcodehash(1)
|
||||
}
|
||||
}
|
||||
function h() public returns (bool ret) {
|
||||
assembly {
|
||||
ret := iszero(iszero(extcodehash(address())))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// EVMVersion: >=constantinople
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0
|
||||
// g() -> 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
|
||||
// h() -> true
|
Loading…
Reference in New Issue
Block a user