Skip to content

Commit 22ef082

Browse files
committed
test: Add a max/min classes test case
1 parent 728d16c commit 22ef082

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Diff for: src/test/run-pass/max-min-classes.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
trait Product {
2+
fn product() -> int;
3+
}
4+
5+
struct Foo {
6+
x: int;
7+
y: int;
8+
}
9+
10+
impl Foo {
11+
fn sum() -> int {
12+
self.x + self.y
13+
}
14+
}
15+
16+
impl Foo : Product {
17+
fn product() -> int {
18+
self.x * self.y
19+
}
20+
}
21+
22+
fn Foo(x: int, y: int) -> Foo {
23+
Foo { x: x, y: y }
24+
}
25+
26+
fn main() {
27+
let foo = Foo(3, 20);
28+
io::println(#fmt("%d %d", foo.sum(), foo.product()));
29+
}
30+

0 commit comments

Comments
 (0)