about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorLuqman Aden <me@luqman.ca>2015-12-24 23:05:57 -0500
committerLuqman Aden <me@luqman.ca>2015-12-24 23:05:57 -0500
commit9f72e001a0a761f711739bfe07c8ea54136ec5da (patch)
tree8f0e324d0a46acc4ac2903101967567e94747cec /src/test
parent0a09ae6de8c6ce688baa836d77c90b0988f02b6b (diff)
downloadrust-9f72e001a0a761f711739bfe07c8ea54136ec5da.tar.gz
rust-9f72e001a0a761f711739bfe07c8ea54136ec5da.zip
Add test.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/mir_match_arm_guard.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/run-pass/mir_match_arm_guard.rs b/src/test/run-pass/mir_match_arm_guard.rs
new file mode 100644
index 00000000000..fb177ba7b2b
--- /dev/null
+++ b/src/test/run-pass/mir_match_arm_guard.rs
@@ -0,0 +1,28 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// #30527 - We were not generating arms with guards in certain cases.
+
+#![feature(rustc_attrs)]
+
+#[rustc_mir]
+fn match_with_guard(x: Option<i8>) -> i8 {
+    match x {
+        Some(xyz) if xyz > 100 => 0,
+        Some(_) => -1,
+        None => -2
+    }
+}
+
+fn main() {
+    assert_eq!(match_with_guard(Some(111)), 0);
+    assert_eq!(match_with_guard(Some(2)), -1);
+    assert_eq!(match_with_guard(None), -2);
+}