From aced4ce145bf23cc945c58a6c9c1bc1f33359a06 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 27 Mar 2011 18:51:25 -0400 Subject: Handle structural types as the result of if expressions --- src/test/run-pass/expr-if-struct.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/run-pass/expr-if-struct.rs (limited to 'src/test') diff --git a/src/test/run-pass/expr-if-struct.rs b/src/test/run-pass/expr-if-struct.rs new file mode 100644 index 00000000..df20a3ba --- /dev/null +++ b/src/test/run-pass/expr-if-struct.rs @@ -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(); +} \ No newline at end of file -- cgit v1.2.3