#![feature(no_std)] #![no_std] #![feature(rustc_private, plugin, box_syntax)] #![plugin(cg)] #[prelude_import] use std::prelude::v1::*; #[macro_use] extern crate std as std; extern crate rustc; #[macro_use] extern crate syntax; use syntax::ext::deriving::generic::ty; #[allow(dead_code)] struct TestStruct<'a, 'b> { a: &'a str, b: &'b str, } #[test] pub fn path_eq() { let expected = ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["std", "core", "option", "Option"])), None, <[_]>::into_vec(::std::boxed::Box::new([box() ty::Ty::Literal(ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["TestStruct"])), Some("\'c,\'d"), <[_]>::into_vec(::std::boxed::Box::new([])), false))])), false); let p: ty::Path = ::syntax::ext::deriving::generic::ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["std", "core", "option", "Option"])), None, <[_]>::into_vec(::std::boxed::Box::new([::std::boxed::Box::new(::syntax::ext::deriving::generic::ty::Ty::Literal(::syntax::ext::deriving::generic::ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["TestStruct"])), Some("\'c,\'d"), <[_]>::into_vec(::std::boxed::Box::new([])), false)))])), false); if !(p == expected) { { ::std::rt::begin_unwind("assertion failed: p == expected", { static _FILE_LINE: (&'static str, u32) = ("tests/paths.rs", 65u32); &_FILE_LINE }) } }; } #[allow(dead_code)] struct TT<'a> { a: &'a str, } #[allow(dead_code)] trait TTT<'a> { } impl <'a> TTT<'a> for TT<'a> { } #[allow(dead_code)] struct Test2<'a, 'b, T: 'a + TTT<'a>> { a: &'a str, b: &'b str, t: &'a T, } #[test] pub fn path_eq2() { let ttt_ty = ty::Ty::Literal(ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["TTT"])), Some("\'a"), <[_]>::into_vec(::std::boxed::Box::new([])), false)); if !(::syntax::ext::deriving::generic::ty::Ty::Literal(::syntax::ext::deriving::generic::ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["TTT"])), Some("\'a"), <[_]>::into_vec(::std::boxed::Box::new([])), false)) == ttt_ty) { { ::std::rt::begin_unwind("assertion failed: ext_ty!(TTT < \'a >) == ttt_ty", { static _FILE_LINE: (&'static str, u32) = ("tests/paths.rs", 92u32); &_FILE_LINE }) } }; let test2_ty = ty::Ty::Literal(ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["Test2"])), Some("\'c,\'d"), <[_]>::into_vec(::std::boxed::Box::new([box() ttt_ty])), false)); if !(::syntax::ext::deriving::generic::ty::Ty::Literal(::syntax::ext::deriving::generic::ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["Test2"])), Some("\'c,\'d"), <[_]>::into_vec(::std::boxed::Box::new([::std::boxed::Box::new(::syntax::ext::deriving::generic::ty::Ty::Literal(::syntax::ext::deriving::generic::ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["TTT"])), Some("\'a"), <[_]>::into_vec(::std::boxed::Box::new([])), false)))])), false)) == test2_ty) { { ::std::rt::begin_unwind("assertion failed: ext_ty!(Test2 < \'c , \'d , TTT < \'a >>) == test2_ty", { static _FILE_LINE: (&'static str, u32) = ("tests/paths.rs", 96u32); &_FILE_LINE }) } }; let expected = ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["std", "core", "option", "Option"])), None, <[_]>::into_vec(::std::boxed::Box::new([box() test2_ty])), false); let p: ty::Path = ::syntax::ext::deriving::generic::ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["std", "core", "option", "Option"])), None, <[_]>::into_vec(::std::boxed::Box::new([::std::boxed::Box::new(::syntax::ext::deriving::generic::ty::Ty::Literal(::syntax::ext::deriving::generic::ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["Test2"])), Some("\'c,\'d"), <[_]>::into_vec(::std::boxed::Box::new([::std::boxed::Box::new(::syntax::ext::deriving::generic::ty::Ty::Literal(::syntax::ext::deriving::generic::ty::Path::new_(<[_]>::into_vec(::std::boxed::Box::new(["TTT"])), Some("\'a"), <[_]>::into_vec(::std::boxed::Box::new([])), false)))])), false)))])), false); if !(p == expected) { { ::std::rt::begin_unwind("assertion failed: p == expected", { static _FILE_LINE: (&'static str, u32) = ("tests/paths.rs", 101u32); &_FILE_LINE }) } }; } pub mod __test_reexports { #[prelude_import] use std::prelude::v1::*; pub use super::path_eq; pub use super::path_eq2; } pub mod __test { #[prelude_import] use std::prelude::v1::*; extern crate test; #[main] pub fn main() -> () { test::test_main_static(::std::env::args(), TESTS); } const TESTS: &'static [self::test::TestDescAndFn] = &[self::test::TestDescAndFn{desc: self::test::TestDesc{name: self::test::StaticTestName("path_eq"), ignore: false, should_panic: self::test::ShouldPanic::No,}, testfn: self::test::StaticTestFn(::__test_reexports::path_eq),}, self::test::TestDescAndFn{desc: self::test::TestDesc{name: self::test::StaticTestName("path_eq2"), ignore: false, should_panic: self::test::ShouldPanic::No,}, testfn: self::test::StaticTestFn(::__test_reexports::path_eq2),}]; }