rust/src/test/run-pass/standalone-method.rs

19 lines
398 B
Rust
Raw Normal View History

2011-07-28 12:37:11 -05:00
// Test case for issue #435.
obj foo(x: int) {
fn add5(n: int) -> int { ret n + x; }
2011-07-28 12:37:11 -05:00
}
fn add5(n: int) -> int { ret n + 5; }
2011-07-28 12:37:11 -05:00
fn main() {
let fiveplusseven = bind add5(7);
assert (add5(7) == 12);
assert (fiveplusseven() == 12);
2011-07-28 12:37:11 -05:00
let my_foo = foo(5);
2011-07-28 12:37:11 -05:00
let fiveplusseven_too = bind my_foo.add5(7);
assert (my_foo.add5(7) == 12);
assert (fiveplusseven_too() == 12);
2011-07-28 12:37:11 -05:00
}