aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorEdvard Thörnros <edvard.thornros@gmail.com>2021-02-19 18:07:21 +0100
committerGitHub <noreply@github.com>2021-02-19 18:07:21 +0100
commitfe41db5dceecb01a0ada18ea2fc369abb1498aa3 (patch)
tree539e63178a3a687bc4df92d53712cd9b028bf0e9 /src/lib.rs
parentf024e88de53c24fd5e5e2fb2d66947dc93262af8 (diff)
parent7e330b8d622183696ddf3c7f8140c6510804e0a0 (diff)
downloadsylt-fe41db5dceecb01a0ada18ea2fc369abb1498aa3.tar.gz
Merge branch 'main' into unusued-variables
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 40bae2b..e8b6c54 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -771,9 +771,14 @@ mod tests {
#[macro_export]
macro_rules! assert_errs {
($result:expr, [ $( $kind:pat ),* ]) => {
- eprintln!("{} => {:?}", stringify!($result), $result);
- assert!(matches!(
- $result.unwrap_err().as_slice(),
+ let errs = if let Err(errs) = $result {
+ errs
+ } else {
+ eprintln!(" Program succeeded when it should've failed");
+ unreachable!();
+ };
+ if !matches!(
+ errs.as_slice(),
&[$($crate::error::Error {
kind: $kind,
file: _,
@@ -781,7 +786,19 @@ mod tests {
message: _,
},
)*]
- ))
+ ) {
+ eprintln!("Unexpected errors");
+ eprint!(" Got: [");
+ for err in errs {
+ eprint!(" ErrorKind::{:?} ", err.kind);
+ }
+ eprint!("]\n Want: [");
+ $(
+ eprint!(" {} ", stringify!($kind));
+ )*
+ eprintln!("]");
+ assert!(false);
+ }
};
}
@@ -831,8 +848,8 @@ mod tests {
for e in errs.iter() {
println!("{}", e);
}
- println!(" {} - FAILED\n", stringify!($fn));
- panic!();
+ eprintln!(" {} - failed\n", stringify!($fn));
+ unreachable!();
}
}
});