@@ -2,71 +2,76 @@ import test from 'ava';
22
33import { get64 } from '@arithmetic-type/uint64' ;
44
5- import { splitmix64 , xoroshiro128plus , fill , nextUint64 } from '../../src/index.js' ;
5+ import {
6+ splitmix64 ,
7+ xoroshiro128plus ,
8+ fill ,
9+ nextUint64 ,
10+ } from '../../src/index.js' ;
611
712test ( 'Example found at https://github.com/dgryski/go-xoroshiro/blob/ea5ca0291510c1f8b16321d610ae73e1006d499f/xoro_test.go#L28' , ( t ) => {
813 const prng = xoroshiro128plus ( [ 0 , 1 , 0 , 2 ] , { a : 55 , b : 14 , c : 36 } ) ;
914
10- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x00000000 , 0x00000003 ) ) ; // 3
11- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x00800030 , 0x0000c003 ) ) ; // 36029003177443331
12- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x01184060 , 0x38000363 ) ) ; // 78883775479546723
13- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xa080fe50 , 0x30c4c366 ) ) ; // 11565523463456473958
14- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x3ae0e84f , 0x181c8404 ) ) ; // 4242646275387589636
15- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x03902839 , 0x17940944 ) ) ; // 256749404433942852
16- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x98dcc1f0 , 0x6360888c ) ) ; // 11014892026844973196
17- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x7db94a02 , 0x5d95c80f ) ) ; // 9059353499452950543
18- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x77508804 , 0x6d70b290 ) ) ; // 8597521241247625872
19- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x412422d9 , 0x4084790d ) ) ; // 4693915028112570637
15+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x00_00_00_00 , 0x00_00_00_03 ) ) ; // 3
16+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x00_80_00_30 , 0x00_00_c0_03 ) ) ; // 36029003177443331
17+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x01_18_40_60 , 0x38_00_03_63 ) ) ; // 78883775479546723
18+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xa0_80_fe_50 , 0x30_c4_c3_66 ) ) ; // 11565523463456473958
19+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x3a_e0_e8_4f , 0x18_1c_84_04 ) ) ; // 4242646275387589636
20+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x03_90_28_39 , 0x17_94_09_44 ) ) ; // 256749404433942852
21+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x98_dc_c1_f0 , 0x63_60_88_8c ) ) ; // 11014892026844973196
22+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x7d_b9_4a_02 , 0x5d_95_c8_0f ) ) ; // 9059353499452950543
23+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x77_50_88_04 , 0x6d_70_b2_90 ) ) ; // 8597521241247625872
24+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x41_24_22_d9 , 0x40_84_79_0d ) ) ; // 4693915028112570637
2025} ) ;
2126
2227test ( 'Example found at https://github.com/dgryski/go-xoroshiro/blob/ea5ca0291510c1f8b16321d610ae73e1006d499f/xoro_test.go#L47' , ( t ) => {
2328 const prng = xoroshiro128plus (
24- [ 0x0916df85 , 0x1e2aee44 , 0x9ade0f09 , 0xffca1bc4 ] ,
29+ [ 0x09_16_df_85 , 0x1e_2a_ee_44 , 0x9a_de_0f_09 , 0xff_ca_1b_c4 ] ,
2530 {
2631 a : 55 ,
2732 b : 14 ,
2833 c : 36 ,
29- JUMP : [ 0xeba5facb , 0xbeac0467 , 0x86aa9922 , 0xd86b048b ] ,
34+ JUMP : [ 0xeb_a5_fa_cb , 0xbe_ac_04_67 , 0x86_aa_99_22 , 0xd8_6b_04_8b ] ,
3035 } ,
3136 ) ;
3237
3338 prng . jump ( ) ;
34- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x658bac67 , 0x42f1cb34 ) ) ; // 7317131579098254132
39+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x65_8b_ac_67 , 0x42_f1_cb_34 ) ) ; // 7317131579098254132
3540 prng . jump ( ) ;
36- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x7ea22887 , 0x3c5d2ad5 ) ) ; // 9124900356304480981
41+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x7e_a2_28_87 , 0x3c_5d_2a_d5 ) ) ; // 9124900356304480981
3742 prng . jump ( ) ;
38- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xe794ec98 , 0xaebcd8bc ) ) ; // 16687222659825326268
43+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xe7_94_ec_98 , 0xae_bc_d8_bc ) ) ; // 16687222659825326268
3944 prng . jump ( ) ;
40- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x93e0f50d , 0x5d924d3a ) ) ; // 10655786156111842618
45+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x93_e0_f5_0d , 0x5d_92_4d_3a ) ) ; // 10655786156111842618
4146 prng . jump ( ) ;
42- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x0555abbe , 0x490eb380 ) ) ; // 384402176967881600
47+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x05_55_ab_be , 0x49_0e_b3_80 ) ) ; // 384402176967881600
4348 prng . jump ( ) ;
44- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x1e2935c4 , 0x3d1ceffa ) ) ; // 2173327412138143738
49+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x1e_29_35_c4 , 0x3d_1c_ef_fa ) ) ; // 2173327412138143738
4550 prng . jump ( ) ;
46- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xc94b9bd3 , 0x583ae4dd ) ) ; // 14504858356897473757
51+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xc9_4b_9b_d3 , 0x58_3a_e4_dd ) ) ; // 14504858356897473757
4752 prng . jump ( ) ;
48- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x426bc5ee , 0x5b3a4f93 ) ) ; // 4786136656534720403
53+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x42_6b_c5_ee , 0x5b_3a_4f_93 ) ) ; // 4786136656534720403
4954 prng . jump ( ) ;
50- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x2ac1f1af , 0xddd342bf ) ) ; // 3081009357741310655
55+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x2a_c1_f1_af , 0xdd_d3_42_bf ) ) ; // 3081009357741310655
5156 prng . jump ( ) ;
52- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x3884d3ed , 0xd6ffd586 ) ) ; // 4072612981517571462
57+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x38_84_d3_ed , 0xd6_ff_d5_86 ) ) ; // 4072612981517571462
5358} ) ;
5459
5560test ( 'Example found at https://github.com/dgryski/go-xoroshiro/blob/ea5ca0291510c1f8b16321d610ae73e1006d499f/xoro_test.go#L80' , ( t ) => {
56- const seeder = splitmix64 ( [ 0x0ddc0ffe , 0xebadf00d ] ) ;
61+ const seeder = splitmix64 ( [ 0x0d_dc_0f_fe , 0xeb_ad_f0_0d ] ) ;
5762 const seed = new Int32Array ( 4 ) ;
5863 fill ( seeder , seed ) ;
5964
6065 const prng = xoroshiro128plus ( seed , { a : 55 , b : 14 , c : 36 } ) ;
6166
62- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xa3f4ee8f , 0x1df50a08 ) ) ; // 11814330020949985800
63- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xa3febba4 , 0x5a9ce9c5 ) ) ; // 11817088786836023749
64- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x16f4c81d , 0x130768eb ) ) ; // 1654166990350674155
65- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xc3da8db5 , 0x1d9cc8ea ) ) ; // 14112748191344281834
66- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x3b8315d6 , 0xf1f63305 ) ) ; // 4288295283113472773
67- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x747636fe , 0x553bb5ca ) ) ; // 8391955421631067594
68- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x0255d516 , 0xf81d9239 ) ) ; // 168274855724945977
69- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x27114eb0 , 0xcdd2961f ) ) ; // 2815117763357611551
70- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xa92195f5 , 0x93148843 ) ) ; // 12187186948608395331
71- t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x9381f38a , 0x6d63d35c ) ) ; // 10629044371437376348
67+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xa3_f4_ee_8f , 0x1d_f5_0a_08 ) ) ; // 11814330020949985800
68+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xa3_fe_bb_a4 , 0x5a_9c_e9_c5 ) ) ; // 11817088786836023749
69+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x16_f4_c8_1d , 0x13_07_68_eb ) ) ; // 1654166990350674155
70+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xc3_da_8d_b5 , 0x1d_9c_c8_ea ) ) ; // 14112748191344281834
71+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x3b_83_15_d6 , 0xf1_f6_33_05 ) ) ; // 4288295283113472773
72+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x74_76_36_fe , 0x55_3b_b5_ca ) ) ; // 8391955421631067594
73+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x02_55_d5_16 , 0xf8_1d_92_39 ) ) ; // 168274855724945977
74+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x27_11_4e_b0 , 0xcd_d2_96_1f ) ) ; // 2815117763357611551
75+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0xa9_21_95_f5 , 0x93_14_88_43 ) ) ; // 12187186948608395331
76+ t . deepEqual ( nextUint64 ( prng ) , get64 ( 0x93_81_f3_8a , 0x6d_63_d3_5c ) ) ; // 10629044371437376348
7277} ) ;
0 commit comments