mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
move tests
This commit is contained in:
parent
6fd2f1d25b
commit
748e6881fc
@ -128,7 +128,7 @@ fn pretty_print_macro_expansion(expn: SyntaxNode) -> String {
|
|||||||
(T![>], _) if curr_kind.is_keyword() => " ",
|
(T![>], _) if curr_kind.is_keyword() => " ",
|
||||||
(T![->], _) | (_, T![->]) => " ",
|
(T![->], _) | (_, T![->]) => " ",
|
||||||
(T![&&], _) | (_, T![&&]) => " ",
|
(T![&&], _) | (_, T![&&]) => " ",
|
||||||
(T![,], _) => " ",
|
(T![,] | T![:], _) => " ",
|
||||||
(T![fn], T!['(']) => "",
|
(T![fn], T!['(']) => "",
|
||||||
(T![']'], _) if curr_kind.is_keyword() => " ",
|
(T![']'], _) if curr_kind.is_keyword() => " ",
|
||||||
(T![']'], T![#]) => "\n",
|
(T![']'], T![#]) => "\n",
|
||||||
|
@ -35,12 +35,12 @@ macro_rules! impl_froms {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Leaf> for TokenTree {
|
impl From<Leaf> for TokenTree {
|
||||||
fn from(it:Leaf) -> TokenTree {
|
fn from(it: Leaf) -> TokenTree {
|
||||||
TokenTree::Leaf(it)
|
TokenTree::Leaf(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Subtree> for TokenTree {
|
impl From<Subtree> for TokenTree {
|
||||||
fn from(it:Subtree) -> TokenTree {
|
fn from(it: Subtree) -> TokenTree {
|
||||||
TokenTree::Subtree(it)
|
TokenTree::Subtree(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -433,10 +433,10 @@ macro_rules! structs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
field:u32
|
field: u32
|
||||||
}
|
}
|
||||||
struct Bar {
|
struct Bar {
|
||||||
field:u32
|
field: u32
|
||||||
}
|
}
|
||||||
// MACRO_ITEMS@0..40
|
// MACRO_ITEMS@0..40
|
||||||
// STRUCT@0..20
|
// STRUCT@0..20
|
||||||
@ -906,8 +906,8 @@ extern crate a;
|
|||||||
mod b;
|
mod b;
|
||||||
mod c {}
|
mod c {}
|
||||||
use d;
|
use d;
|
||||||
const E:i32 = 0;
|
const E: i32 = 0;
|
||||||
static F:i32 = 0;
|
static F: i32 = 0;
|
||||||
impl G {}
|
impl G {}
|
||||||
struct H;
|
struct H;
|
||||||
enum I {
|
enum I {
|
||||||
@ -1239,3 +1239,36 @@ struct Ref<'a> {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_literal() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($type:ty, $lit:literal) => { const VALUE: $type = $ lit; };
|
||||||
|
}
|
||||||
|
m!(u8, 0);
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($type:ty, $lit:literal) => { const VALUE: $type = $ lit; };
|
||||||
|
}
|
||||||
|
const VALUE: u8 = 0;
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($type:ty, $lit:literal) => { const VALUE: $ type = $ lit; };
|
||||||
|
}
|
||||||
|
m!(i32, -1);
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
macro_rules! m {
|
||||||
|
($type:ty, $lit:literal) => { const VALUE: $ type = $ lit; };
|
||||||
|
}
|
||||||
|
const VALUE: i32 = -1;
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -101,27 +101,6 @@ fn test_attr_to_token_tree() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_literal() {
|
|
||||||
parse_macro(
|
|
||||||
r#"
|
|
||||||
macro_rules! foo {
|
|
||||||
($ type:ty , $ lit:literal) => { const VALUE: $ type = $ lit;};
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.assert_expand_items(r#"foo!(u8,0);"#, r#"const VALUE : u8 = 0 ;"#);
|
|
||||||
|
|
||||||
parse_macro(
|
|
||||||
r#"
|
|
||||||
macro_rules! foo {
|
|
||||||
($ type:ty , $ lit:literal) => { const VALUE: $ type = $ lit;};
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.assert_expand_items(r#"foo!(i32,-1);"#, r#"const VALUE : i32 = - 1 ;"#);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_boolean_is_ident() {
|
fn test_boolean_is_ident() {
|
||||||
parse_macro(
|
parse_macro(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user