From 8e84e038848e08893fc706981ce2e6e8226610e0 Mon Sep 17 00:00:00 2001 From: CAIMEOX <38813005+CAIMEOX@users.noreply.github.com> Date: Thu, 9 Jan 2025 19:02:25 +0800 Subject: [PATCH] moon info --- src/lib/falsify/falsify.mbti | 21 ++++++++--------- src/lib/lazy/lazy.mbti | 4 ++++ src/lib/lib.mbti | 45 +++++++++++++++++++++++++++--------- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/lib/falsify/falsify.mbti b/src/lib/falsify/falsify.mbti index 6f9624e..5115505 100644 --- a/src/lib/falsify/falsify.mbti +++ b/src/lib/falsify/falsify.mbti @@ -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 @@ -31,11 +30,11 @@ 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] @@ -43,7 +42,7 @@ 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] @@ -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 @@ -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] @@ -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 diff --git a/src/lib/lazy/lazy.mbti b/src/lib/lazy/lazy.mbti index 372bab4..9f247a1 100644 --- a/src/lib/lazy/lazy.mbti +++ b/src/lib/lazy/lazy.mbti @@ -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] @@ -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 @@ -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] } diff --git a/src/lib/lib.mbti b/src/lib/lib.mbti index 2358772..d6a9324 100644 --- a/src/lib/lib.mbti +++ b/src/lib/lib.mbti @@ -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 @@ -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] @@ -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 @@ -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] @@ -203,6 +209,8 @@ impl Gen { } impl[P : Testable] Testable for Gen[P] +type IntE + type InternalError type Kind @@ -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 { @@ -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 @@ -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 } @@ -278,3 +299,5 @@ impl Testable for Bool impl[P : Testable] Testable for P? impl Testable for @rose.Rose[SingleResult] +trait Unfold +