@@ -27,7 +27,7 @@ enum Op {
27
27
/// - `rng`: a random number generator
28
28
/// - `times`: the number of operations to be generated
29
29
/// - `max_lvl`: the maximum level of the tree
30
- fn random_test_gen (rng : @random . Rand , times : Int , max_lvl : Int ) -> Array [Op ] {
30
+ fn random_test_gen (rng : Random , times : Int , max_lvl : Int ) -> Array [Op ] {
31
31
// Hyperparameters
32
32
let op_count = 3
33
33
let max_len = branching_factor_power (max_lvl )
@@ -93,7 +93,7 @@ fn execute_array_test(rs : Array[Op]) -> Unit! {
93
93
for i = 0 ; i < len ; i = i + 1 {
94
94
a .push (v [i ])
95
95
}
96
- t = t .concat (from_iter ( v . iter () ))
96
+ t = t .concat (from_array ( v ))
97
97
check_array_eq! (a , t )
98
98
}
99
99
Set (idx , v ) => {
@@ -159,6 +159,19 @@ fn check_fixedarray_eq(a : FixedArray[Int], t : T[Int]) -> Unit! {
159
159
///|
160
160
/// Generate a random array of length `n`.
161
161
fn random_array (n : Int ) -> Array [Int ] {
162
- let rng = @random . new ( seed = b "DEADBEEFLIVEBEEFDEADBEEFDEADBEEF" )
162
+ let rng = Random ({ val : 0 } )
163
163
Array ::makei (n , fn (i ) { rng .int (limit = i ) })
164
164
}
165
+
166
+ ///|
167
+ type Random Ref [UInt64 ]
168
+
169
+ ///|
170
+ fn int (self : Random , limit ~ : Int ) -> Int {
171
+ let limit = if limit == 0 { 1L << 32 } else { limit .to_int64 () }
172
+ let a = 1UL << 48
173
+ let c = 11UL
174
+ let m = 25214903917UL
175
+ self ._.val = (a * self ._.val + c ) % m
176
+ (self ._.val.reinterpret_as_int64 () % limit ).to_int ()
177
+ }
0 commit comments