Write boilerplate code for being able to easily test properties.

Loads of plumbing, but we now have at least some nice ways to test property execution and shrinking.
This commit is contained in:
KtorZ
2024-03-02 16:23:43 +01:00
parent 2db15d59be
commit 70ea3c9598
5 changed files with 351 additions and 170 deletions

View File

@@ -1,7 +1,21 @@
use std::{collections::HashMap, ops::Deref, rc::Rc};
use super::{
air::{Air, ExpectLevel},
tree::{AirMsg, AirTree, TreePath},
};
use crate::{
ast::{
AssignmentKind, BinOp, ClauseGuard, Constant, DataType, DataTypeKey, FunctionAccessKey,
Pattern, Span, TraceLevel, TypedArg, TypedClause, TypedClauseGuard, TypedDataType,
TypedPattern, UnOp,
},
builtins::{bool, data, function, int, list, string, void},
expr::TypedExpr,
line_numbers::{LineColumn, LineNumbers},
tipo::{PatternConstructor, Type, TypeVar, ValueConstructor, ValueConstructorVariant},
};
use indexmap::{IndexMap, IndexSet};
use itertools::{Itertools, Position};
use std::{collections::HashMap, ops::Deref, rc::Rc};
use uplc::{
ast::{Constant as UplcConstant, Name, Term, Type as UplcType},
builder::{CONSTR_FIELDS_EXPOSER, CONSTR_INDEX_EXPOSER},
@@ -13,27 +27,6 @@ use uplc::{
Constr, KeyValuePairs, PlutusData,
};
use crate::{
ast::{
AssignmentKind, DataType, DataTypeKey, FunctionAccessKey, Pattern, Span, TraceLevel,
TypedArg, TypedClause, TypedClauseGuard, TypedDataType, TypedPattern,
},
builtins::{bool, data, function, int, list, string, void},
expr::TypedExpr,
line_numbers::{LineColumn, LineNumbers},
tipo::{PatternConstructor, TypeVar, ValueConstructor, ValueConstructorVariant},
};
use crate::{
ast::{BinOp, ClauseGuard, Constant, UnOp},
tipo::Type,
};
use super::{
air::{Air, ExpectLevel},
tree::{AirMsg, AirTree, TreePath},
};
pub type Variant = String;
pub type Params = Vec<String>;
@@ -1943,7 +1936,7 @@ pub fn extract_constant(term: &Term<Name>) -> Option<Rc<UplcConstant>> {
}
pub fn get_src_code_by_span(
module_name: &String,
module_name: &str,
span: &Span,
module_src: &IndexMap<String, (String, LineNumbers)>,
) -> String {
@@ -1957,7 +1950,7 @@ pub fn get_src_code_by_span(
}
pub fn get_line_columns_by_span(
module_name: &String,
module_name: &str,
span: &Span,
module_src: &IndexMap<String, (String, LineNumbers)>,
) -> LineColumn {