-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add semantic test for UDVT delete operator
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
test/libsolidity/semanticTests/userDefinedValueType/delete.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,43 @@ | ||
type MyUInt256 is uint256; | ||
type MyBytes32 is bytes32; | ||
type MyAddress is address; | ||
type MyBool is bool; | ||
|
||
contract C { | ||
MyUInt256 a = MyUInt256.wrap(255); | ||
|
||
function f() external returns(MyUInt256) { | ||
delete a; | ||
return a; | ||
} | ||
|
||
function g(MyUInt256 b) external returns(MyUInt256) { | ||
delete b; | ||
return b; | ||
} | ||
|
||
function h(MyAddress b) external returns(MyAddress) { | ||
delete b; | ||
return b; | ||
} | ||
|
||
function i(MyBytes32 b) external returns(MyBytes32) { | ||
delete b; | ||
return b; | ||
} | ||
|
||
function j(MyBool b) external returns(MyBool) { | ||
delete b; | ||
return b; | ||
} | ||
} | ||
// ---- | ||
// f() -> 0 | ||
// g(uint256): 255 -> 0 | ||
// g(uint256): 0 -> 0 | ||
// h(address): 0xffffffffffffffffffffffffffffffffffffffff -> 0x0000000000000000000000000000000000000000 | ||
// h(address): 0x0000000000000000000000000000000000000000 -> 0x0000000000000000000000000000000000000000 | ||
// i(bytes32): 0xffffffffffffffffffffffffffffffffffffffff -> 0x0000000000000000000000000000000000000000 | ||
// i(bytes32): 0x0000000000000000000000000000000000000000 -> 0x0000000000000000000000000000000000000000 | ||
// j(bool): true -> false | ||
// j(bool): false -> false |