mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2024-11-23 16:00:10 +00:00
Add regression test of pattern inside None group
This commit is contained in:
parent
4f547c9aad
commit
915ca09e50
@ -1,4 +1,9 @@
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
use proc_macro2::{Delimiter, Group, TokenStream, TokenTree};
|
||||
use quote::quote;
|
||||
use std::iter::FromIterator;
|
||||
use syn::{Item, Pat, Stmt};
|
||||
|
||||
#[test]
|
||||
@ -36,3 +41,27 @@ fn test_leading_vert() {
|
||||
syn::parse_str::<Stmt>("let NS { f: | A }: NS;").unwrap_err();
|
||||
syn::parse_str::<Stmt>("let NS { f: || A }: NS;").unwrap_err();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_group() {
|
||||
let group = Group::new(Delimiter::None, quote!(Some(_)));
|
||||
let tokens = TokenStream::from_iter(vec![TokenTree::Group(group)]);
|
||||
|
||||
snapshot!(tokens as Pat, @r###"
|
||||
Pat::TupleStruct {
|
||||
path: Path {
|
||||
segments: [
|
||||
PathSegment {
|
||||
ident: "Some",
|
||||
arguments: None,
|
||||
},
|
||||
],
|
||||
},
|
||||
pat: PatTuple {
|
||||
elems: [
|
||||
Pat::Wild,
|
||||
],
|
||||
},
|
||||
}
|
||||
"###);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user