Merge pull request #1251 from dtolnay/instaloop

Fix invalid use of insta snapshot inside a loop
This commit is contained in:
David Tolnay 2022-12-03 13:28:05 -08:00 committed by GitHub
commit 876a605f75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,36 +53,37 @@ fn test_await() {
#[rustfmt::skip]
#[test]
fn test_tuple_multi_index() {
let expected = snapshot!("tuple.0.0" as Expr, @r###"
Expr::Field {
base: Expr::Field {
base: Expr::Path {
path: Path {
segments: [
PathSegment {
ident: "tuple",
arguments: None,
},
],
},
},
member: Unnamed(Index {
index: 0,
}),
},
member: Unnamed(Index {
index: 0,
}),
}
"###);
for &input in &[
"tuple.0.0",
"tuple .0.0",
"tuple. 0.0",
"tuple.0 .0",
"tuple.0. 0",
"tuple . 0 . 0",
] {
snapshot!(input as Expr, @r###"
Expr::Field {
base: Expr::Field {
base: Expr::Path {
path: Path {
segments: [
PathSegment {
ident: "tuple",
arguments: None,
},
],
},
},
member: Unnamed(Index {
index: 0,
}),
},
member: Unnamed(Index {
index: 0,
}),
}
"###);
assert_eq!(expected, syn::parse_str(input).unwrap());
}
for tokens in vec![
@ -93,28 +94,7 @@ fn test_tuple_multi_index() {
quote!(tuple.0. 0),
quote!(tuple . 0 . 0),
] {
snapshot!(tokens as Expr, @r###"
Expr::Field {
base: Expr::Field {
base: Expr::Path {
path: Path {
segments: [
PathSegment {
ident: "tuple",
arguments: None,
},
],
},
},
member: Unnamed(Index {
index: 0,
}),
},
member: Unnamed(Index {
index: 0,
}),
}
"###);
assert_eq!(expected, syn::parse2(tokens).unwrap());
}
}