]> git.lizzy.rs Git - rust.git/blob - test/new_values.rs
WIP: Switching to a new byte-based value representation.
[rust.git] / test / new_values.rs
1 #![feature(custom_attribute)]
2 #![allow(dead_code, unused_attributes)]
3
4 #[miri_run(expected = "Int(1)")]
5 fn ret() -> i32 {
6     1
7 }
8
9 // #[miri_run(expected = "Int(-1)")]
10 // fn neg() -> i32 {
11 //     -1
12 // }
13
14 #[miri_run(expected = "Int(3)")]
15 fn add() -> i32 {
16     1 + 2
17 }
18
19 // #[miri_run(expected = "Int(3)")]
20 // fn indirect_add() -> i32 {
21 //     let x = 1;
22 //     let y = 2;
23 //     x + y
24 // }
25
26 // #[miri_run(expected = "Int(25)")]
27 // fn arith() -> i32 {
28 //     3*3 + 4*4
29 // }
30
31 // #[miri_run(expected = "Int(0)")]
32 // fn if_false() -> i32 {
33 //     if false { 1 } else { 0 }
34 // }
35
36 // #[miri_run(expected = "Int(1)")]
37 // fn if_true() -> i32 {
38 //     if true { 1 } else { 0 }
39 // }
40
41 // #[miri_run(expected = "Int(2)")]
42 // fn call() -> i32 {
43 //     fn increment(x: i32) -> i32 {
44 //         x + 1
45 //     }
46
47 //     increment(1)
48 // }
49
50 // // #[miri_run(expected = "Int(3628800)")]
51 // // fn factorial_loop() -> i32 {
52 // //     let mut product = 1;
53 // //     let mut i = 1;
54
55 // //     while i <= 10 {
56 // //         product *= i;
57 // //         i += 1;
58 // //     }
59
60 // //     product
61 // // }
62
63 // #[miri_run(expected = "Int(3628800)")]
64 // fn factorial_recursive() -> i32 {
65 //     fn fact(n: i32) -> i32 {
66 //         if n == 0 {
67 //             1
68 //         } else {
69 //             n * fact(n - 1)
70 //         }
71 //     }
72
73 //     fact(10)
74 // }
75
76 // #[miri_run(expected = "Int(1)")]
77 // fn match_bool() -> i32 {
78 //     let b = true;
79 //     match b {
80 //         true => 1,
81 //         false => 0,
82 //     }
83 // }
84
85 // #[miri_run(expected = "Int(20)")]
86 // fn match_int() -> i32 {
87 //     let n = 2;
88 //     match n {
89 //         0 => 0,
90 //         1 => 10,
91 //         2 => 20,
92 //         3 => 30,
93 //         _ => 100,
94 //     }
95 // }
96
97 // #[miri_run(expected = "Int(1)")]
98 // fn one_line_ref() -> i32 {
99 //     *&1
100 // }
101
102 // #[miri_run(expected = "Int(1)")]
103 // fn basic_ref() -> i32 {
104 //     let x = &1;
105 //     *x
106 // }
107
108 // #[miri_run(expected = "Int(3)")]
109 // fn basic_ref_mut() -> i32 {
110 //     let x = &mut 1;
111 //     *x += 2;
112 //     *x
113 // }
114
115 // // #[miri_run(expected = "Int(3)")]
116 // // fn basic_ref_mut_var() -> i32 {
117 // //     let mut a = 1;
118 // //     {
119 // //         let x = &mut a;
120 // //         *x += 2;
121 // //     }
122 // //     a
123 // // }
124
125 // #[miri_run(expected = "Int(4)")]
126 // fn match_int_range() -> i32 {
127 //     let n = 42;
128 //     match n {
129 //         0...9 => 0,
130 //         10...19 => 1,
131 //         20...29 => 2,
132 //         30...39 => 3,
133 //         40...49 => 4,
134 //         _ => 5,
135 //     }
136 // }
137
138 // enum MyOption<T> {
139 //     Some { data: T },
140 //     None,
141 // }
142
143 // #[miri_run(expected = "Int(13)")]
144 // fn match_my_opt_some() -> i32 {
145 //     let x = MyOption::Some { data: 13 };
146 //     match x {
147 //         MyOption::Some { data } => data,
148 //         MyOption::None => 42,
149 //     }
150 // }
151
152 // #[miri_run(expected = "Int(42)")]
153 // fn match_my_opt_none() -> i32 {
154 //     let x = MyOption::None;
155 //     match x {
156 //         MyOption::Some { data } => data,
157 //         MyOption::None => 42,
158 //     }
159 // }
160
161 // #[miri_run(expected = "Int(13)")]
162 // fn match_opt_some() -> i32 {
163 //     let x = Some(13);
164 //     match x {
165 //         Some(data)  => data,
166 //         None => 42,
167 //     }
168 // }
169
170 // /// Test calling a very simple function from the standard library.
171 // #[miri_run(expected = "Int(1)")]
172 // fn cross_crate_fn_call() -> i32 {
173 //     if 1i32.is_positive() { 1 } else { 0 }
174 // }
175
176 // fn main() {}