Skip to content

Commit

Permalink
Assert syntax errors via pretty_assertions
Browse files Browse the repository at this point in the history
If test will fail due to another syntax error we get a nice diff
  • Loading branch information
Mingun committed Jul 6, 2024
1 parent be86267 commit 0d99a16
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions src/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,9 +1172,9 @@ mod test {
// ^= 1

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedCData)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedCData),
x => panic!(
"Expected `Err(Syntax(UnclosedCData))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand All @@ -1191,9 +1191,9 @@ mod test {
// ^= 1 ^= 22

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedCData)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedCData),
x => panic!(
"Expected `Err(Syntax(UnclosedCData))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand Down Expand Up @@ -1270,9 +1270,9 @@ mod test {
// ^= 1

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedComment)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedComment),
x => panic!(
"Expected `Err(Syntax(UnclosedComment))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand All @@ -1287,9 +1287,9 @@ mod test {
// ^= 1 ^= 17

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedComment)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedComment),
x => panic!(
"Expected `Err(Syntax(UnclosedComment))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand All @@ -1304,9 +1304,9 @@ mod test {
// ^= 1 ^= 17

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedComment)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedComment),
x => panic!(
"Expected `Err(Syntax(UnclosedComment))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand All @@ -1321,9 +1321,9 @@ mod test {
// ^= 1 ^= 18

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedComment)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedComment),
x => panic!(
"Expected `Err(Syntax(UnclosedComment))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand All @@ -1338,9 +1338,9 @@ mod test {
// ^= 1 ^= 19

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedComment)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedComment),
x => panic!(
"Expected `Err(Syntax(UnclosedComment))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand Down Expand Up @@ -1400,9 +1400,9 @@ mod test {
// ^= 1 ^= 17

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedDoctype)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedDoctype),
x => panic!(
"Expected `Err(Syntax(UnclosedDoctype))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand All @@ -1417,9 +1417,9 @@ mod test {
// ^= 1 ^= 22

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedDoctype)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedDoctype),
x => panic!(
"Expected `Err(Syntax(UnclosedDoctype))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand Down Expand Up @@ -1452,9 +1452,9 @@ mod test {
// ^= 1 ^23

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedDoctype)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedDoctype),
x => panic!(
"Expected `Err(Syntax(UnclosedDoctype))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand All @@ -1474,9 +1474,9 @@ mod test {
// ^= 1 ^= 17

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedDoctype)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedDoctype),
x => panic!(
"Expected `Err(Syntax(UnclosedDoctype))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand All @@ -1491,9 +1491,9 @@ mod test {
// ^= 1 ^= 22

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedDoctype)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedDoctype),
x => panic!(
"Expected `Err(Syntax(UnclosedDoctype))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand Down Expand Up @@ -1526,9 +1526,9 @@ mod test {
// ^= 1 ^= 23

match $source(&mut input).read_bang_element(buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedDoctype)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedDoctype),
x => panic!(
"Expected `Err(Syntax(UnclosedDoctype))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand All @@ -1554,9 +1554,9 @@ mod test {
// ^= 1

match $source(&mut input).read_with(ElementParser::default(), buf, &mut position) $(.$await)? {
Err(Error::Syntax(SyntaxError::UnclosedTag)) => {}
Err(Error::Syntax(cause)) => assert_eq!(cause, SyntaxError::UnclosedTag),
x => panic!(
"Expected `Err(Syntax(UnclosedTag))`, but got `{:?}`",
"Expected `Err(Syntax(_))`, but got `{:?}`",
x
),
}
Expand Down

0 comments on commit 0d99a16

Please sign in to comment.