Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 72 additions & 12 deletions quickcheck/splitmix/README.mbt.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,30 @@ Create and initialize random number generators:
test "random state creation" {
// Create with default seed
let rng1 = @splitmix.new()
inspect(rng1.to_string().length() > 0, content="true")
debug_inspect(
rng1,
content=(
#|{ seed: 6185074585042305769, gamma: 16934044424796929712 }
),
)

// Create with specific seed
let rng2 = @splitmix.new(seed=12345UL)
inspect(rng2.to_string().length() > 0, content="true")
debug_inspect(
rng2,
content=(
#|{ seed: 1716623506685013753, gamma: 14663218685290508263 }
),
)

// Clone existing state
let rng3 = rng2.clone()
inspect(rng3.to_string().length() > 0, content="true")
debug_inspect(
rng3,
content=(
#|{ seed: 1716623506685013753, gamma: 14663218685290508263 }
),
)
}
```

Expand All @@ -34,23 +49,43 @@ test "random number generation" {

// Generate random integers
let int_val = rng.next_int()
inspect(int_val.to_string().length() > 0, content="true")
debug_inspect(
int_val,
content=(
#|-1716621765
),
)

// Generate positive integers only
let pos_int = rng.next_positive_int()
inspect(pos_int > 0, content="true")

// Generate UInt values
let uint_val = rng.next_uint()
inspect(uint_val.to_string().length() > 0, content="true")
debug_inspect(
uint_val,
content=(
#|40636561
),
)

// Generate Int64 values
let int64_val = rng.next_int64()
inspect(int64_val.to_string().length() > 0, content="true")
debug_inspect(
int64_val,
content=(
#|640680877524568329
),
)

// Generate UInt64 values
let uint64_val = rng.next_uint64()
inspect(uint64_val.to_string().length() > 0, content="true")
debug_inspect(
uint64_val,
content=(
#|11629490981681548516
),
)
}
```

Expand Down Expand Up @@ -117,17 +152,37 @@ test "advanced operations" {

// Generate two UInt values at once
let (uint1, uint2) = rng.next_two_uint()
inspect(uint1.to_string().length() > 0, content="true")
inspect(uint2.to_string().length() > 0, content="true")
debug_inspect(
uint1,
content=(
#|3306273023
),
)
debug_inspect(
uint2,
content=(
#|472035372
),
)

// Split the generator (for parallel use)
let split_rng = rng.split()

// Both generators should work independently
let original_val = rng.next_int()
let split_val = split_rng.next_int()
inspect(original_val.to_string().length() > 0, content="true")
inspect(split_val.to_string().length() > 0, content="true")
debug_inspect(
original_val,
content=(
#|2115132817
),
)
debug_inspect(
split_val,
content=(
#|400628363
),
)
}
```

Expand All @@ -145,7 +200,12 @@ test "state management" {

// Generate value after advancing
let after_advance = rng.next_int()
inspect(after_advance.to_string().length() > 0, content="true")
debug_inspect(
after_advance,
content=(
#|817660368
),
)

// Create independent copy
let independent = rng.clone()
Expand Down
10 changes: 0 additions & 10 deletions quickcheck/splitmix/extends.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// --- promoted: kept as regular methods ---

///|
pub extend RandomState with Show::{to_string}

// --- deprecated: hidden from the generated interface ---

///|
Expand All @@ -28,8 +23,3 @@ pub extend RandomState with @debug.Debug::{to_repr}
#deprecated("Use `Default::default` instead", skip_current_package=true)
#doc(hidden)
pub extend RandomState with Default::{default}

///|
#deprecated("Use `Show::output` via the trait or `to_string` instead", skip_current_package=true)
#doc(hidden)
pub extend RandomState with Show::{output}
3 changes: 1 addition & 2 deletions quickcheck/splitmix/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn new(seed? : UInt64) -> RandomState
// Errors

// Types and methods
type RandomState derive(Show, @debug.Debug)
type RandomState derive(@debug.Debug)
pub fn RandomState::clone(Self) -> Self
#deprecated
pub fn RandomState::new(seed? : UInt64) -> Self
Expand All @@ -25,7 +25,6 @@ pub fn RandomState::next_two_uint(Self) -> (UInt, UInt)
pub fn RandomState::next_uint(Self, limit? : UInt) -> UInt
pub fn RandomState::next_uint64(Self, limit? : UInt64) -> UInt64
pub fn RandomState::split(Self) -> Self
pub fn RandomState::to_string(Self) -> String
pub impl Default for RandomState

// Type aliases
Expand Down
5 changes: 1 addition & 4 deletions quickcheck/splitmix/random.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
// limitations under the License.

///|
// TODO(future): `derive(Show)` is deprecated syntax — switch to `derive(Debug)`
// or a manual `Show` implementation, then remove this annotation.
#warnings("-deprecated_syntax")
struct RandomState {
mut seed : UInt64
gamma : UInt64
} derive(Show, @debug.Debug)
} derive(@debug.Debug)

///|
let golden_gamma : UInt64 = 0x9e3779b97f4a7c15
Expand Down
Loading