diff --git a/test/libsolidity/semanticTests/literalSuffixes/checked_suffixes.sol b/test/libsolidity/semanticTests/literalSuffixes/checked_suffixes.sol new file mode 100644 index 000000000..1e965a748 --- /dev/null +++ b/test/libsolidity/semanticTests/literalSuffixes/checked_suffixes.sol @@ -0,0 +1,18 @@ +function checkedSuffix(uint8 x) pure suffix returns (uint8) { + return x + 10; +} + +contract C { + function testCheckedSuffix() public pure returns (uint8) { + return 250 checkedSuffix; + } + + function testCheckedSuffixInUncheckedBlock() public pure returns (uint8) { + unchecked { + return 250 checkedSuffix; + } + } +} +// ---- +// testCheckedSuffix() -> FAILURE, hex"4e487b71", 0x11 +// testCheckedSuffixInUncheckedBlock() -> FAILURE, hex"4e487b71", 0x11 diff --git a/test/libsolidity/semanticTests/literalSuffixes/unchecked_suffixes.sol b/test/libsolidity/semanticTests/literalSuffixes/unchecked_suffixes.sol new file mode 100644 index 000000000..949c68675 --- /dev/null +++ b/test/libsolidity/semanticTests/literalSuffixes/unchecked_suffixes.sol @@ -0,0 +1,20 @@ +function uncheckedSuffix(uint8 x) pure suffix returns (uint8) { + unchecked { + return x + 10; + } +} + +contract C { + function testUncheckedSuffix() public pure returns (uint8) { + return 250 uncheckedSuffix; + } + + function testUncheckedSuffixInUncheckedBlock() public pure returns (uint8) { + unchecked { + return 250 uncheckedSuffix; + } + } +} +// ---- +// testUncheckedSuffix() -> 4 +// testUncheckedSuffixInUncheckedBlock() -> 4 diff --git a/test/libsolidity/semanticTests/operators/userDefined/unchecked_operators.sol b/test/libsolidity/semanticTests/operators/userDefined/unchecked_operators.sol index 684ea1b43..ec819fa7c 100644 --- a/test/libsolidity/semanticTests/operators/userDefined/unchecked_operators.sol +++ b/test/libsolidity/semanticTests/operators/userDefined/unchecked_operators.sol @@ -8,7 +8,7 @@ function uncheckedAdd(U8 x, U8 y) pure returns (U8) { using {uncheckedAdd as +} for U8 global; -contract D { +contract C { function testUncheckedOperator() public pure returns (U8) { return U8.wrap(250) + U8.wrap(10); } @@ -19,7 +19,6 @@ contract D { } } } - // ---- // testUncheckedOperator() -> 4 // testUncheckedOperatorInUncheckedBlock() -> 4