Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions crates/ty_python_semantic/src/types/property_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,41 @@ use type_generation::{intersection, union};
///
/// where `t1`, `t2`, ..., `tn` are identifiers that represent arbitrary types, and `<property>`
/// is an expression using these identifiers.
///
macro_rules! type_property_test {
($test_name:ident, $db:ident, forall types $($types:ident),+ . $property:expr) => {
#[quickcheck_macros::quickcheck]
#[ignore]
fn $test_name($($types: crate::types::property_tests::type_generation::Ty),+) -> bool {
let $db = &crate::types::property_tests::setup::get_cached_db();
$(let $types = $types.into_type($db);)+
let result = $property;

if !result {
println!("\nFailing types were:");
$(println!("{}", $types.display($db));)+
}

$property
result
}
};

($test_name:ident, $db:ident, forall fully_static_types $($types:ident),+ . $property:expr) => {
#[quickcheck_macros::quickcheck]
#[ignore]
fn $test_name($($types: crate::types::property_tests::type_generation::FullyStaticTy),+) -> bool {
let $db = &crate::types::property_tests::setup::get_cached_db();
$(let $types = $types.into_type($db);)+
let result = $property;

$property
if !result {
println!("\nFailing types were:");
$(println!("{}", $types.display($db));)+
}

result
}
};

// A property test with a logical implication.
($name:ident, $db:ident, forall $typekind:ident $($types:ident),+ . $premise:expr => $conclusion:expr) => {
type_property_test!($name, $db, forall $typekind $($types),+ . !($premise) || ($conclusion));
Expand Down
Loading