Handle structural types as the result of if expressions
This commit is contained in:
parent
a5a319fa04
commit
aced4ce145
2 changed files with 27 additions and 0 deletions
24
src/test/run-pass/expr-if-struct.rs
Normal file
24
src/test/run-pass/expr-if-struct.rs
Normal file
|
@ -0,0 +1,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) };
|
||||
check (res == rec(i = 100));
|
||||
}
|
||||
|
||||
fn test_tag() {
|
||||
tag mood {
|
||||
happy;
|
||||
sad;
|
||||
}
|
||||
|
||||
auto res = if (true) { happy } else { sad };
|
||||
check (res == happy);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test_rec();
|
||||
test_tag();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue