mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
82aad73bf2
Just reformat some comments to make them take up less lines.
41 lines
1.4 KiB
Rust
41 lines
1.4 KiB
Rust
/// A redefinition/wrapper macro of `quickcheck::quickcheck!` that supports
|
|
/// limiting the number of test iterations to one when we are running under MIRI.
|
|
#[macro_export]
|
|
macro_rules! quickcheck {
|
|
(
|
|
$(
|
|
$(#[$m:meta])*
|
|
fn $fn_name:ident($($arg_name:ident : $arg_ty:ty),*) -> $ret:ty {
|
|
$($code:tt)*
|
|
}
|
|
)*
|
|
) => {
|
|
$(
|
|
#[test]
|
|
$(#[$m])*
|
|
fn $fn_name() {
|
|
fn prop($($arg_name: $arg_ty),*) -> $ret {
|
|
$($code)*
|
|
}
|
|
|
|
let mut qc = ::quickcheck::QuickCheck::new();
|
|
|
|
// Use the `QUICKCHECK_TESTS` environment variable from compile time to avoid violating MIRI's isolation
|
|
// by looking at the runtime environment variable
|
|
let tests = option_env!("QUICKCHECK_TESTS").and_then(|s| s.parse().ok());
|
|
|
|
// Limit quickcheck tests to a single iteration under MIRI, since they are otherwise super slow
|
|
#[cfg(miri)]
|
|
let tests = tests.or(Some(1));
|
|
|
|
if let Some(tests) = tests {
|
|
eprintln!("Executing at most {} quickchecks", tests);
|
|
qc = qc.tests(tests);
|
|
}
|
|
|
|
qc.quickcheck(prop as fn($($arg_ty),*) -> $ret);
|
|
}
|
|
)*
|
|
};
|
|
}
|