mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2024-11-23 16:00:10 +00:00
Add none-group statement parsing test
This commit is contained in:
parent
e627ec80ce
commit
ba4f188168
@ -1,6 +1,8 @@
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
|
||||
use std::iter::FromIterator;
|
||||
use syn::Stmt;
|
||||
|
||||
#[test]
|
||||
@ -42,3 +44,31 @@ fn test_raw_variable() {
|
||||
fn test_raw_invalid() {
|
||||
assert!(syn::parse_str::<Stmt>("let _ = &raw x;").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_none_group() {
|
||||
// <Ø async fn f() {} Ø>
|
||||
let tokens = TokenStream::from_iter(vec![TokenTree::Group(Group::new(
|
||||
Delimiter::None,
|
||||
TokenStream::from_iter(vec![
|
||||
TokenTree::Ident(Ident::new("async", Span::call_site())),
|
||||
TokenTree::Ident(Ident::new("fn", Span::call_site())),
|
||||
TokenTree::Ident(Ident::new("f", Span::call_site())),
|
||||
TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())),
|
||||
TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())),
|
||||
]),
|
||||
))]);
|
||||
|
||||
snapshot!(tokens as Stmt, @r###"
|
||||
Item(Item::Fn {
|
||||
vis: Inherited,
|
||||
sig: Signature {
|
||||
asyncness: Some,
|
||||
ident: "f",
|
||||
generics: Generics,
|
||||
output: Default,
|
||||
},
|
||||
block: Block,
|
||||
})
|
||||
"###);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user