]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/mir_build_match_comparisons.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 fn test1(x
: i8) -> i32 {
18 const U
: Option
<i8> = Some(10);
19 const S
: &'
static str = "hello";
21 fn test2(x
: i8) -> i32 {
28 fn test3(x
: &'
static str) -> i32 {
40 fn test4(x
: u64) -> i32 {
41 let opt
= Opt
::Some{ v: x }
;
43 Opt
::Some { v: 10 }
=> 0,
50 assert_eq
!(test1(0), 1);
51 assert_eq
!(test1(1), 0);
52 assert_eq
!(test1(2), 0);
53 assert_eq
!(test1(5), 0);
54 assert_eq
!(test1(9), 0);
55 assert_eq
!(test1(10), 0);
56 assert_eq
!(test1(11), 1);
57 assert_eq
!(test1(20), 1);
58 assert_eq
!(test2(10), 0);
59 assert_eq
!(test2(0), 1);
60 assert_eq
!(test2(20), 1);
61 assert_eq
!(test3("hello"), 0);
62 assert_eq
!(test3(""), 1);
63 assert_eq
!(test3("world"), 1);
64 assert_eq
!(test4(10), 0);
65 assert_eq
!(test4(0), 1);
66 assert_eq
!(test4(20), 1);