提交 bf84d20f 编写于 作者: L Lindsey Kuper

Move along; nothing to see here...

上级 fed62af8
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");
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册