rust/src/test/run-pass/classes.rs
Tim Chevalier f3343b3571 Beginnings of front-end support for classes
Added class support to the parser, prettyprinter, fold, and visit.
(See Issue 1726.)

This is WIP -- the test case is xfailed, and attempting to compile
it will error out in resolve.
2012-02-03 22:47:35 -08:00

29 lines
464 B
Rust

// xfail-test
class cat {
priv {
let mutable meows : uint;
fn meow() {
#error("Meow");
meows += 1;
if meows % 5 == 0 {
how_hungry += 1;
}
}
}
let how_hungry : int;
new(in_x : uint, in_y : int) { meows = in_x; how_hungry = in_y; }
fn speak() { meow(); }
fn eat() {
if how_hungry > 0 {
#error("OM NOM NOM");
how_hungry -= 2;
}
else {
#error("Not hungry!");
}
}
}