Adjust parsing with inline snapshot to reduce indentation
diff --git a/tests/macros/mod.rs b/tests/macros/mod.rs
index a83be16..5924d7d 100644
--- a/tests/macros/mod.rs
+++ b/tests/macros/mod.rs
@@ -44,6 +44,11 @@
insta::assert_debug_snapshot_matches!(syntax_tree);
syntax_tree
}};
+ (($expr:ident) as $t:ty, @$snapshot:literal) => {
+ let $expr = ::macros::Tokens::parse::<$t>($expr).unwrap();
+ let debug = crate::macros::debug::Lite(&$expr);
+ insta::assert_debug_snapshot_matches!(debug, @$snapshot);
+ };
(($($expr:tt)*) as $t:ty, @$snapshot:literal) => {{
let syntax_tree = ::macros::Tokens::parse::<$t>($($expr)*).unwrap();
let debug = crate::macros::debug::Lite(&syntax_tree);
diff --git a/tests/test_derive_input.rs b/tests/test_derive_input.rs
index c34123f..1821066 100644
--- a/tests/test_derive_input.rs
+++ b/tests/test_derive_input.rs
@@ -11,11 +11,11 @@
#[test]
fn test_unit() {
- let code = quote! {
+ let input = quote! {
struct Unit;
};
- snapshot!(code as DeriveInput, @r###"
+ snapshot!(input as DeriveInput, @r###"
⋮DeriveInput {
⋮ vis: Inherited,
⋮ ident: "Unit",
@@ -30,7 +30,7 @@
#[test]
fn test_struct() {
- let code = quote! {
+ let input = quote! {
#[derive(Debug, Clone)]
pub struct Item {
pub ident: Ident,
@@ -38,80 +38,78 @@
}
};
- let actual = {
- snapshot!(code as DeriveInput, @r###"
- ⋮DeriveInput {
- ⋮ attrs: [
- ⋮ Attribute {
- ⋮ style: Outer,
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "derive",
- ⋮ arguments: None,
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ tts: `( Debug , Clone )`,
- ⋮ },
- ⋮ ],
- ⋮ vis: Visibility::Public,
- ⋮ ident: "Item",
- ⋮ generics: Generics,
- ⋮ data: Data::Struct {
- ⋮ fields: Fields::Named {
- ⋮ named: [
- ⋮ Field {
- ⋮ vis: Visibility::Public,
- ⋮ ident: Some("ident"),
- ⋮ colon_token: Some,
- ⋮ ty: Type::Path {
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "Ident",
- ⋮ arguments: None,
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ },
- ⋮ },
- ⋮ Field {
- ⋮ vis: Visibility::Public,
- ⋮ ident: Some("attrs"),
- ⋮ colon_token: Some,
- ⋮ ty: Type::Path {
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "Vec",
- ⋮ arguments: PathArguments::AngleBracketed {
- ⋮ args: [
- ⋮ Type(Type::Path {
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "Attribute",
- ⋮ arguments: None,
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ }),
- ⋮ ],
- ⋮ },
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ },
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ },
- ⋮}
- "###)
- };
+ snapshot!(input as DeriveInput, @r###"
+ ⋮DeriveInput {
+ ⋮ attrs: [
+ ⋮ Attribute {
+ ⋮ style: Outer,
+ ⋮ path: Path {
+ ⋮ segments: [
+ ⋮ PathSegment {
+ ⋮ ident: "derive",
+ ⋮ arguments: None,
+ ⋮ },
+ ⋮ ],
+ ⋮ },
+ ⋮ tts: `( Debug , Clone )`,
+ ⋮ },
+ ⋮ ],
+ ⋮ vis: Visibility::Public,
+ ⋮ ident: "Item",
+ ⋮ generics: Generics,
+ ⋮ data: Data::Struct {
+ ⋮ fields: Fields::Named {
+ ⋮ named: [
+ ⋮ Field {
+ ⋮ vis: Visibility::Public,
+ ⋮ ident: Some("ident"),
+ ⋮ colon_token: Some,
+ ⋮ ty: Type::Path {
+ ⋮ path: Path {
+ ⋮ segments: [
+ ⋮ PathSegment {
+ ⋮ ident: "Ident",
+ ⋮ arguments: None,
+ ⋮ },
+ ⋮ ],
+ ⋮ },
+ ⋮ },
+ ⋮ },
+ ⋮ Field {
+ ⋮ vis: Visibility::Public,
+ ⋮ ident: Some("attrs"),
+ ⋮ colon_token: Some,
+ ⋮ ty: Type::Path {
+ ⋮ path: Path {
+ ⋮ segments: [
+ ⋮ PathSegment {
+ ⋮ ident: "Vec",
+ ⋮ arguments: PathArguments::AngleBracketed {
+ ⋮ args: [
+ ⋮ Type(Type::Path {
+ ⋮ path: Path {
+ ⋮ segments: [
+ ⋮ PathSegment {
+ ⋮ ident: "Attribute",
+ ⋮ arguments: None,
+ ⋮ },
+ ⋮ ],
+ ⋮ },
+ ⋮ }),
+ ⋮ ],
+ ⋮ },
+ ⋮ },
+ ⋮ ],
+ ⋮ },
+ ⋮ },
+ ⋮ },
+ ⋮ ],
+ ⋮ },
+ ⋮ },
+ ⋮}
+ "###);
- snapshot!(actual.attrs[0].interpret_meta().unwrap(), @r###"
+ snapshot!(input.attrs[0].interpret_meta().unwrap(), @r###"
⋮Meta::List {
⋮ ident: "derive",
⋮ nested: [