move tests

This commit is contained in:
Aleksey Kladov 2021-10-09 22:23:38 +03:00
parent 3a47dba761
commit f17f5d68f9
2 changed files with 69 additions and 46 deletions
crates
hir_def/src/macro_expansion_tests
mbe/src/tests

@ -635,3 +635,72 @@ macro panic_2015 {
"#]],
);
}
#[test]
fn test_path() {
check(
r#"
macro_rules! m {
($p:path) => { fn foo() { let a = $p; } }
}
m! { foo }
m! { bar::<u8>::baz::<u8> }
"#,
expect![[r#"
macro_rules! m {
($p:path) => { fn foo() { let a = $p; } }
}
fn foo() {
let a = foo;
}
fn foo() {
let a = bar::<u8>::baz::<u8> ;
}
"#]],
);
}
#[test]
fn test_two_paths() {
check(
r#"
macro_rules! m {
($i:path, $j:path) => { fn foo() { let a = $ i; let b = $j; } }
}
m! { foo, bar }
"#,
expect![[r#"
macro_rules! m {
($i:path, $j:path) => { fn foo() { let a = $ i; let b = $j; } }
}
fn foo() {
let a = foo;
let b = bar;
}
"#]],
);
}
#[test]
fn test_path_with_path() {
check(
r#"
macro_rules! m {
($p:path) => { fn foo() { let a = $p::bar; } }
}
m! { foo }
"#,
expect![[r#"
macro_rules! m {
($p:path) => { fn foo() { let a = $p::bar; } }
}
fn foo() {
let a = foo::bar;
}
"#]],
);
}

@ -101,52 +101,6 @@ fn test_attr_to_token_tree() {
);
}
#[test]
fn test_path() {
parse_macro(
r#"
macro_rules! foo {
($ i:path) => {
fn foo() { let a = $ i; }
}
}
"#,
)
.assert_expand_items("foo! { foo }", "fn foo () {let a = foo ;}")
.assert_expand_items(
"foo! { bar::<u8>::baz::<u8> }",
"fn foo () {let a = bar ::< u8 >:: baz ::< u8 > ;}",
);
}
#[test]
fn test_two_paths() {
parse_macro(
r#"
macro_rules! foo {
($ i:path, $ j:path) => {
fn foo() { let a = $ i; let b = $j; }
}
}
"#,
)
.assert_expand_items("foo! { foo, bar }", "fn foo () {let a = foo ; let b = bar ;}");
}
#[test]
fn test_path_with_path() {
parse_macro(
r#"
macro_rules! foo {
($ i:path) => {
fn foo() { let a = $ i :: bar; }
}
}
"#,
)
.assert_expand_items("foo! { foo }", "fn foo () {let a = foo :: bar ;}");
}
#[test]
fn test_expr() {
parse_macro(