Skip to content

Commit 5e7f1c1

Browse files
committed
Update tests
1 parent fde9dde commit 5e7f1c1

File tree

1 file changed

+50
-3
lines changed
  • lib/node_modules/@stdlib/random/base/f/test

1 file changed

+50
-3
lines changed

lib/node_modules/@stdlib/random/base/f/test/test.js

+50-3
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ tape( 'main export is a function', function test( t ) {
3434
});
3535

3636
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' );
3838
t.end();
3939
});
4040

4141
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' );
4343
t.end();
4444
});
4545

4646
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' );
4848
t.end();
4949
});
5050

@@ -53,6 +53,26 @@ tape( 'attached to the main export is the generator seed', function test( t ) {
5353
t.end();
5454
});
5555

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+
5676
tape( 'the function returns pseudorandom numbers', function test( t ) {
5777
var r;
5878
var i;
@@ -63,3 +83,30 @@ tape( 'the function returns pseudorandom numbers', function test( t ) {
6383
}
6484
t.end();
6585
});
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

Comments
 (0)