about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLindsey Kuper <lkuper@mozilla.com>2011-08-09 15:42:48 -0700
committerLindsey Kuper <lkuper@mozilla.com>2011-08-09 15:42:48 -0700
commitbf84d20f7cfba43abb7c895f31b3da23c1fd4a9a (patch)
tree9c0545611dc433fa5051e10604db33ed1d9e56b9
parentfed62af8873bd7319a380dc9f07cf9fef9414131 (diff)
downloadrust-bf84d20f7cfba43abb7c895f31b3da23c1fd4a9a.tar.gz
rust-bf84d20f7cfba43abb7c895f31b3da23c1fd4a9a.zip
Move along; nothing to see here...
-rw-r--r--src/test/run-pass/anon-obj-cats.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/test/run-pass/anon-obj-cats.rs b/src/test/run-pass/anon-obj-cats.rs
new file mode 100644
index 00000000000..ca093f0cb9b
--- /dev/null
+++ b/src/test/run-pass/anon-obj-cats.rs
@@ -0,0 +1,54 @@
+fn main() {
+
+    // The Internet made me do it.
+
+    obj cat() {
+        fn ack() -> str {
+            ret "ack";
+        }
+        fn meow() -> str {
+            ret "meow";
+        }
+        fn zzz() -> str {
+            ret self.meow();
+        }
+    }
+
+    let shortcat = cat();
+
+    let longcat = obj() {
+        fn lol() -> str {
+            ret "lol";
+        }
+        fn nyan() -> str {
+            ret "nyan";
+        }
+        with shortcat
+    };
+
+    let longercat = obj() {
+        fn meow() -> str {
+            ret "zzz";
+        }
+        with shortcat
+    };
+
+    let evenlongercat = obj() {
+        fn meow() -> str {
+            ret "zzzzzz";
+        }
+        with longercat
+    };
+
+    // Tests self-call.
+    assert (shortcat.zzz() == "meow");
+
+    // Tests forwarding/backwarding + self-call.
+    assert (longcat.zzz() == "meow");
+
+    // Tests forwarding/backwarding + self-call + override.
+    assert (longercat.zzz() == "zzz");
+
+    // Tests two-level forwarding/backwarding + self-call + override.
+    assert (evenlongercat.zzz() == "zzzzzz");
+}