fixup! Tests for suffixes used to define operators

This commit is contained in:
Kamil Śliwak 2023-03-22 19:25:04 +01:00
parent 88fa1c89c5
commit 06b7114ae1

View File

@ -2,23 +2,23 @@ type B is bool;
using {bitnot as ~, bitor as |} for B global; using {bitnot as ~, bitor as |} for B global;
// NOTE: There are no literals of type B so these cannot be actually used on anything // NOTE: There are no literals of type B so these cannot be actually used on anything
function bitnot(B x) pure suffix returns (B) {
return B.wrap(!B.unwrap(x));
}
function bitor(B x, B y) pure suffix returns (B) { function bitor(B x, B y) pure suffix returns (B) {
return B.wrap(B.unwrap(x) || B.unwrap(y)); return B.wrap(B.unwrap(x) || B.unwrap(y));
} }
function bitnot(B x) pure suffix returns (B) {
return B.wrap(!B.unwrap(x));
}
contract C { contract C {
function testBinary() pure public returns (B) { function testBinary() pure public returns (B) {
B.wrap(true) | B.wrap(false); return B.wrap(true) | B.wrap(false);
} }
function testUnary() pure public returns (B) { function testUnary() pure public returns (B) {
-B.wrap(true); return ~B.wrap(true);
} }
} }
// ---- // ----
// testUnary() -> true // testBinary() -> true
// testBinary() -> false // testUnary() -> false