aboutsummaryrefslogtreecommitdiff
path: root/src/test/run-pass/expr-if-struct.rs
blob: 6d42c2241d57d53d7dd389f45762b4ba5a8c2c6e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// xfail-boot
// -*- rust -*-

// Tests for if as expressions returning structural types

fn test_rec() {
  auto res = if (true) { rec(i = 100) } else { rec(i = 101) };
  assert (res == rec(i = 100));
}

fn test_tag() {
  tag mood {
    happy;
    sad;
  }

  auto res = if (true) { happy } else { sad };
  assert (res == happy);
}

fn main() {
  test_rec();
  test_tag();
}