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.
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.
11 // aux-build:typeid-intrinsic-aux1.rs
12 // aux-build:typeid-intrinsic-aux2.rs
14 #![feature(core_intrinsics)]
16 extern crate typeid_intrinsic_aux1
as other1
;
17 extern crate typeid_intrinsic_aux2
as other2
;
19 use std
::hash
::{SipHasher, Hasher, Hash}
;
27 assert_eq
!(TypeId
::of
::<other1
::A
>(), other1
::id_A());
28 assert_eq
!(TypeId
::of
::<other1
::B
>(), other1
::id_B());
29 assert_eq
!(TypeId
::of
::<other1
::C
>(), other1
::id_C());
30 assert_eq
!(TypeId
::of
::<other1
::D
>(), other1
::id_D());
31 assert_eq
!(TypeId
::of
::<other1
::E
>(), other1
::id_E());
32 assert_eq
!(TypeId
::of
::<other1
::F
>(), other1
::id_F());
33 assert_eq
!(TypeId
::of
::<other1
::G
>(), other1
::id_G());
34 assert_eq
!(TypeId
::of
::<other1
::H
>(), other1
::id_H());
36 assert_eq
!(TypeId
::of
::<other2
::A
>(), other2
::id_A());
37 assert_eq
!(TypeId
::of
::<other2
::B
>(), other2
::id_B());
38 assert_eq
!(TypeId
::of
::<other2
::C
>(), other2
::id_C());
39 assert_eq
!(TypeId
::of
::<other2
::D
>(), other2
::id_D());
40 assert_eq
!(TypeId
::of
::<other2
::E
>(), other2
::id_E());
41 assert_eq
!(TypeId
::of
::<other2
::F
>(), other2
::id_F());
42 assert_eq
!(TypeId
::of
::<other2
::G
>(), other2
::id_G());
43 assert_eq
!(TypeId
::of
::<other2
::H
>(), other2
::id_H());
45 assert_eq
!(other1
::id_F(), other2
::id_F());
46 assert_eq
!(other1
::id_G(), other2
::id_G());
47 assert_eq
!(other1
::id_H(), other2
::id_H());
49 assert_eq
!(TypeId
::of
::<isize>(), other2
::foo
::<isize>());
50 assert_eq
!(TypeId
::of
::<isize>(), other1
::foo
::<isize>());
51 assert_eq
!(other2
::foo
::<isize>(), other1
::foo
::<isize>());
52 assert_eq
!(TypeId
::of
::<A
>(), other2
::foo
::<A
>());
53 assert_eq
!(TypeId
::of
::<A
>(), other1
::foo
::<A
>());
54 assert_eq
!(other2
::foo
::<A
>(), other1
::foo
::<A
>());
57 // sanity test of TypeId
58 let (a
, b
, c
) = (TypeId
::of
::<usize>(), TypeId
::of
::<&'
static str>(),
59 TypeId
::of
::<Test
>());
60 let (d
, e
, f
) = (TypeId
::of
::<usize>(), TypeId
::of
::<&'
static str>(),
61 TypeId
::of
::<Test
>());
71 // check it has a hash
72 let (a
, b
) = (TypeId
::of
::<usize>(), TypeId
::of
::<usize>());
74 let mut s1
= SipHasher
::new();
76 let mut s2
= SipHasher
::new();
79 assert_eq
!(s1
.finish(), s2
.finish());