rust/src/test/run-pass/alt-range.rs

32 lines
658 B
Rust
Raw Normal View History

fn main() {
2012-08-06 19:34:08 +00:00
match 5u {
1u..5u => {}
2012-08-04 02:59:04 +00:00
_ => fail ~"should match range",
}
2012-08-06 19:34:08 +00:00
match 5u {
6u..7u => fail ~"shouldn't match range",
2012-08-04 02:59:04 +00:00
_ => {}
}
2012-08-23 21:44:58 +00:00
match 5u {
2012-08-04 02:59:04 +00:00
1u => fail ~"should match non-first range",
2u..6u => {}
2012-08-23 21:44:58 +00:00
_ => fail ~"math is broken"
}
2012-08-06 19:34:08 +00:00
match 'c' {
'a'..'z' => {}
2012-08-04 02:59:04 +00:00
_ => fail ~"should suppport char ranges"
}
2012-08-06 19:34:08 +00:00
match -3 {
-7..5 => {}
2012-08-04 02:59:04 +00:00
_ => fail ~"should match signed range"
}
2012-08-06 19:34:08 +00:00
match 3.0 {
1.0..5.0 => {}
2012-08-04 02:59:04 +00:00
_ => fail ~"should match float range"
}
2012-08-06 19:34:08 +00:00
match -1.5 {
-3.6..3.6 => {}
2012-08-04 02:59:04 +00:00
_ => fail ~"should match negative float range"
}
}