/src/test/run-pass/expr-alt.rs

http://github.com/jruderman/rust · Rust · 44 lines · 32 code · 9 blank · 3 comment · 7 complexity · 281dac604e295995f95f7dd32170b548 MD5 · raw file

  1. // -*- rust -*-
  2. // Tests for using match as an expression
  3. fn test_basic() {
  4. let mut rs: bool = match true { true => { true } false => { false } };
  5. assert (rs);
  6. rs = match false { true => { false } false => { true } };
  7. assert (rs);
  8. }
  9. fn test_inferrence() {
  10. let mut rs = match true { true => { true } false => { false } };
  11. assert (rs);
  12. }
  13. fn test_alt_as_alt_head() {
  14. // Yeah, this is kind of confusing ...
  15. let rs =
  16. match match false { true => { true } false => { false } } {
  17. true => { false }
  18. false => { true }
  19. };
  20. assert (rs);
  21. }
  22. fn test_alt_as_block_result() {
  23. let rs =
  24. match false {
  25. true => { false }
  26. false => { match true { true => { true } false => { false } } }
  27. };
  28. assert (rs);
  29. }
  30. fn main() {
  31. test_basic();
  32. test_inferrence();
  33. test_alt_as_alt_head();
  34. test_alt_as_block_result();
  35. }