mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-22 13:23:18 +00:00
[ty] Print display of types when a property test fails (#20720)
Some checks are pending
CI / cargo build (release) (push) Waiting to run
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / mkdocs (push) Waiting to run
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks instrumented (ruff) (push) Blocked by required conditions
CI / benchmarks instrumented (ty) (push) Blocked by required conditions
CI / benchmarks-walltime (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
Some checks are pending
CI / cargo build (release) (push) Waiting to run
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / mkdocs (push) Waiting to run
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks instrumented (ruff) (push) Blocked by required conditions
CI / benchmarks instrumented (ty) (push) Blocked by required conditions
CI / benchmarks-walltime (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
This commit is contained in:
parent
9a29f7a339
commit
70f51e9648
1 changed files with 16 additions and 3 deletions
|
|
@ -38,7 +38,6 @@ use type_generation::{intersection, union};
|
||||||
///
|
///
|
||||||
/// where `t1`, `t2`, ..., `tn` are identifiers that represent arbitrary types, and `<property>`
|
/// where `t1`, `t2`, ..., `tn` are identifiers that represent arbitrary types, and `<property>`
|
||||||
/// is an expression using these identifiers.
|
/// is an expression using these identifiers.
|
||||||
///
|
|
||||||
macro_rules! type_property_test {
|
macro_rules! type_property_test {
|
||||||
($test_name:ident, $db:ident, forall types $($types:ident),+ . $property:expr) => {
|
($test_name:ident, $db:ident, forall types $($types:ident),+ . $property:expr) => {
|
||||||
#[quickcheck_macros::quickcheck]
|
#[quickcheck_macros::quickcheck]
|
||||||
|
|
@ -46,20 +45,34 @@ macro_rules! type_property_test {
|
||||||
fn $test_name($($types: crate::types::property_tests::type_generation::Ty),+) -> bool {
|
fn $test_name($($types: crate::types::property_tests::type_generation::Ty),+) -> bool {
|
||||||
let $db = &crate::types::property_tests::setup::get_cached_db();
|
let $db = &crate::types::property_tests::setup::get_cached_db();
|
||||||
$(let $types = $types.into_type($db);)+
|
$(let $types = $types.into_type($db);)+
|
||||||
|
let result = $property;
|
||||||
|
|
||||||
$property
|
if !result {
|
||||||
|
println!("\nFailing types were:");
|
||||||
|
$(println!("{}", $types.display($db));)+
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
($test_name:ident, $db:ident, forall fully_static_types $($types:ident),+ . $property:expr) => {
|
($test_name:ident, $db:ident, forall fully_static_types $($types:ident),+ . $property:expr) => {
|
||||||
#[quickcheck_macros::quickcheck]
|
#[quickcheck_macros::quickcheck]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn $test_name($($types: crate::types::property_tests::type_generation::FullyStaticTy),+) -> bool {
|
fn $test_name($($types: crate::types::property_tests::type_generation::FullyStaticTy),+) -> bool {
|
||||||
let $db = &crate::types::property_tests::setup::get_cached_db();
|
let $db = &crate::types::property_tests::setup::get_cached_db();
|
||||||
$(let $types = $types.into_type($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.
|
// A property test with a logical implication.
|
||||||
($name:ident, $db:ident, forall $typekind:ident $($types:ident),+ . $premise:expr => $conclusion:expr) => {
|
($name:ident, $db:ident, forall $typekind:ident $($types:ident),+ . $premise:expr => $conclusion:expr) => {
|
||||||
type_property_test!($name, $db, forall $typekind $($types),+ . !($premise) || ($conclusion));
|
type_property_test!($name, $db, forall $typekind $($types),+ . !($premise) || ($conclusion));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue