From ea937dca8995311c6ee8d73e0c45dab3d4c1a4f4 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Fri, 11 Jan 2013 16:27:12 -0500 Subject: [PATCH] test: add test for overloading logical negation operator --- src/test/run-pass/operator-overloading.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs index 6d0473a7d2c..13439c6e7e6 100644 --- a/src/test/run-pass/operator-overloading.rs +++ b/src/test/run-pass/operator-overloading.rs @@ -34,6 +34,12 @@ impl Point : ops::Neg { } } +impl Point : ops::Not { + pure fn not(&self) -> Point { + Point {x: !self.x, y: !self.y } + } +} + impl Point : ops::Index { pure fn index(&self, +x: bool) -> int { if x { self.x } else { self.y } @@ -55,6 +61,11 @@ fn main() { assert -p == Point {x: -11, y: -22}; assert p[true] == 11; assert p[false] == 22; + + let q = !p; + assert q.x == !(p.x); + assert q.y == !(p.y); + // Issue #1733 fn~(_x: int){}(p[true]); }