2011-06-15 13:19:50 -05:00
|
|
|
fn main() {
|
2011-07-27 07:19:39 -05:00
|
|
|
obj foo(mutable i: int) {
|
|
|
|
fn inc_by(incr: int) -> int { i += incr; ret i; }
|
2011-06-15 13:19:50 -05:00
|
|
|
fn inc_by_5() -> int { ret self.inc_by(5); }
|
2011-05-27 14:43:23 -05:00
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
// A test case showing that issue #324 is resolved. (It used to
|
|
|
|
// be that commenting out this (unused!) function produced a
|
|
|
|
// type error.)
|
|
|
|
// fn wrapper(int incr) -> int {
|
|
|
|
// ret self.inc_by(incr);
|
|
|
|
// }
|
|
|
|
fn get() -> int { ret i; }
|
|
|
|
}
|
2011-07-27 07:19:39 -05:00
|
|
|
let rs: int;
|
|
|
|
let o = foo(5);
|
2011-06-25 10:45:49 -05:00
|
|
|
rs = o.get();
|
|
|
|
assert (rs == 5);
|
|
|
|
rs = o.inc_by(3);
|
|
|
|
assert (rs == 8);
|
|
|
|
rs = o.get();
|
|
|
|
assert (rs == 8);
|
2011-08-19 17:16:48 -05:00
|
|
|
}
|