@@ -34,17 +34,17 @@ tape( 'main export is a function', function test( t ) {
34
34
} ) ;
35
35
36
36
tape ( 'attached to the main export is a method to generate pseudorandom number generators' , function test ( t ) {
37
- t . equal ( typeof f . factory , 'function' , 'has `factory` method' ) ;
37
+ t . equal ( typeof f . factory , 'function' , 'has method' ) ;
38
38
t . end ( ) ;
39
39
} ) ;
40
40
41
41
tape ( 'attached to the main export is the generator name' , function test ( t ) {
42
- t . equal ( f . NAME , 'f' , 'has `NAME` property' ) ;
42
+ t . equal ( f . NAME , 'f' , 'has property' ) ;
43
43
t . end ( ) ;
44
44
} ) ;
45
45
46
46
tape ( 'attached to the main export is the underlying PRNG' , function test ( t ) {
47
- t . equal ( typeof f . PRNG , 'function' , 'has `PRNG` property' ) ;
47
+ t . equal ( typeof f . PRNG , 'function' , 'has property' ) ;
48
48
t . end ( ) ;
49
49
} ) ;
50
50
@@ -53,6 +53,26 @@ tape( 'attached to the main export is the generator seed', function test( t ) {
53
53
t . end ( ) ;
54
54
} ) ;
55
55
56
+ tape ( 'attached to the main export is the generator seed length' , function test ( t ) {
57
+ t . equal ( typeof f . seedLength , 'number' , 'has property' ) ;
58
+ t . end ( ) ;
59
+ } ) ;
60
+
61
+ tape ( 'attached to the main export is the generator state' , function test ( t ) {
62
+ t . equal ( isUint32Array ( f . state ) , true , 'has property' ) ;
63
+ t . end ( ) ;
64
+ } ) ;
65
+
66
+ tape ( 'attached to the main export is the generator state length' , function test ( t ) {
67
+ t . equal ( typeof f . stateLength , 'number' , 'has property' ) ;
68
+ t . end ( ) ;
69
+ } ) ;
70
+
71
+ tape ( 'attached to the main export is the generator state size' , function test ( t ) {
72
+ t . equal ( typeof f . byteLength , 'number' , 'has property' ) ;
73
+ t . end ( ) ;
74
+ } ) ;
75
+
56
76
tape ( 'the function returns pseudorandom numbers' , function test ( t ) {
57
77
var r ;
58
78
var i ;
@@ -63,3 +83,30 @@ tape( 'the function returns pseudorandom numbers', function test( t ) {
63
83
}
64
84
t . end ( ) ;
65
85
} ) ;
86
+
87
+ tape ( 'the function supports setting the generator state' , function test ( t ) {
88
+ var state ;
89
+ var arr ;
90
+ var i ;
91
+
92
+ // Move to a future state...
93
+ for ( i = 0 ; i < 100 ; i ++ ) {
94
+ f ( 2.0 , 4.0 ) ;
95
+ }
96
+ // Capture the current state:
97
+ state = f . state ;
98
+
99
+ // Move to a future state...
100
+ arr = [ ] ;
101
+ for ( i = 0 ; i < 100 ; i ++ ) {
102
+ arr . push ( f ( 2.0 , 4.0 ) ) ;
103
+ }
104
+ // Set the state:
105
+ f . state = state ;
106
+
107
+ // Replay previously generated values...
108
+ for ( i = 0 ; i < 100 ; i ++ ) {
109
+ t . equal ( f ( 2.0 , 4.0 ) , arr [ i ] , 'returns expected value. i: ' + i + '.' ) ;
110
+ }
111
+ t . end ( ) ;
112
+ } ) ;
0 commit comments