diff --git a/test/arrays.tm b/test/arrays.tm index 25d4558..7f1882a 100644 --- a/test/arrays.tm +++ b/test/arrays.tm @@ -105,7 +105,7 @@ func main(): >> ["A", "B", "C"]:sample(10, [1.0, 0.5, 0.0]) do: - >> heap := [Int.random(1, 50) for _ in 10] + >> heap := [random:int(1, 50) for _ in 10] >> heap:heapify() >> heap sorted := [:Int] @@ -114,7 +114,7 @@ func main(): >> sorted == sorted:sorted() = yes for _ in 10: - heap:heap_push(Int.random(1, 50)) + heap:heap_push(random:int(1, 50)) >> heap sorted = [:Int] while heap.length > 0: @@ -172,29 +172,3 @@ func main(): = !Int >> [4, 5, 6]:first(func(i:&Int): i:is_prime()) = 2? - - test_seeded_rng() - -# Inspired by: https://nullprogram.com/blog/2017/09/21/ -struct RNGxoroshiro128(s0=Int64.random(),s1=Int64.random()): - func int_fn(rng:@RNGxoroshiro128 -> func(->Int64)): - return func(-> Int64): - s0 := rng.s0 - s1 := rng.s1 - result := s0:wrapping_plus(s1) - s1 xor= s0 - rng.s0 = (s0 <<< 55) or (s0 >>> 9) xor s1 xor (s1 <<< 14) - rng.s1 = (s1 <<< 36) or (s1 >>> 28) - return result - -func test_seeded_rng(): - !! Seeded RNG: - rng_state := RNGxoroshiro128(Int64.random(), Int64.random()) - rng1 := @rng_state:int_fn() - rng2 := @rng_state:int_fn() - - nums := [i*10 for i in 20] - >> nums:random(rng1) == nums:random(rng2) - = yes - >> nums:shuffled(rng1) == nums:shuffled(rng2) - = yes diff --git a/test/integers.tm b/test/integers.tm index 9b5b6b4..ad9c40d 100644 --- a/test/integers.tm +++ b/test/integers.tm @@ -50,7 +50,6 @@ func main(): >> x:octal() = "0o173" - >> Int.random(1, 100) >> Int64.min = -9223372036854775808[64] >> Int64.max @@ -87,8 +86,8 @@ func main(): do: for in 20: - >> n := Int.random(-999999, 999999) - >> d := Int.random(-999, 999) + >> n := random:int(-999999, 999999) + >> d := random:int(-999, 999) !! n=$n, d=$d: >> (n/d)*d + (n mod d) == n = yes diff --git a/test/nums.tm b/test/nums.tm index 3d6b05d..32c55f3 100644 --- a/test/nums.tm +++ b/test/nums.tm @@ -17,8 +17,6 @@ func main(): >> Num.PI:format(precision=10) = "3.1415926536" - >> Num.random() - >> Num.INF = inf >> Num.INF:isinf()