mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
move tests
This commit is contained in:
parent
1c15f47e00
commit
9c819eaa9a
2 changed files with 65 additions and 48 deletions
|
@ -783,13 +783,13 @@ x!();
|
|||
fn test_ty() {
|
||||
check(
|
||||
r#"
|
||||
macro_rules! foo {
|
||||
macro_rules! m {
|
||||
($t:ty) => ( fn bar() -> $t {} )
|
||||
}
|
||||
foo! { Baz<u8> }
|
||||
m! { Baz<u8> }
|
||||
"#,
|
||||
expect![[r#"
|
||||
macro_rules! foo {
|
||||
macro_rules! m {
|
||||
($t:ty) => ( fn bar() -> $t {} )
|
||||
}
|
||||
fn bar() -> Baz<u8> {}
|
||||
|
@ -801,16 +801,16 @@ fn bar() -> Baz<u8> {}
|
|||
fn test_ty_with_complex_type() {
|
||||
check(
|
||||
r#"
|
||||
macro_rules! foo {
|
||||
macro_rules! m {
|
||||
($t:ty) => ( fn bar() -> $ t {} )
|
||||
}
|
||||
|
||||
foo! { &'a Baz<u8> }
|
||||
m! { &'a Baz<u8> }
|
||||
|
||||
foo! { extern "Rust" fn() -> Ret }
|
||||
m! { extern "Rust" fn() -> Ret }
|
||||
"#,
|
||||
expect![[r#"
|
||||
macro_rules! foo {
|
||||
macro_rules! m {
|
||||
($t:ty) => ( fn bar() -> $ t {} )
|
||||
}
|
||||
|
||||
|
@ -820,3 +820,61 @@ fn bar() -> extern"Rust"fn() -> Ret {}
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pat_() {
|
||||
check(
|
||||
r#"
|
||||
macro_rules! m {
|
||||
($p:pat) => { fn foo() { let $p; } }
|
||||
}
|
||||
m! { (a, b) }
|
||||
"#,
|
||||
expect![[r#"
|
||||
macro_rules! m {
|
||||
($p:pat) => { fn foo() { let $p; } }
|
||||
}
|
||||
fn foo() {
|
||||
let(a,b);
|
||||
}
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stmt() {
|
||||
check(
|
||||
r#"
|
||||
macro_rules! m {
|
||||
($s:stmt) => ( fn bar() { $s; } )
|
||||
}
|
||||
m! { 2 }
|
||||
m! { let a = 0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
macro_rules! m {
|
||||
($s:stmt) => ( fn bar() { $s; } )
|
||||
}
|
||||
fn bar() {
|
||||
2;
|
||||
}
|
||||
fn bar() {
|
||||
let a = 0;
|
||||
}
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_single_item() {
|
||||
check(
|
||||
r#"
|
||||
macro_rules! m { ($i:item) => ( $i ) }
|
||||
m! { mod c {} }
|
||||
"#,
|
||||
expect![[r#"
|
||||
macro_rules! m { ($i:item) => ( $i ) }
|
||||
mod c {}
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
|
|
@ -101,47 +101,6 @@ fn test_attr_to_token_tree() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pat_() {
|
||||
parse_macro(
|
||||
r#"
|
||||
macro_rules! foo {
|
||||
($ i:pat) => { fn foo() { let $ i; } }
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.assert_expand_items("foo! { (a, b) }", "fn foo () {let (a , b) ;}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stmt() {
|
||||
parse_macro(
|
||||
r#"
|
||||
macro_rules! foo {
|
||||
($ i:stmt) => (
|
||||
fn bar() { $ i; }
|
||||
)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.assert_expand_items("foo! { 2 }", "fn bar () {2 ;}")
|
||||
.assert_expand_items("foo! { let a = 0 }", "fn bar () {let a = 0 ;}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_single_item() {
|
||||
parse_macro(
|
||||
r#"
|
||||
macro_rules! foo {
|
||||
($ i:item) => (
|
||||
$ i
|
||||
)
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.assert_expand_items("foo! {mod c {}}", "mod c {}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_all_items() {
|
||||
parse_macro(
|
||||
|
|
Loading…
Reference in a new issue