]> git.lizzy.rs Git - rust.git/blob - src/libcoretest/raw.rs
Do not use entropy during gen_weighted_bool(1)
[rust.git] / src / libcoretest / raw.rs
1 // Copyright 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 use core::raw::*;
12 use core::mem;
13
14 #[test]
15 fn synthesize_closure() {
16     unsafe {
17         let x = 10;
18         let f: |int| -> int = |y| x + y;
19
20         assert_eq!(f(20), 30);
21
22         let original_closure: Closure = mem::transmute(f);
23
24         let actual_function_pointer = original_closure.code;
25         let environment = original_closure.env;
26
27         let new_closure = Closure {
28             code: actual_function_pointer,
29             env: environment
30         };
31
32         let new_f: |int| -> int = mem::transmute(new_closure);
33         assert_eq!(new_f(20), 30);
34     }
35 }