aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / syn-2.0.119 / tests / test_grouping.rs
| 1 | #![allow( |
| 2 | clippy::elidable_lifetime_names, |
| 3 | clippy::needless_lifetimes, |
| 4 | clippy::uninlined_format_args |
| 5 | )] |
| 6 | |
| 7 | #[macro_use] |
| 8 | mod snapshot; |
| 9 | |
| 10 | mod debug; |
| 11 | |
| 12 | use proc_macro2::{Delimiter, Group, Literal, Punct, Spacing, TokenStream, TokenTree}; |
| 13 | use syn::Expr; |
| 14 | |
| 15 | #[test] |
| 16 | fn test_grouping() { |
| 17 | let tokens: TokenStream = TokenStream::from_iter([ |
| 18 | TokenTree::Literal(Literal::i32_suffixed(1)), |
| 19 | TokenTree::Punct(Punct::new('+', Spacing::Alone)), |
| 20 | TokenTree::Group(Group::new( |
| 21 | Delimiter::None, |
| 22 | TokenStream::from_iter([ |
| 23 | TokenTree::Literal(Literal::i32_suffixed(2)), |
| 24 | TokenTree::Punct(Punct::new('+', Spacing::Alone)), |
| 25 | TokenTree::Literal(Literal::i32_suffixed(3)), |
| 26 | ]), |
| 27 | )), |
| 28 | TokenTree::Punct(Punct::new('*', Spacing::Alone)), |
| 29 | TokenTree::Literal(Literal::i32_suffixed(4)), |
| 30 | ]); |
| 31 | |
| 32 | assert_eq!(tokens.to_string(), "1i32 + 2i32 + 3i32 * 4i32"); |
| 33 | |
| 34 | snapshot!(tokens as Expr, @r#" |
| 35 | Expr::Binary { |
| 36 | left: Expr::Lit { |
| 37 | lit: 1i32, |
| 38 | }, |
| 39 | op: BinOp::Add, |
| 40 | right: Expr::Binary { |
| 41 | left: Expr::Group { |
| 42 | expr: Expr::Binary { |
| 43 | left: Expr::Lit { |
| 44 | lit: 2i32, |
| 45 | }, |
| 46 | op: BinOp::Add, |
| 47 | right: Expr::Lit { |
| 48 | lit: 3i32, |
| 49 | }, |
| 50 | }, |
| 51 | }, |
| 52 | op: BinOp::Mul, |
| 53 | right: Expr::Lit { |
| 54 | lit: 4i32, |
| 55 | }, |
| 56 | }, |
| 57 | } |
| 58 | "#); |
| 59 | } |