Skip to content

Commit

Permalink
Add a failing tests for #1504
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio authored and Jesse Hoobergs committed Jan 21, 2022
1 parent 3bb4a5a commit dedf989
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test_suite/tests/test_annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,64 @@ fn test_rename_struct() {
);
}

#[test]
#[should_panic] // FIXME(emilio): It shouldn't!
fn test_alias_flattened() {
#[derive(Debug, PartialEq, Deserialize)]
struct Flattened {
#[serde(flatten)]
with_aliases: AliasStruct,
}

// First without the aliases.
assert_de_tokens(
&Flattened {
with_aliases: AliasStruct {
a1: 1,
a2: 2,
a4: 3,
},
},
&[
Token::Struct {
name: "Flattened",
len: 3,
},
Token::Str("a1"),
Token::I32(1),
Token::Str("a2"),
Token::I32(2),
Token::Str("a6"),
Token::I32(3),
Token::StructEnd,
],
);

// Now with them
assert_de_tokens(
&Flattened {
with_aliases: AliasStruct {
a1: 1,
a2: 2,
a4: 3,
},
},
&[
Token::Struct {
name: "Flattened",
len: 3,
},
Token::Str("a1"),
Token::I32(1),
Token::Str("a3"),
Token::I32(2),
Token::Str("a6"),
Token::I32(3),
Token::StructEnd,
],
);
}

#[test]
fn test_unknown_field_rename_struct() {
assert_de_tokens_error::<AliasStruct>(
Expand Down

0 comments on commit dedf989

Please sign in to comment.