mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fixup! Tests for suffixes used to define operators
This commit is contained in:
parent
88fa1c89c5
commit
06b7114ae1
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user