]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/deriving-rand.rs
71cae400602d2c23b9cf4b5f6ddd0ecb76cb1001
[rust.git] / src / test / run-pass / deriving-rand.rs
1 // Copyright 2013-2014 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.
4 //
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.
10
11 #![feature(rand)]
12
13 use std::rand;
14
15 #[derive(Rand)]
16 struct A;
17
18 #[derive(Rand)]
19 struct B(int, int);
20
21 #[derive(Rand)]
22 struct C {
23     x: f64,
24     y: (u8, u8)
25 }
26
27 #[derive(Rand)]
28 enum D {
29     D0,
30     D1(uint),
31     D2 { x: (), y: () }
32 }
33
34 pub fn main() {
35     // check there's no segfaults
36     for _ in 0..20 {
37         rand::random::<A>();
38         rand::random::<B>();
39         rand::random::<C>();
40         rand::random::<D>();
41     }
42 }