rust/src/test/run-pass/stateful-obj.rs
2010-06-23 21:03:09 -07:00

24 lines
303 B
Rust

// -*- rust -*-
obj counter(mutable int x) {
fn hello() -> int {
ret 12345;
}
fn incr() {
x = x + 1;
}
fn get() -> int {
ret x;
}
}
fn main() {
auto y = counter(0);
check (y.hello() == 12345);
log y.get();
y.incr();
y.incr();
log y.get();
check (y.get() == 2);
}