about summary refs log tree commit diff
path: root/src/test/run-pass/standalone-method.rs
blob: a9d93917c4be5bb67840f7c2b39a173701de6d94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// xfail-test

// Test case for issue #435.
obj foo(x: int) {
    fn add5(n: int) -> int { ret n + x; }
}

fn add5(n: int) -> int { ret n + 5; }

fn main() {
    let fiveplusseven = bind add5(7);
    assert (add5(7) == 12);
    assert (fiveplusseven() == 12);

    let my_foo = foo(5);
    let fiveplusseven_too = bind my_foo.add5(7);
    assert (my_foo.add5(7) == 12);
    assert (fiveplusseven_too() == 12);
}