rust/src/test/run-pass/stateful-obj.rs
Brian Anderson 518dc52f85 Reformat
This changes the indexing syntax from .() to [], the vector syntax from ~[] to
[] and the extension syntax from #fmt() to #fmt[]
2011-08-20 11:04:00 -07:00

19 lines
309 B
Rust

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