Skip to content

Commit

Permalink
moon info
Browse files Browse the repository at this point in the history
  • Loading branch information
CAIMEOX committed Jan 9, 2025
1 parent fa85d0a commit 8e84e03
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
21 changes: 9 additions & 12 deletions src/lib/falsify/falsify.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package moonbitlang/quickcheck/lib/falsify

alias @moonbitlang/core/immut/list as @list
alias @moonbitlang/core/quickcheck/splitmix as @splitmix
alias @moonbitlang/quickcheck/lib/lazy as @lazy

// Values
fn collect[T : Show, E](String, @list.T[T]) -> Property[Unit, E]

fn combine_shrunk(Sample, SampleTree, SampleTree, @lazy.LazyList[SampleTree], @lazy.LazyList[SampleTree]) -> @lazy.LazyList[SampleTree]
fn combine_shrunk(Sample, SampleTree, SampleTree, Iter[SampleTree], Iter[SampleTree]) -> Iter[SampleTree]

fn constant(UInt) -> SampleTree

Expand All @@ -31,19 +30,19 @@ fn label[E](String, @list.T[String]) -> Property[Unit, E]

fn mk_property[T, E]((TestRun) -> Gen[(TestResult[T, E], TestRun)]) -> Property[T, E]

fn new[T]((SampleTree) -> (T, @lazy.LazyList[SampleTree])) -> Gen[T]
fn new[T]((SampleTree) -> (T, Iter[SampleTree])) -> Gen[T]

fn prim() -> Gen[UInt]

fn prim_with((Sample) -> @lazy.LazyList[UInt]) -> Gen[Sample]
fn prim_with((Sample) -> Iter[UInt]) -> Gen[Sample]

fn pure[T](T) -> Gen[T]

fn run_property[T, E](Property[T, E]) -> Gen[(TestResult[T, E], TestRun)]

fn second[A, B, C]((B) -> C, (A, B)) -> (A, C)

fn shrink_to_list[T](T, @lazy.LazyList[T]) -> Gen[T]
fn shrink_to_list[T](T, Iter[T]) -> Gen[T]

fn test_gen[T]((T) -> Bool, Gen[T]) -> Property[T, String]

Expand All @@ -65,10 +64,10 @@ impl Gen {
bind[T, U](Self[T], (T) -> Self[U]) -> Self[U]
fmap[T, U](Self[T], (T) -> U) -> Self[U]
ifS[T](Self[Bool], Self[T], Self[T]) -> Self[T]
run_gen[T](Self[T], SampleTree) -> (T, @lazy.LazyList[SampleTree])
run_gen[T](Self[T], SampleTree) -> (T, Iter[SampleTree])
sample[T](Self[T]) -> T
select[T, U](Self[(T) -> U], Self[Either[T, U]]) -> Self[U]
shrink_from[A, P, N](Self[A], (A) -> IsValidShrink[P, N], (P, @lazy.LazyList[SampleTree])) -> ShrinkExplain[P, N]
shrink_from[A, P, N](Self[A], (A) -> IsValidShrink[P, N], (P, Iter[SampleTree])) -> ShrinkExplain[P, N]
}

type IsValidShrink
Expand All @@ -94,12 +93,12 @@ type ShrinkExplain
impl ShrinkExplain {
limit_steps[P, N](Self[P, N], Int?) -> Self[P, N]
shrink_history[P, N](Self[P, N]) -> Array[P]
shrink_outcome[P, N](Self[P, N]) -> (P, @lazy.LazyList[N]?)
shrink_outcome[P, N](Self[P, N]) -> (P, Iter[N]?)
}
impl[P : Show, N : Show] Show for ShrinkExplain[P, N]

type ShrinkHistroy
impl[P : Show, N : Show] Show for ShrinkHistroy[P, N]
type ShrinkHistory
impl[P : Show, N : Show] Show for ShrinkHistory[P, N]

type Success
impl[T : Show] Show for Success[T]
Expand All @@ -110,8 +109,6 @@ type TestRun
impl Show for TestRun

// Type aliases
pub typealias LazyList[T] = @lazy.LazyList[T]

pub typealias List[T] = @list.T[T]

pub typealias RandomState = @splitmix.RandomState
Expand Down
4 changes: 4 additions & 0 deletions src/lib/lazy/lazy.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ alias @moonbitlang/core/immut/list as @list
// Values
fn default[X : Default]() -> LazyList[X]

fn from_list[T](@list.T[T]) -> LazyList[T]

fn infinite_stream[X : Monoid](X, X) -> LazyList[X]

