]> git.proxmox.com Git - rustc.git/blobdiff - src/liballoc/tests/lib.rs
New upstream version 1.22.1+dfsg1
[rustc.git] / src / liballoc / tests / lib.rs
index 8f3e71ef794465fb8a5b3e1c23d28faf5ffaf32c..c5beb63d12e9d0f07052b3fd1d38f54d30198f61 100644 (file)
@@ -50,3 +50,19 @@ fn hash<T: Hash>(t: &T) -> u64 {
     t.hash(&mut s);
     s.finish()
 }
+
+// FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten.
+// See https://github.com/kripken/emscripten-fastcomp/issues/169
+#[cfg(not(target_os = "emscripten"))]
+#[test]
+fn test_boxed_hasher() {
+    let ordinary_hash = hash(&5u32);
+
+    let mut hasher_1 = Box::new(DefaultHasher::new());
+    5u32.hash(&mut hasher_1);
+    assert_eq!(ordinary_hash, hasher_1.finish());
+
+    let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<Hasher>;
+    5u32.hash(&mut hasher_2);
+    assert_eq!(ordinary_hash, hasher_2.finish());
+}