Skip to content

Commit

Permalink
test: Add a max/min classes test case
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed Jul 24, 2012
1 parent 728d16c commit 22ef082
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/test/run-pass/max-min-classes.rs
Original file line number Diff line number Diff line change
@@ -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()));
}

0 comments on commit 22ef082

Please sign in to comment.