Skip to content

Commit

Permalink
Fix invalid use of insta snapshot inside a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 3, 2022
1 parent 1d09024 commit 65e0e42
Showing 1 changed file with 25 additions and 45 deletions.
70 changes: 25 additions & 45 deletions tests/test_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![
Expand All @@ -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());
}
}

Expand Down

0 comments on commit 65e0e42

Please sign in to comment.