about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAndrew Paseltiner <apaseltiner@gmail.com>2013-01-11 16:27:12 -0500
committerAndrew Paseltiner <apaseltiner@gmail.com>2013-01-11 16:27:12 -0500
commitea937dca8995311c6ee8d73e0c45dab3d4c1a4f4 (patch)
treede8b13a5bce88cdf08f65e707498809338941a82 /src/test
parent0de7aa55062485835bc45b962f306dddf42f372d (diff)
downloadrust-ea937dca8995311c6ee8d73e0c45dab3d4c1a4f4.tar.gz
rust-ea937dca8995311c6ee8d73e0c45dab3d4c1a4f4.zip
test: add test for overloading logical negation operator
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/operator-overloading.rs11
1 files changed, 11 insertions, 0 deletions
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<Point> {
     }
 }
 
+impl Point : ops::Not<Point> {
+    pure fn not(&self) -> Point {
+        Point {x: !self.x, y: !self.y }
+    }
+}
+
 impl Point : ops::Index<bool,int> {
     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]);
 }