|
1 | 1 | /**
|
2 | 2 | * @license Apache-2.0
|
3 | 3 | *
|
4 |
| -* Copyright (c) 2018 The Stdlib Authors. |
| 4 | +* Copyright (c) 2023 The Stdlib Authors. |
5 | 5 | *
|
6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License");
|
7 | 7 | * you may not use this file except in compliance with the License.
|
|
21 | 21 | // MODULES //
|
22 | 22 |
|
23 | 23 | var tape = require( 'tape' );
|
24 |
| -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); |
25 |
| -var triangular = require( './../../dist' ); |
| 24 | +var main = require( './../../dist' ); |
26 | 25 |
|
27 | 26 |
|
28 | 27 | // TESTS //
|
29 | 28 |
|
30 |
| -tape( 'main export is a function', function test( t ) { |
| 29 | +tape( 'main export is defined', function test( t ) { |
31 | 30 | t.ok( true, __filename );
|
32 |
| - t.strictEqual( typeof triangular, 'function', 'main export is a function' ); |
33 |
| - t.end(); |
34 |
| -}); |
35 |
| - |
36 |
| -tape( 'attached to the main export is a method to generate pseudorandom number generators', function test( t ) { |
37 |
| - t.equal( typeof triangular.factory, 'function', 'has method' ); |
38 |
| - t.end(); |
39 |
| -}); |
40 |
| - |
41 |
| -tape( 'attached to the main export is a method to serialize a pseudorandom number generator as JSON', function test( t ) { |
42 |
| - t.equal( typeof triangular.toJSON, 'function', 'has method' ); |
43 |
| - t.end(); |
44 |
| -}); |
45 |
| - |
46 |
| -tape( 'attached to the main export is the generator name', function test( t ) { |
47 |
| - t.equal( triangular.NAME, 'triangular', 'has property' ); |
48 |
| - t.end(); |
49 |
| -}); |
50 |
| - |
51 |
| -tape( 'attached to the main export is the underlying PRNG', function test( t ) { |
52 |
| - t.equal( typeof triangular.PRNG, 'function', 'has property' ); |
53 |
| - t.end(); |
54 |
| -}); |
55 |
| - |
56 |
| -tape( 'attached to the main export is the generator seed', function test( t ) { |
57 |
| - t.equal( isUint32Array( triangular.seed ), true, 'has property' ); |
58 |
| - t.end(); |
59 |
| -}); |
60 |
| - |
61 |
| -tape( 'attached to the main export is the generator seed length', function test( t ) { |
62 |
| - t.equal( typeof triangular.seedLength, 'number', 'has property' ); |
63 |
| - t.end(); |
64 |
| -}); |
65 |
| - |
66 |
| -tape( 'attached to the main export is the generator state', function test( t ) { |
67 |
| - t.equal( isUint32Array( triangular.state ), true, 'has property' ); |
68 |
| - t.end(); |
69 |
| -}); |
70 |
| - |
71 |
| -tape( 'attached to the main export is the generator state length', function test( t ) { |
72 |
| - t.equal( typeof triangular.stateLength, 'number', 'has property' ); |
73 |
| - t.end(); |
74 |
| -}); |
75 |
| - |
76 |
| -tape( 'attached to the main export is the generator state size', function test( t ) { |
77 |
| - t.equal( typeof triangular.byteLength, 'number', 'has property' ); |
78 |
| - t.end(); |
79 |
| -}); |
80 |
| - |
81 |
| -tape( 'the function returns pseudorandom numbers', function test( t ) { |
82 |
| - var r; |
83 |
| - var a; |
84 |
| - var b; |
85 |
| - var c; |
86 |
| - var i; |
87 |
| - |
88 |
| - a = 200.0; |
89 |
| - b = 499.974; |
90 |
| - c = 211.33; |
91 |
| - for ( i = 0; i < 1e2; i++ ) { |
92 |
| - r = triangular( a, b, c ); |
93 |
| - t.equal( typeof r, 'number', 'returns a number' ); |
94 |
| - t.equal( r >= a && r <= b, true, 'within support: '+r ); |
95 |
| - } |
96 |
| - t.end(); |
97 |
| -}); |
98 |
| - |
99 |
| -tape( 'the function supports setting the generator state', function test( t ) { |
100 |
| - var state; |
101 |
| - var arr; |
102 |
| - var i; |
103 |
| - |
104 |
| - // Move to a future state... |
105 |
| - for ( i = 0; i < 100; i++ ) { |
106 |
| - triangular( 0.0, 1.0, 0.5 ); |
107 |
| - } |
108 |
| - // Capture the current state: |
109 |
| - state = triangular.state; |
110 |
| - |
111 |
| - // Move to a future state... |
112 |
| - arr = []; |
113 |
| - for ( i = 0; i < 100; i++ ) { |
114 |
| - arr.push( triangular( 0.0, 1.0, 0.5 ) ); |
115 |
| - } |
116 |
| - // Set the state: |
117 |
| - triangular.state = state; |
118 |
| - |
119 |
| - // Replay previously generated values... |
120 |
| - for ( i = 0; i < 100; i++ ) { |
121 |
| - t.equal( triangular( 0.0, 1.0, 0.5 ), arr[ i ], 'returns expected value. i: '+i+'.' ); |
122 |
| - } |
| 31 | + t.strictEqual( main !== void 0, true, 'main export is defined' ); |
123 | 32 | t.end();
|
124 | 33 | });
|
0 commit comments