2011-04-02 18:32:34 -05:00
|
|
|
// -*- rust -*-
|
|
|
|
|
|
|
|
// Tests for alt as expressions resulting in structural types
|
|
|
|
|
|
|
|
fn test_rec() {
|
|
|
|
auto res = alt (true) {
|
|
|
|
case (true) {
|
|
|
|
rec(i = 100)
|
|
|
|
}
|
|
|
|
};
|
2011-05-02 19:47:24 -05:00
|
|
|
assert (res == rec(i = 100));
|
2011-04-02 18:32:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_tag() {
|
|
|
|
tag mood {
|
|
|
|
happy;
|
|
|
|
sad;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto res = alt (true) {
|
|
|
|
case (true) {
|
|
|
|
happy
|
|
|
|
}
|
|
|
|
case (false) {
|
|
|
|
sad
|
|
|
|
}
|
|
|
|
};
|
2011-05-02 19:47:24 -05:00
|
|
|
assert (res == happy);
|
2011-04-02 18:32:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
test_rec();
|
|
|
|
test_tag();
|
|
|
|
}
|