mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-18 17:40:29 +00:00
Add test for literals created client-side
This commit is contained in:
parent
32ee097580
commit
36d825fd5d
2 changed files with 46 additions and 0 deletions
|
@ -56,6 +56,35 @@ fn test_fn_like_macro_clone_ident_subtree() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_fn_like_macro_clone_raw_ident() {
|
||||||
|
assert_expand(
|
||||||
|
"fn_like_clone_tokens",
|
||||||
|
"r#\"ident\"#",
|
||||||
|
expect![[r##"
|
||||||
|
SUBTREE $
|
||||||
|
LITERAL r#"ident"# 4294967295"##]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_fn_like_mk_literals() {
|
||||||
|
assert_expand(
|
||||||
|
"fn_like_mk_literals",
|
||||||
|
r#""#,
|
||||||
|
expect![[r#"
|
||||||
|
SUBTREE $
|
||||||
|
LITERAL b"byte_string" 4294967295
|
||||||
|
LITERAL 'c' 4294967295
|
||||||
|
LITERAL "string" 4294967295
|
||||||
|
LITERAL "maybe \"raw\"?" 4294967295
|
||||||
|
LITERAL 3.14f64 4294967295
|
||||||
|
LITERAL 3.14 4294967295
|
||||||
|
LITERAL 123i64 4294967295
|
||||||
|
LITERAL 123 4294967295"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fn_like_macro_clone_literals() {
|
fn test_fn_like_macro_clone_literals() {
|
||||||
assert_expand(
|
assert_expand(
|
||||||
|
@ -105,6 +134,7 @@ fn list_test_macros() {
|
||||||
fn_like_panic [FuncLike]
|
fn_like_panic [FuncLike]
|
||||||
fn_like_error [FuncLike]
|
fn_like_error [FuncLike]
|
||||||
fn_like_clone_tokens [FuncLike]
|
fn_like_clone_tokens [FuncLike]
|
||||||
|
fn_like_mk_literals [FuncLike]
|
||||||
attr_noop [Attr]
|
attr_noop [Attr]
|
||||||
attr_panic [Attr]
|
attr_panic [Attr]
|
||||||
attr_error [Attr]
|
attr_error [Attr]
|
||||||
|
|
|
@ -24,6 +24,22 @@ pub fn fn_like_clone_tokens(args: TokenStream) -> TokenStream {
|
||||||
clone_stream(args)
|
clone_stream(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[proc_macro]
|
||||||
|
pub fn fn_like_mk_literals(_args: TokenStream) -> TokenStream {
|
||||||
|
let trees: Vec<TokenTree> = vec![
|
||||||
|
TokenTree::from(Literal::byte_string(b"byte_string")),
|
||||||
|
TokenTree::from(Literal::character('c')),
|
||||||
|
TokenTree::from(Literal::string("string")),
|
||||||
|
// as of 2022-07-21, there's no method on `Literal` to build a raw
|
||||||
|
// string or a raw byte string
|
||||||
|
TokenTree::from(Literal::f64_suffixed(3.14)),
|
||||||
|
TokenTree::from(Literal::f64_unsuffixed(3.14)),
|
||||||
|
TokenTree::from(Literal::i64_suffixed(123)),
|
||||||
|
TokenTree::from(Literal::i64_unsuffixed(123)),
|
||||||
|
];
|
||||||
|
TokenStream::from_iter(trees)
|
||||||
|
}
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn attr_noop(_args: TokenStream, item: TokenStream) -> TokenStream {
|
pub fn attr_noop(_args: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
item
|
item
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue