rust/src/test/run-pass/alt-str.rs
Marijn Haverbeke 67cc89f38d Rewrite exhaustiveness checker
Issue #352
Closes #1720

The old checker would happily accept things like 'alt x { @some(a) { a } }'.
It now properly descends into patterns, checks exhaustiveness of booleans,
and complains when number/string patterns aren't exhaustive.
2012-02-15 15:47:42 +01:00

22 lines
369 B
Rust

// Issue #53
fn main() {
alt check "test" { "not-test" { fail; } "test" { } _ { fail; } }
enum t { tag1(str), tag2, }
alt tag1("test") {
tag2 { fail; }
tag1("not-test") { fail; }
tag1("test") { }
_ { fail; }
}
let x = alt check "a" { "a" { 1 } "b" { 2 } };
assert (x == 1);
alt check "a" { "a" { } "b" { } }
}