diff --git a/tests/test.rs b/tests/test.rs index b410ab0..6580bcd 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -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;