mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
internal: move test
This commit is contained in:
parent
26f4124b26
commit
b21244e080
3 changed files with 20 additions and 29 deletions
|
@ -20,7 +20,7 @@ use stdx::format_to;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{self, edit::IndentLevel},
|
ast::{self, edit::IndentLevel},
|
||||||
AstNode,
|
AstNode,
|
||||||
SyntaxKind::{self, IDENT},
|
SyntaxKind::{self, IDENT, LIFETIME_IDENT},
|
||||||
SyntaxNode, T,
|
SyntaxNode, T,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ fn pretty_print_macro_expansion(expn: SyntaxNode) -> String {
|
||||||
_ if prev_kind.is_trivia() || curr_kind.is_trivia() => "",
|
_ if prev_kind.is_trivia() || curr_kind.is_trivia() => "",
|
||||||
(T![=], _) | (_, T![=]) => " ",
|
(T![=], _) | (_, T![=]) => " ",
|
||||||
(T![;], _) => "\n",
|
(T![;], _) => "\n",
|
||||||
(IDENT, IDENT) => " ",
|
(IDENT | LIFETIME_IDENT, IDENT | LIFETIME_IDENT) => " ",
|
||||||
(IDENT, _) if curr_kind.is_keyword() => " ",
|
(IDENT, _) if curr_kind.is_keyword() => " ",
|
||||||
(_, IDENT) if prev_kind.is_keyword() => " ",
|
(_, IDENT) if prev_kind.is_keyword() => " ",
|
||||||
_ => "",
|
_ => "",
|
||||||
|
|
|
@ -63,6 +63,24 @@ fn f() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn roundtrip_lifetime() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($($t:tt)*) => { $($t)*}
|
||||||
|
}
|
||||||
|
m!(static bar: &'static str = "hello";);
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($($t:tt)*) => { $($t)*}
|
||||||
|
}
|
||||||
|
static bar: & 'static str = "hello";
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn broken_parenthesis_sequence() {
|
fn broken_parenthesis_sequence() {
|
||||||
check(
|
check(
|
||||||
|
|
|
@ -166,33 +166,6 @@ SUBTREE $
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_lifetime_split() {
|
|
||||||
parse_macro(
|
|
||||||
r#"
|
|
||||||
macro_rules! foo {
|
|
||||||
($($t:tt)*) => { $($t)*}
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.assert_expand(
|
|
||||||
r#"foo!(static bar: &'static str = "hello";);"#,
|
|
||||||
r#"
|
|
||||||
SUBTREE $
|
|
||||||
IDENT static 17
|
|
||||||
IDENT bar 18
|
|
||||||
PUNCH : [alone] 19
|
|
||||||
PUNCH & [alone] 20
|
|
||||||
PUNCH ' [joint] 21
|
|
||||||
IDENT static 22
|
|
||||||
IDENT str 23
|
|
||||||
PUNCH = [alone] 24
|
|
||||||
LITERAL "hello" 25
|
|
||||||
PUNCH ; [joint] 26
|
|
||||||
"#,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_expr_order() {
|
fn test_expr_order() {
|
||||||
let expanded = parse_macro(
|
let expanded = parse_macro(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue