diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-07-24 16:39:26 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-07-24 16:39:26 -0700 |
| commit | 22ef08293e69a5bec54874c30ec7652e7d917da0 (patch) | |
| tree | 99f4ebdfaa84e3a28732c615f4d91ccd6e028472 /src | |
| parent | 728d16cfca4d1d12fdabbcc666071810c4d94dc9 (diff) | |
| download | rust-22ef08293e69a5bec54874c30ec7652e7d917da0.tar.gz rust-22ef08293e69a5bec54874c30ec7652e7d917da0.zip | |
test: Add a max/min classes test case
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/run-pass/max-min-classes.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/run-pass/max-min-classes.rs b/src/test/run-pass/max-min-classes.rs new file mode 100644 index 00000000000..61e4bc047f4 --- /dev/null +++ b/src/test/run-pass/max-min-classes.rs @@ -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())); +} + |
