|
| 1 | +// Copyright 2012-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 | +pub mod testtypes { |
| 12 | + use std::intrinsics::TypeId; |
| 13 | + |
| 14 | + pub fn type_ids() -> Vec<TypeId> { |
| 15 | + let mut ids = vec!(); |
| 16 | + ids.push(TypeId::of::<FooNil>()); |
| 17 | + ids.push(TypeId::of::<FooBool>()); |
| 18 | + ids.push(TypeId::of::<FooInt>()); |
| 19 | + ids.push(TypeId::of::<FooUint>()); |
| 20 | + ids.push(TypeId::of::<FooFloat>()); |
| 21 | + ids.push(TypeId::of::<FooEnum>()); |
| 22 | + ids.push(TypeId::of::<FooUniq>()); |
| 23 | + ids.push(TypeId::of::<FooPtr>()); |
| 24 | + ids.push(TypeId::of::<FooClosure>()); |
| 25 | + ids.push(TypeId::of::<&'static FooTrait>()); |
| 26 | + ids.push(TypeId::of::<FooStruct>()); |
| 27 | + ids.push(TypeId::of::<FooTuple>()); |
| 28 | + ids |
| 29 | + } |
| 30 | + |
| 31 | + // Tests ty_nil |
| 32 | + pub type FooNil = (); |
| 33 | + |
| 34 | + // Skipping ty_bot |
| 35 | + |
| 36 | + // Tests ty_bool |
| 37 | + pub type FooBool = bool; |
| 38 | + |
| 39 | + // Tests ty_char |
| 40 | + pub type FooChar = char; |
| 41 | + |
| 42 | + // Tests ty_int (does not test all variants of IntTy) |
| 43 | + pub type FooInt = int; |
| 44 | + |
| 45 | + // Tests ty_uint (does not test all variants of UintTy) |
| 46 | + pub type FooUint = uint; |
| 47 | + |
| 48 | + // Tests ty_float (does not test all variants of FloatTy) |
| 49 | + pub type FooFloat = f64; |
| 50 | + |
| 51 | + // For ty_str, what kind of string should I use? &'static str? ~str? Raw str? |
| 52 | + |
| 53 | + // Tests ty_enum |
| 54 | + pub enum FooEnum { |
| 55 | + VarA(uint), |
| 56 | + VarB(uint, uint) |
| 57 | + } |
| 58 | + |
| 59 | + // Skipping ty_box |
| 60 | + |
| 61 | + // Tests ty_uniq (of u8) |
| 62 | + pub type FooUniq = ~u8; |
| 63 | + |
| 64 | + // As with ty_str, what type should be used for ty_vec? |
| 65 | + |
| 66 | + // Tests ty_ptr |
| 67 | + pub type FooPtr = *u8; |
| 68 | + |
| 69 | + // Skipping ty_rptr |
| 70 | + |
| 71 | + // Skipping ty_bare_fn (how do you get a bare function type, rather than proc or closure?) |
| 72 | + |
| 73 | + // Tests ty_closure (does not test all types of closures) |
| 74 | + pub type FooClosure = |arg: u8|: 'static -> u8; |
| 75 | + |
| 76 | + // Tests ty_trait |
| 77 | + pub trait FooTrait { |
| 78 | + fn foo_method(&self) -> uint; |
| 79 | + fn foo_static_method() -> uint; |
| 80 | + } |
| 81 | + |
| 82 | + // Tests ty_struct |
| 83 | + pub struct FooStruct { |
| 84 | + pub pub_foo_field: uint, |
| 85 | + foo_field: uint |
| 86 | + } |
| 87 | + |
| 88 | + // Tests ty_tup |
| 89 | + pub type FooTuple = (u8, i8, bool); |
| 90 | + |
| 91 | + // Skipping ty_param |
| 92 | + |
| 93 | + // Skipping ty_self |
| 94 | + |
| 95 | + // Skipping ty_self |
| 96 | + |
| 97 | + // Skipping ty_infer |
| 98 | + |
| 99 | + // Skipping ty_err |
| 100 | +} |
0 commit comments