]> git.lizzy.rs Git - rust.git/blob - tests/run-pass/sums.rs
Replace Repr with the new ty::layout in rustc.
[rust.git] / tests / run-pass / sums.rs
1 #![feature(custom_attribute)]
2 #![allow(dead_code, unused_attributes)]
3
4 #[derive(Debug, PartialEq)]
5 enum Unit { Unit(()) } // Force non-C-enum representation.
6
7 #[miri_run]
8 fn return_unit() -> Unit {
9     Unit::Unit(())
10 }
11
12 #[derive(Debug, PartialEq)]
13 enum MyBool { False(()), True(()) } // Force non-C-enum representation.
14
15 #[miri_run]
16 fn return_true() -> MyBool {
17     MyBool::True(())
18 }
19
20 #[miri_run]
21 fn return_false() -> MyBool {
22     MyBool::False(())
23 }
24
25 #[miri_run]
26 fn return_none() -> Option<i64> {
27     None
28 }
29
30 #[miri_run]
31 fn return_some() -> Option<i64> {
32     Some(42)
33 }
34
35 #[miri_run]
36 fn match_opt_none() -> i8 {
37     let x = None;
38     match x {
39         Some(data) => data,
40         None => 42,
41     }
42 }
43
44 #[miri_run]
45 fn match_opt_some() -> i8 {
46     let x = Some(13);
47     match x {
48         Some(data) => data,
49         None => 20,
50     }
51 }
52
53 #[miri_run]
54 fn two_nones() -> (Option<i16>, Option<i16>) {
55     (None, None)
56 }
57
58 #[miri_run]
59 fn main() {
60     //assert_eq!(two_nones(), (None, None));
61     assert_eq!(match_opt_some(), 13);
62     assert_eq!(match_opt_none(), 42);
63     //assert_eq!(return_some(), Some(42));
64     //assert_eq!(return_none(), None);
65     //assert_eq!(return_false(), MyBool::False);
66     //assert_eq!(return_true(), MyBool::True);
67     //assert_eq!(return_unit(), Unit::Unit);
68 }