]> git.lizzy.rs Git - rust.git/blob - src/liballoc/tests/lib.rs
Rollup merge of #56914 - glaubitz:ignore-tests, r=alexcrichton
[rust.git] / src / liballoc / tests / lib.rs
1 // Copyright 2015 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(allocator_api)]
12 #![feature(box_syntax)]
13 #![feature(drain_filter)]
14 #![feature(exact_size_is_empty)]
15 #![feature(pattern)]
16 #![feature(repeat_generic_slice)]
17 #![feature(slice_sort_by_cached_key)]
18 #![feature(str_escape)]
19 #![feature(try_reserve)]
20 #![feature(unboxed_closures)]
21 #![feature(vecdeque_rotate)]
22
23 extern crate core;
24 extern crate rand;
25
26 use std::hash::{Hash, Hasher};
27 use std::collections::hash_map::DefaultHasher;
28
29 mod arc;
30 mod binary_heap;
31 mod btree;
32 mod cow_str;
33 mod fmt;
34 mod heap;
35 mod linked_list;
36 mod rc;
37 mod slice;
38 mod str;
39 mod string;
40 mod vec_deque;
41 mod vec;
42
43 fn hash<T: Hash>(t: &T) -> u64 {
44     let mut s = DefaultHasher::new();
45     t.hash(&mut s);
46     s.finish()
47 }
48
49 // FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten.
50 // See https://github.com/kripken/emscripten-fastcomp/issues/169
51 #[cfg(not(target_os = "emscripten"))]
52 #[test]
53 fn test_boxed_hasher() {
54     let ordinary_hash = hash(&5u32);
55
56     let mut hasher_1 = Box::new(DefaultHasher::new());
57     5u32.hash(&mut hasher_1);
58     assert_eq!(ordinary_hash, hasher_1.finish());
59
60     let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<dyn Hasher>;
61     5u32.hash(&mut hasher_2);
62     assert_eq!(ordinary_hash, hasher_2.finish());
63 }