internal: move tests

This commit is contained in:
Aleksey Kladov 2021-10-10 12:45:17 +03:00
parent 5a854a7253
commit 6fd2f1d25b
2 changed files with 54 additions and 37 deletions

View file

@ -1185,3 +1185,57 @@ ok!();
"#]],
);
}
#[test]
fn test_vertical_bar_with_pat() {
check(
r#"
macro_rules! m { (|$pat:pat| ) => { ok!(); } }
m! { |x| }
"#,
expect![[r#"
macro_rules! m { (|$pat:pat| ) => { ok!(); } }
ok!();
"#]],
);
}
#[test]
fn test_dollar_crate_lhs_is_not_meta() {
check(
r#"
macro_rules! m {
($crate) => { err!(); };
() => { ok!(); };
}
m!{}
"#,
expect![[r#"
macro_rules! m {
($crate) => { err!(); };
() => { ok!(); };
}
ok!();
"#]],
);
}
#[test]
fn test_lifetime() {
check(
r#"
macro_rules! m {
($lt:lifetime) => { struct Ref<$lt>{ s: &$ lt str } }
}
m! {'a}
"#,
expect![[r#"
macro_rules! m {
($lt:lifetime) => { struct Ref<$lt>{ s: &$ lt str } }
}
struct Ref<'a> {
s: &'a str
}
"#]],
);
}

View file

@ -101,43 +101,6 @@ fn test_attr_to_token_tree() {
);
}
#[test]
fn test_vertical_bar_with_pat() {
parse_macro(
r#"
macro_rules! foo {
(| $pat:pat | ) => { 0 }
}
"#,
)
.assert_expand_items(r#"foo! { | x | }"#, r#"0"#);
}
#[test]
fn test_dollar_crate_lhs_is_not_meta() {
parse_macro(
r#"
macro_rules! foo {
($crate) => {};
() => {0};
}
"#,
)
.assert_expand_items(r#"foo!{}"#, r#"0"#);
}
#[test]
fn test_lifetime() {
parse_macro(
r#"
macro_rules! foo {
($ lt:lifetime) => { struct Ref<$ lt>{ s: &$ lt str } }
}
"#,
)
.assert_expand_items(r#"foo!{'a}"#, r#"struct Ref <'a > {s : &'a str}"#);
}
#[test]
fn test_literal() {
parse_macro(