aboutsummaryrefslogtreecommitdiff
path: root/src/test/run-pass/expr-if-struct.rs
diff options
context:
space:
mode:
authorBrian Anderson <[email protected]>2011-03-27 18:51:25 -0400
committerGraydon Hoare <[email protected]>2011-03-28 21:14:04 -0700
commitaced4ce145bf23cc945c58a6c9c1bc1f33359a06 (patch)
tree92d233fd79b9ee0f119bc89ee329b6be07047c09 /src/test/run-pass/expr-if-struct.rs
parentTeach rustc to use the result of if expressions (diff)
downloadrust-aced4ce145bf23cc945c58a6c9c1bc1f33359a06.tar.xz
rust-aced4ce145bf23cc945c58a6c9c1bc1f33359a06.zip
Handle structural types as the result of if expressions
Diffstat (limited to 'src/test/run-pass/expr-if-struct.rs')
-rw-r--r--src/test/run-pass/expr-if-struct.rs24
1 files changed, 24 insertions, 0 deletions
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