Skip to content

Commit ea937dc

Browse files
committed
test: add test for overloading logical negation operator
1 parent 0de7aa5 commit ea937dc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test/run-pass/operator-overloading.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ impl Point : ops::Neg<Point> {
3434
}
3535
}
3636

37+
impl Point : ops::Not<Point> {
38+
pure fn not(&self) -> Point {
39+
Point {x: !self.x, y: !self.y }
40+
}
41+
}
42+
3743
impl Point : ops::Index<bool,int> {
3844
pure fn index(&self, +x: bool) -> int {
3945
if x { self.x } else { self.y }
@@ -55,6 +61,11 @@ fn main() {
5561
assert -p == Point {x: -11, y: -22};
5662
assert p[true] == 11;
5763
assert p[false] == 22;
64+
65+
let q = !p;
66+
assert q.x == !(p.x);
67+
assert q.y == !(p.y);
68+
5869
// Issue #1733
5970
fn~(_x: int){}(p[true]);
6071
}

0 commit comments

Comments
 (0)