Add Fuzzer to the prelude.
This commit is contained in:
parent
5b4fedd084
commit
93347d8e7b
|
@ -29,7 +29,7 @@ pub const OPTION: &str = "Option";
|
|||
pub const ORDERING: &str = "Ordering";
|
||||
pub const REDEEMER_WRAPPER: &str = "RedeemerWrapper";
|
||||
pub const PRNG: &str = "PRNG";
|
||||
pub const FUZZER: &str = "FUZZER";
|
||||
pub const FUZZER: &str = "Fuzzer";
|
||||
|
||||
/// Build a prelude that can be injected
|
||||
/// into a compiler pipeline
|
||||
|
@ -482,6 +482,23 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo {
|
|||
),
|
||||
);
|
||||
|
||||
// Fuzzer
|
||||
//
|
||||
// pub type Fuzzer<a> =
|
||||
// fn(PRNG) -> Option<(PRNG, a)>
|
||||
|
||||
let fuzzer_value = generic_var(id_gen.next());
|
||||
prelude.types.insert(
|
||||
FUZZER.to_string(),
|
||||
TypeConstructor {
|
||||
location: Span::empty(),
|
||||
parameters: vec![fuzzer_value.clone()],
|
||||
tipo: fuzzer(fuzzer_value),
|
||||
module: "".to_string(),
|
||||
public: true,
|
||||
},
|
||||
);
|
||||
|
||||
prelude
|
||||
}
|
||||
|
||||
|
@ -1302,6 +1319,13 @@ pub fn prng() -> Rc<Type> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn fuzzer(a: Rc<Type>) -> Rc<Type> {
|
||||
Rc::new(Type::Fn {
|
||||
args: vec![prng()],
|
||||
ret: option(tuple(vec![prng(), a])),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn list(t: Rc<Type>) -> Rc<Type> {
|
||||
Rc::new(Type::App {
|
||||
public: true,
|
||||
|
|
|
@ -2,9 +2,6 @@ use aiken/builtin
|
|||
|
||||
const max_int: Int = 255
|
||||
|
||||
pub type Fuzzer<a> =
|
||||
fn(PRNG) -> Option<(PRNG, a)>
|
||||
|
||||
// Primitives
|
||||
|
||||
pub fn any_int() -> Fuzzer<Int> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use aiken/dict.{Dict}
|
||||
use aiken/fuzz.{Fuzzer}
|
||||
use aiken/fuzz
|
||||
use aiken/int
|
||||
|
||||
pub type Season {
|
||||
|
|
Loading…
Reference in New Issue