internal: move tests

This commit is contained in:
Aleksey Kladov 2021-10-10 11:11:50 +03:00
parent c6d5c1c946
commit 1c15f47e00
2 changed files with 42 additions and 37 deletions

View File

@ -778,3 +778,45 @@ x!();
"#]],
)
}
#[test]
fn test_ty() {
check(
r#"
macro_rules! foo {
($t:ty) => ( fn bar() -> $t {} )
}
foo! { Baz<u8> }
"#,
expect![[r#"
macro_rules! foo {
($t:ty) => ( fn bar() -> $t {} )
}
fn bar() -> Baz<u8> {}
"#]],
)
}
#[test]
fn test_ty_with_complex_type() {
check(
r#"
macro_rules! foo {
($t:ty) => ( fn bar() -> $ t {} )
}
foo! { &'a Baz<u8> }
foo! { extern "Rust" fn() -> Ret }
"#,
expect![[r#"
macro_rules! foo {
($t:ty) => ( fn bar() -> $ t {} )
}
fn bar() -> & 'a Baz<u8> {}
fn bar() -> extern"Rust"fn() -> Ret {}
"#]],
);
}

View File

@ -101,43 +101,6 @@ fn test_attr_to_token_tree() {
);
}
#[test]
fn test_ty() {
parse_macro(
r#"
macro_rules! foo {
($ i:ty) => (
fn bar() -> $ i { unimplemented!() }
)
}
"#,
)
.assert_expand_items("foo! { Baz<u8> }", "fn bar () -> Baz < u8 > {unimplemented ! ()}");
}
#[test]
fn test_ty_with_complex_type() {
parse_macro(
r#"
macro_rules! foo {
($ i:ty) => (
fn bar() -> $ i { unimplemented!() }
)
}
"#,
)
// Reference lifetime struct with generic type
.assert_expand_items(
"foo! { &'a Baz<u8> }",
"fn bar () -> & 'a Baz < u8 > {unimplemented ! ()}",
)
// extern "Rust" func type
.assert_expand_items(
r#"foo! { extern "Rust" fn() -> Ret }"#,
r#"fn bar () -> extern "Rust" fn () -> Ret {unimplemented ! ()}"#,
);
}
#[test]
fn test_pat_() {
parse_macro(