Uh, formatting again..
This commit is contained in:
parent
d73ee3dfe7
commit
df05ae7e5d
|
@ -260,7 +260,7 @@ impl Type {
|
|||
.into(),
|
||||
}
|
||||
.into(),
|
||||
}
|
||||
},
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
|
|
|
@ -506,7 +506,7 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo {
|
|||
tipo: Type::sampler(sampler_generic),
|
||||
module: "".to_string(),
|
||||
public: true,
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
prelude
|
||||
|
|
|
@ -49,7 +49,7 @@ use vec1::{vec1, Vec1};
|
|||
pub enum Test {
|
||||
UnitTest(UnitTest),
|
||||
PropertyTest(PropertyTest),
|
||||
Benchmark(Benchmark)
|
||||
Benchmark(Benchmark),
|
||||
}
|
||||
|
||||
unsafe impl Send for Test {}
|
||||
|
@ -383,9 +383,7 @@ impl PropertyTest {
|
|||
value,
|
||||
choices: next_prng.choices(),
|
||||
cache: Cache::new(move |choices| {
|
||||
match Prng::from_choices(choices)
|
||||
.sample(&self.fuzzer.program)
|
||||
{
|
||||
match Prng::from_choices(choices).sample(&self.fuzzer.program) {
|
||||
Err(..) => Status::Invalid,
|
||||
Ok(None) => Status::Invalid,
|
||||
Ok(Some((_, value))) => {
|
||||
|
@ -468,7 +466,10 @@ impl Benchmark {
|
|||
let mut prng = Prng::from_seed(seed);
|
||||
|
||||
while n > iteration {
|
||||
let fuzzer = self.sampler.program.apply_data(Data::integer(num_bigint::BigInt::from(iteration as i64)));
|
||||
let fuzzer = self
|
||||
.sampler
|
||||
.program
|
||||
.apply_data(Data::integer(num_bigint::BigInt::from(iteration as i64)));
|
||||
match prng.sample(&fuzzer) {
|
||||
Ok(Some((new_prng, value))) => {
|
||||
prng = new_prng;
|
||||
|
@ -529,14 +530,8 @@ impl Benchmark {
|
|||
///
|
||||
#[derive(Debug)]
|
||||
pub enum Prng {
|
||||
Seeded {
|
||||
choices: Vec<u8>,
|
||||
uplc: PlutusData,
|
||||
},
|
||||
Replayed {
|
||||
choices: Vec<u8>,
|
||||
uplc: PlutusData,
|
||||
},
|
||||
Seeded { choices: Vec<u8>, uplc: PlutusData },
|
||||
Replayed { choices: Vec<u8>, uplc: PlutusData },
|
||||
}
|
||||
|
||||
impl Prng {
|
||||
|
@ -607,9 +602,7 @@ impl Prng {
|
|||
fuzzer: &Program<Name>,
|
||||
// iteration: usize,
|
||||
) -> Result<Option<(Prng, PlutusData)>, FuzzerError> {
|
||||
let program = Program::<NamedDeBruijn>::try_from(
|
||||
fuzzer
|
||||
.apply_data(self.uplc())).unwrap();
|
||||
let program = Program::<NamedDeBruijn>::try_from(fuzzer.apply_data(self.uplc())).unwrap();
|
||||
let mut result = program.eval(ExBudget::max());
|
||||
result
|
||||
.result()
|
||||
|
@ -630,9 +623,7 @@ impl Prng {
|
|||
/// made during shrinking aren't breaking underlying invariants (if only, because we run out of
|
||||
/// values to replay). In such case, the replayed sequence is simply invalid and the fuzzer
|
||||
/// aborted altogether with 'None'.
|
||||
pub fn from_result(
|
||||
result: Term<NamedDeBruijn>,
|
||||
) -> Option<(Self, PlutusData)> {
|
||||
pub fn from_result(result: Term<NamedDeBruijn>) -> Option<(Self, PlutusData)> {
|
||||
/// Interpret the given 'PlutusData' as one of two Prng constructors.
|
||||
fn as_prng(cst: &PlutusData) -> Prng {
|
||||
if let PlutusData::Constr(Constr { tag, fields, .. }) = cst {
|
||||
|
|
|
@ -365,7 +365,7 @@ fn infer_definition(
|
|||
&arg.via.location(),
|
||||
) {
|
||||
Ok(result) => Ok(result),
|
||||
Err(err) => Err(err)
|
||||
Err(err) => Err(err),
|
||||
}?;
|
||||
|
||||
// Ensure that the annotation, if any, matches the type inferred from the
|
||||
|
@ -501,7 +501,7 @@ fn infer_definition(
|
|||
&arg.via.location(),
|
||||
) {
|
||||
Ok(result) => Ok(result),
|
||||
Err(err) => Err(err)
|
||||
Err(err) => Err(err),
|
||||
}?;
|
||||
|
||||
// Ensure that the annotation, if any, matches the type inferred from the
|
||||
|
@ -930,11 +930,13 @@ fn infer_sampler(
|
|||
ret,
|
||||
args,
|
||||
alias: _,
|
||||
} => if args.len() == 1 && args[0].is_int() {
|
||||
infer_fuzzer(environment, expected_inner_type, ret, &Span::empty())
|
||||
} else {
|
||||
Err(could_not_unify())
|
||||
},
|
||||
} => {
|
||||
if args.len() == 1 && args[0].is_int() {
|
||||
infer_fuzzer(environment, expected_inner_type, ret, &Span::empty())
|
||||
} else {
|
||||
Err(could_not_unify())
|
||||
}
|
||||
}
|
||||
|
||||
Type::Var { tipo, alias } => match &*tipo.deref().borrow() {
|
||||
TypeVar::Link { tipo } => infer_sampler(
|
||||
|
|
|
@ -474,7 +474,8 @@ where
|
|||
output,
|
||||
} => {
|
||||
// todo - collect benchmarks
|
||||
let tests = self.collect_benchmarks(false, match_tests, exact_match, options.tracing)?;
|
||||
let tests =
|
||||
self.collect_benchmarks(false, match_tests, exact_match, options.tracing)?;
|
||||
|
||||
if !tests.is_empty() {
|
||||
self.event_listener.handle_event(Event::RunningBenchmarks);
|
||||
|
@ -1215,7 +1216,7 @@ where
|
|||
Test::PropertyTest(property_test) => {
|
||||
property_test.run(seed, property_max_success, plutus_version)
|
||||
}
|
||||
Test::Benchmark(_) => unreachable!("Benchmarks cannot be run in PBT.")
|
||||
Test::Benchmark(_) => unreachable!("Benchmarks cannot be run in PBT."),
|
||||
})
|
||||
.collect::<Vec<TestResult<(Constant, Rc<Type>), PlutusData>>>()
|
||||
.into_iter()
|
||||
|
@ -1237,7 +1238,9 @@ where
|
|||
tests
|
||||
.into_par_iter()
|
||||
.flat_map(|test| match test {
|
||||
Test::UnitTest(_) | Test::PropertyTest(_) => unreachable!("Tests cannot be ran during benchmarking."),
|
||||
Test::UnitTest(_) | Test::PropertyTest(_) => {
|
||||
unreachable!("Tests cannot be ran during benchmarking.")
|
||||
}
|
||||
Test::Benchmark(benchmark) => benchmark
|
||||
.benchmark(seed, property_max_success, plutus_version)
|
||||
.into_iter()
|
||||
|
|
Loading…
Reference in New Issue