fn repeat[T](T) -> LazyList[T]
Expand All @@ -26,6 +28,7 @@ pub(all) enum LazyList {
}
impl LazyList {
concat[T](Self[T], Self[T]) -> Self[T]
drop[T](Self[T], Int) -> Self[T]
drop_while[T](Self[T], (T) -> Bool) -> Self[T]
fold_left[T, U](Self[T], (U, T) -> U, init~ : U) -> U
fold_right[T, U](Self[T], (T, U) -> U, init~ : U) -> U
Expand All @@ -37,6 +40,7 @@ impl LazyList {
split_at[T](Self[T], Int) -> (Self[T], Self[T])
tail[T](Self[T]) -> Self[T]
tails[T](Self[T]) -> Self[Self[T]]
take[T](Self[T], Int) -> Self[T]
take_while[T](Self[T], (T) -> Bool) -> Self[T]
unfold[T](Self[T], (Self[T]) -> (T, Self[T])?) -> Self[T]
}
Expand Down
45 changes: 34 additions & 11 deletions src/lib/lib.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ fn list_with_size[T](Int, Gen[T]) -> Gen[@list.T[T]]

fn local_min_found(State, SingleResult) -> (Int, Int, Int, SingleResult)

fn map_prop[P : Testable](P, (@rose.Rose[SingleResult]) -> @rose.Rose[SingleResult]) -> Property

fn map_rose_result[P : Testable](P, (@rose.Rose[SingleResult]) -> @rose.Rose[SingleResult]) -> Property

fn map_size[P : Testable](P, (Int) -> Int) -> Property

fn map_total_result[P : Testable](P, (SingleResult) -> SingleResult) -> Property
Expand Down Expand Up @@ -124,6 +120,8 @@ fn quick_check_with_result[P : Testable](Config, P) -> TestSuccess!TestError

fn rejected() -> SingleResult

fn run_prop[P : Testable](P) -> Gen[@rose.Rose[SingleResult]]

fn shrinking[P : Testable, T]((T) -> Iter[T], T, (T) -> P) -> Property

fn sized[T]((Int) -> Gen[T]) -> Gen[T]
Expand All @@ -149,7 +147,7 @@ fn with_max_size[P : Testable](P, Int) -> Property
fn with_max_success[P : Testable](P, Int) -> Property

// Types and methods
type Arrow
pub type Arrow (A) -> B
impl[P : Testable, A : @quickcheck.Arbitrary + Shrink + Show] Testable for Arrow[A, P]

type Axiom
Expand All @@ -163,15 +161,23 @@ impl Axiom {
}

type Callback
impl Show for Callback

type Config

type Coverage

type Discard
impl Default for Discard
impl Testable for Discard

type Dyn

type DynMap
impl DynMap {
insert[T : Dynamic](Self, T) -> Unit
query[T : Dynamic](Self) -> T?
}

type Equivalence
impl Equivalence {
ap[T, U](Self[(T) -> U], Self[T]) -> Self[U]
Expand Down Expand Up @@ -203,6 +209,8 @@ impl Gen {
}
impl[P : Testable] Testable for Gen[P]

type IntE

type InternalError

type Kind
Expand All @@ -229,10 +237,6 @@ impl Printer {
}

type Property
impl Property {
make(Gen[@rose.Rose[SingleResult]]) -> Self
run_prop(Self) -> Gen[@rose.Rose[SingleResult]]
}
impl Testable for Property

pub(all) struct Replay {
Expand All @@ -243,8 +247,9 @@ impl Replay {
new(@splitmix.RandomState, Int) -> Self
}

type ShowE

type SingleResult
impl Show for SingleResult
impl Testable for SingleResult

type State
Expand All @@ -257,19 +262,35 @@ impl State {
run_test(Self, Property) -> TestSuccess!TestError
}

type StringE

type TestError

type TestSuccess

type TypeRep
impl Eq for TypeRep
impl Hash for TypeRep

type UIntE

type UnitE

// Type aliases
pub typealias RandomState = @splitmix.RandomState

// Traits
trait Dynamic

pub(open) trait Shrink {
shrink(Self) -> Iter[Self]
}
impl Shrink::shrink

pub(open) trait SumTuple {
sumOf(Self) -> Int
}

pub(open) trait Testable {
property(Self) -> Property
}
Expand All @@ -278,3 +299,5 @@ impl Testable for Bool
impl[P : Testable] Testable for P?
impl Testable for @rose.Rose[SingleResult]

trait Unfold

0 comments on commit 8e84e03

Please sign in to comment.