]> git.lizzy.rs Git - rust.git/blob - src/libcoretest/clone.rs
Auto merge of #27630 - sylvestre:master, r=dotdash
[rust.git] / src / libcoretest / clone.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 #[test]
12 fn test_borrowed_clone() {
13     let x = 5;
14     let y: &int = &x;
15     let z: &int = (&y).clone();
16     assert_eq!(*z, 5);
17 }
18
19 #[test]
20 fn test_clone_from() {
21     let a = box 5;
22     let mut b = box 10;
23     b.clone_from(&a);
24     assert_eq!(*b, 5);
25 }
26
27 #[test]
28 fn test_extern_fn_clone() {
29     trait Empty {}
30     impl Empty for int {}
31
32     fn test_fn_a() -> f64 { 1.0 }
33     fn test_fn_b<T: Empty>(x: T) -> T { x }
34     fn test_fn_c(_: int, _: f64, _: int, _: int, _: int) {}
35
36     let _ = test_fn_a.clone();
37     let _ = test_fn_b::<int>.clone();
38     let _ = test_fn_c.clone();
39 }