Skip to content

Commit

Permalink
test: add semantic test for UDVT delete operator
Browse files Browse the repository at this point in the history
  • Loading branch information
xBA5ED committed Oct 31, 2023
1 parent 21438dc commit d763c46
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/libsolidity/semanticTests/userDefinedValueType/delete.sol
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

0 comments on commit d763c46

Please sign in to comment.