Skip to content

Commit

Permalink
test: Add from_for_generic_and_regular test
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmah309 committed Dec 5, 2024
1 parent 67eaf39 commit 6f1d9d6
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,10 @@ pub mod generics {

#[cfg(test)]
pub mod disable {
use std::{error::Error, fmt::{Debug, Display}};
use std::{
error::Error,
fmt::{Debug, Display},
};

use error_set::error_set;

Expand Down Expand Up @@ -831,6 +834,32 @@ pub mod disable {
}
}

#[cfg(test)]
pub mod from_for_generic_and_regular {
use error_set::error_set;

error_set! {
#[disable(From(E))]
X<E: core::error::Error + core::fmt::Debug + core::fmt::Display> = Y || Z<E>;
Y = {
A,
};
Z<E: core::error::Error + core::fmt::Debug + core::fmt::Display> = {
B(E),
};
}

#[test]
fn test() {
let y = Y::A;
let x: X<std::io::Error> = y.into();
assert!(matches!(x, X::A));

let z = Z::B(std::io::Error::new(std::io::ErrorKind::Other, "oops"));
let x: X<std::io::Error> = z.into();
assert!(matches!(x, X::B(_)));
}
}
#[cfg(test)]
pub mod should_not_compile_tests {

Expand Down

0 comments on commit 6f1d9d6

Please sign in to comment.