Skip to content

Commit

Permalink
Uh, formatting again..
Browse files Browse the repository at this point in the history
  • Loading branch information
Riley-Kilgore committed Dec 17, 2024
1 parent 7b80e32 commit b94150b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion crates/aiken-lang/src/ast/well_known.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ impl Type {
.into(),
}
.into(),
}
},
}
.into(),
),
Expand Down
2 changes: 1 addition & 1 deletion crates/aiken-lang/src/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo {
tipo: Type::sampler(sampler_generic),
module: "".to_string(),
public: true,
}
},
);

prelude
Expand Down
29 changes: 10 additions & 19 deletions crates/aiken-lang/src/test_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use vec1::{vec1, Vec1};
pub enum Test {
UnitTest(UnitTest),
PropertyTest(PropertyTest),
Benchmark(Benchmark)
Benchmark(Benchmark),
}

unsafe impl Send for Test {}
Expand Down Expand Up @@ -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))) => {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand All @@ -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 {
Expand Down
16 changes: 9 additions & 7 deletions crates/aiken-lang/src/tipo/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
9 changes: 6 additions & 3 deletions crates/aiken-project/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit b94150b

Please sign in to comment.