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 #![feature(rustc_attrs)]
14 fn test1(x: i8) -> i32 {
21 const U: Option<i8> = Some(10);
22 const S: &'static str = "hello";
25 fn test2(x: i8) -> i32 {
33 fn test3(x: &'static str) -> i32 {
46 fn test4(x: u64) -> i32 {
47 let opt = Opt::Some{ v: x };
49 Opt::Some { v: 10 } => 0,
56 assert_eq!(test1(0), 1);
57 assert_eq!(test1(1), 0);
58 assert_eq!(test1(2), 0);
59 assert_eq!(test1(5), 0);
60 assert_eq!(test1(9), 0);
61 assert_eq!(test1(10), 0);
62 assert_eq!(test1(11), 1);
63 assert_eq!(test1(20), 1);
64 assert_eq!(test2(10), 0);
65 assert_eq!(test2(0), 1);
66 assert_eq!(test2(20), 1);
67 assert_eq!(test3("hello"), 0);
68 assert_eq!(test3(""), 1);
69 assert_eq!(test3("world"), 1);
70 assert_eq!(test4(10), 0);
71 assert_eq!(test4(0), 1);
72 assert_eq!(test4(20), 1);