test: Add a max/min classes test case

This commit is contained in:
Patrick Walton 2012-07-24 16:39:26 -07:00
parent 728d16cfca
commit 22ef08293e

View File

@ -0,0 +1,30 @@
trait Product {
fn product() -> int;
}
struct Foo {
x: int;
y: int;
}
impl Foo {
fn sum() -> int {
self.x + self.y
}
}
impl Foo : Product {
fn product() -> int {
self.x * self.y
}
}
fn Foo(x: int, y: int) -> Foo {
Foo { x: x, y: y }
}
fn main() {
let foo = Foo(3, 20);
io::println(#fmt("%d %d", foo.sum(), foo.product()));
}