Move all use of snapshot to inline
diff --git a/tests/test_meta.rs b/tests/test_meta.rs
index 5a8cba7..97639cf 100644
--- a/tests/test_meta.rs
+++ b/tests/test_meta.rs
@@ -5,57 +5,176 @@
#[macro_use]
mod macros;
-use std::fmt::Debug;
-use syn::parse::Parse;
use syn::{Meta, MetaList, MetaNameValue, NestedMeta};
#[test]
fn test_parse_meta_item_word() {
- let code = "hello";
+ let input = "hello";
- snapshot!(code as Meta);
+ snapshot!(input as Meta, @r###"Word("hello")"###);
}
#[test]
fn test_parse_meta_name_value() {
- test::<MetaNameValue>("foo = 5");
+ let input = "foo = 5";
+ let (inner, meta) = (input, input);
+
+ snapshot!(inner as MetaNameValue, @r###"
+ ⋮MetaNameValue {
+ ⋮ ident: "foo",
+ ⋮ lit: 5,
+ ⋮}
+ "###);
+
+ snapshot!(meta as Meta, @r###"
+ ⋮Meta::NameValue {
+ ⋮ ident: "foo",
+ ⋮ lit: 5,
+ ⋮}
+ "###);
+
+ assert_eq!(meta, inner.into());
}
#[test]
fn test_parse_meta_name_value_with_keyword() {
- test::<MetaNameValue>("static = 5");
+ let input = "static = 5";
+ let (inner, meta) = (input, input);
+
+ snapshot!(inner as MetaNameValue, @r###"
+ ⋮MetaNameValue {
+ ⋮ ident: "static",
+ ⋮ lit: 5,
+ ⋮}
+ "###);
+
+ snapshot!(meta as Meta, @r###"
+ ⋮Meta::NameValue {
+ ⋮ ident: "static",
+ ⋮ lit: 5,
+ ⋮}
+ "###);
+
+ assert_eq!(meta, inner.into());
}
#[test]
fn test_parse_meta_name_value_with_bool() {
- test::<MetaNameValue>("true = 5");
+ let input = "true = 5";
+ let (inner, meta) = (input, input);
+
+ snapshot!(inner as MetaNameValue, @r###"
+ ⋮MetaNameValue {
+ ⋮ ident: "true",
+ ⋮ lit: 5,
+ ⋮}
+ "###);
+
+ snapshot!(meta as Meta, @r###"
+ ⋮Meta::NameValue {
+ ⋮ ident: "true",
+ ⋮ lit: 5,
+ ⋮}
+ "###);
+
+ assert_eq!(meta, inner.into());
}
#[test]
fn test_parse_meta_item_list_lit() {
- test::<MetaList>("foo(5)");
+ let input = "foo(5)";
+ let (inner, meta) = (input, input);
+
+ snapshot!(inner as MetaList, @r###"
+ ⋮MetaList {
+ ⋮ ident: "foo",
+ ⋮ nested: [
+ ⋮ Literal(5),
+ ⋮ ],
+ ⋮}
+ "###);
+
+ snapshot!(meta as Meta, @r###"
+ ⋮Meta::List {
+ ⋮ ident: "foo",
+ ⋮ nested: [
+ ⋮ Literal(5),
+ ⋮ ],
+ ⋮}
+ "###);
+
+ assert_eq!(meta, inner.into());
}
#[test]
fn test_parse_meta_item_multiple() {
- test::<MetaList>("foo(word, name = 5, list(name2 = 6), word2)");
+ let input = "foo(word, name = 5, list(name2 = 6), word2)";
+ let (inner, meta) = (input, input);
+
+ snapshot!(inner as MetaList, @r###"
+ ⋮MetaList {
+ ⋮ ident: "foo",
+ ⋮ nested: [
+ ⋮ Meta(Word("word")),
+ ⋮ Meta(Meta::NameValue {
+ ⋮ ident: "name",
+ ⋮ lit: 5,
+ ⋮ }),
+ ⋮ Meta(Meta::List {
+ ⋮ ident: "list",
+ ⋮ nested: [
+ ⋮ Meta(Meta::NameValue {
+ ⋮ ident: "name2",
+ ⋮ lit: 6,
+ ⋮ }),
+ ⋮ ],
+ ⋮ }),
+ ⋮ Meta(Word("word2")),
+ ⋮ ],
+ ⋮}
+ "###);
+
+ snapshot!(meta as Meta, @r###"
+ ⋮Meta::List {
+ ⋮ ident: "foo",
+ ⋮ nested: [
+ ⋮ Meta(Word("word")),
+ ⋮ Meta(Meta::NameValue {
+ ⋮ ident: "name",
+ ⋮ lit: 5,
+ ⋮ }),
+ ⋮ Meta(Meta::List {
+ ⋮ ident: "list",
+ ⋮ nested: [
+ ⋮ Meta(Meta::NameValue {
+ ⋮ ident: "name2",
+ ⋮ lit: 6,
+ ⋮ }),
+ ⋮ ],
+ ⋮ }),
+ ⋮ Meta(Word("word2")),
+ ⋮ ],
+ ⋮}
+ "###);
+
+ assert_eq!(meta, inner.into());
}
#[test]
fn test_parse_nested_meta() {
- let code = "5";
- snapshot!(code as NestedMeta);
+ let input = "5";
+ snapshot!(input as NestedMeta, @"Literal(5)");
- let code = "list(name2 = 6)";
- snapshot!(code as NestedMeta);
-}
-
-fn test<T>(input: &str)
-where
- T: Parse + Into<Meta> + Debug,
-{
- let inner = snapshot!(input as T);
- let meta = snapshot!(input as Meta);
-
- assert_eq!(meta, inner.into());
+ let input = "list(name2 = 6)";
+ snapshot!(input as NestedMeta, @r###"
+ ⋮Meta(Meta::List {
+ ⋮ ident: "list",
+ ⋮ nested: [
+ ⋮ Meta(Meta::NameValue {
+ ⋮ ident: "name2",
+ ⋮ lit: 6,
+ ⋮ }),
+ ⋮ ],
+ ⋮})
+ "###);
}