Test case showing that issue 324 is resolved.
This commit is contained in:
parent
0cbcf92749
commit
867e9fb030
1 changed files with 39 additions and 0 deletions
39
src/test/run-pass/obj-self-4.rs
Normal file
39
src/test/run-pass/obj-self-4.rs
Normal file
|
@ -0,0 +1,39 @@
|
|||
// xfail-boot
|
||||
fn main() {
|
||||
|
||||
obj foo(mutable int i) {
|
||||
fn inc_by(int incr) -> int {
|
||||
i += incr;
|
||||
ret i;
|
||||
}
|
||||
|
||||
fn inc_by_5() -> int {
|
||||
ret self.inc_by(5);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
let int res;
|
||||
auto o = foo(5);
|
||||
|
||||
res = o.get();
|
||||
assert (res == 5);
|
||||
|
||||
res = o.inc_by(3);
|
||||
assert (res == 8);
|
||||
|
||||
res = o.get();
|
||||
assert (res == 8);
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue