From d763c468fcbe4cef663dda24ae8d68e2366cd7d1 Mon Sep 17 00:00:00 2001 From: xBA5ED <83727748+xBA5ED@users.noreply.github.com> Date: Tue, 31 Oct 2023 03:11:01 +0100 Subject: [PATCH] test: add semantic test for UDVT delete operator --- .../userDefinedValueType/delete.sol | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/libsolidity/semanticTests/userDefinedValueType/delete.sol diff --git a/test/libsolidity/semanticTests/userDefinedValueType/delete.sol b/test/libsolidity/semanticTests/userDefinedValueType/delete.sol new file mode 100644 index 000000000000..b5fb48f6b5d5 --- /dev/null +++ b/test/libsolidity/semanticTests/userDefinedValueType/delete.sol @@ -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 \ No newline at end of file