mirror of
https://gitee.com/openharmony/third_party_rust_quote
synced 2024-11-23 15:19:40 +00:00
Add quote_spanned smoke test to test suite
This commit is contained in:
parent
2f191555c9
commit
c00eda5d49
@ -4,7 +4,7 @@ use std::borrow::Cow;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use proc_macro2::{Ident, Span, TokenStream};
|
||||
use quote::{format_ident, quote, TokenStreamExt};
|
||||
use quote::{format_ident, quote, quote_spanned, TokenStreamExt};
|
||||
|
||||
struct X;
|
||||
|
||||
@ -35,6 +35,28 @@ fn test_quote_impl() {
|
||||
assert_eq!(expected, tokens.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_quote_spanned_impl() {
|
||||
let span = Span::call_site();
|
||||
let tokens = quote_spanned! {span=>
|
||||
impl<'a, T: ToTokens> ToTokens for &'a T {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
(**self).to_tokens(tokens)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let expected = concat!(
|
||||
"impl < 'a , T : ToTokens > ToTokens for & 'a T { ",
|
||||
"fn to_tokens ( & self , tokens : & mut TokenStream ) { ",
|
||||
"( * * self ) . to_tokens ( tokens ) ",
|
||||
"} ",
|
||||
"}"
|
||||
);
|
||||
|
||||
assert_eq!(expected, tokens.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_substitution() {
|
||||
let x = X;
|
||||
|
Loading…
Reference in New Issue
Block a user