Introduce 'ArgBy' to allow defining function arg not only by name.

This commit is contained in:
KtorZ
2024-06-07 11:17:16 +02:00
parent 257bd23019
commit 4d42c6cb19
21 changed files with 651 additions and 488 deletions

View File

@@ -1,6 +1,6 @@
use aiken_lang::ast::OnTestFailure;
pub(crate) use aiken_lang::{
ast::{Arg, BinOp, DataTypeKey, IfBranch, Span, TypedDataType, TypedTest},
ast::{BinOp, DataTypeKey, IfBranch, Span, TypedArg, TypedDataType, TypedTest},
builtins::bool,
expr::{TypedExpr, UntypedExpr},
format::Formatter,
@@ -124,13 +124,13 @@ impl Test {
let via = parameter.via.clone();
let type_info = parameter.tipo.clone();
let type_info = parameter.arg.tipo.clone();
let stripped_type_info = convert_opaque_type(&type_info, generator.data_types(), true);
let program = generator.clone().generate_raw(
&test.body,
&[Arg {
&[TypedArg {
tipo: stripped_type_info.clone(),
..parameter.clone().into()
}],
@@ -507,8 +507,10 @@ impl Prng {
fn as_prng(cst: &PlutusData) -> Prng {
if let PlutusData::Constr(Constr { tag, fields, .. }) = cst {
if *tag == 121 + Prng::SEEDED {
if let [PlutusData::BoundedBytes(bytes), PlutusData::BoundedBytes(choices)] =
&fields[..]
if let [
PlutusData::BoundedBytes(bytes),
PlutusData::BoundedBytes(choices),
] = &fields[..]
{
return Prng::Seeded {
choices: choices.to_vec(),
@@ -1087,9 +1089,11 @@ impl TryFrom<TypedExpr> for Assertion<TypedExpr> {
final_else,
..
} => {
if let [IfBranch {
condition, body, ..
}] = &branches[..]
if let [
IfBranch {
condition, body, ..
},
] = &branches[..]
{
let then_is_true = match body {
TypedExpr::Var {
@@ -1508,13 +1512,14 @@ mod test {
}
"#});
assert!(prop
.run::<()>(
assert!(
prop.run::<()>(
42,
PropertyTest::DEFAULT_MAX_SUCCESS,
&PlutusVersion::default()
)
.is_success());
.is_success()
);
}
#[test]