/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var tape = require( 'tape' );
var isUint32Array = require( '@stdlib/assert/is-uint32array' );
var beta = require( './../lib' );


// TESTS //

tape( 'main export is a function', function test( t ) {
	t.ok( true, __filename );
	t.equal( typeof beta, 'function', 'main export is a function' );
	t.end();
});

tape( 'attached to the main export is a method to generate pseudorandom number generators', function test( t ) {
	t.equal( typeof beta.factory, 'function', 'has `factory` method' );
	t.end();
});

tape( 'attached to the main export is the generator name', function test( t ) {
	t.equal( beta.NAME, 'beta', 'has `NAME` property' );
	t.end();
});

tape( 'attached to the main export is the underlying PRNG', function test( t ) {
	t.equal( typeof beta.PRNG, 'function', 'has `PRNG` property' );
	t.end();
});

tape( 'attached to the main export is the generator seed', function test( t ) {
	t.equal( isUint32Array( beta.seed ), true, 'has `seed` property' );
	t.end();
});

tape( 'attached to the main export is the generator state', function test( t ) {
	t.equal( isUint32Array( beta.state ), true, 'has `state` property' );
	t.end();
});

tape( 'attached to the main export is the generator state length', function test( t ) {
	t.equal( typeof beta.stateLength, 'number', 'has `stateLength` property' );
	t.end();
});

tape( 'attached to the main export is the generator state size', function test( t ) {
	t.equal( typeof beta.byteLength, 'number', 'has `byteLength` property' );
	t.end();
});

tape( 'the function returns pseudorandom numbers', function test( t ) {
	var r;
	var i;
	for ( i = 0; i < 1e2; i++ ) {
		r = beta( 2.0, 1.0 );
		t.strictEqual( typeof r, 'number', 'returns a number' );
		t.strictEqual( r >= 0.0, true, 'returns a nonnegative number' );
	}
	t.end();
});

tape( 'the function supports setting the generator state (alpha = beta > 1.5)', function test( t ) {
	var state;
	var arr;
	var i;

	// Move to a future state...
	for ( i = 0; i < 100; i++ ) {
		beta( 2.0, 2.0 );
	}
	// Capture the current state:
	state = beta.state;

	// Move to a future state...
	arr = [];
	for ( i = 0; i < 100; i++ ) {
		arr.push( beta( 2.0, 2.0 ) );
	}
	// Set the state:
	beta.state = state;

	// Replay previously generated values...
	for ( i = 0; i < 100; i++ ) {
		t.equal( beta( 2.0, 2.0 ), arr[ i ], 'returns expected value. i: '+i+'.' );
	}
	t.end();
});

tape( 'the function supports setting the generator state (alpha != beta > 1.0)', function test( t ) {
	var state;
	var arr;
	var i;

	// Move to a future state...
	for ( i = 0; i < 100; i++ ) {
		beta( 2.0, 5.0 );
	}
	// Capture the current state:
	state = beta.state;

	// Move to a future state...
	arr = [];
	for ( i = 0; i < 100; i++ ) {
		arr.push( beta( 2.0, 5.0 ) );
	}
	// Set the state:
	beta.state = state;

	// Replay previously generated values...
	for ( i = 0; i < 100; i++ ) {
		t.equal( beta( 2.0, 5.0 ), arr[ i ], 'returns expected value. i: '+i+'.' );
	}
	t.end();
});

tape( 'the function supports setting the generator state (alpha,beta <= 1.0)', function test( t ) {
	var state;
	var arr;
	var i;

	// Move to a future state...
	for ( i = 0; i < 100; i++ ) {
		beta( 0.5, 1.0 );
	}
	// Capture the current state:
	state = beta.state;

	// Move to a future state...
	arr = [];
	for ( i = 0; i < 100; i++ ) {
		arr.push( beta( 0.5, 1.0 ) );
	}
	// Set the state:
	beta.state = state;

	// Replay previously generated values...
	for ( i = 0; i < 100; i++ ) {
		t.equal( beta( 0.5, 1.0 ), arr[ i ], 'returns expected value. i: '+i+'.' );
	}
	t.end();
});

@@ -1112,18 +1112,8 @@
 'has
- %60factory%60
  met
@@ -1116,24 +1116,24 @@
  method' );%0A
+
 %09t.end();%0A%7D)
@@ -1252,15 +1252,8 @@
 'has
- %60NAME%60
  pro
@@ -1406,15 +1406,8 @@
 'has
- %60PRNG%60
  pro
@@ -1564,14 +1564,171 @@
 has 
-%60seed%60
+property' );%0A%09t.end();%0A%7D);%0A%0Atape( 'attached to the main export is the generator seed length', function test( t ) %7B%0A%09t.equal( typeof beta.seedLength, 'number', 'has
  pro
@@ -1886,16 +1886,8 @@
 'has
- %60state%60
  pro
@@ -2052,22 +2052,8 @@
 'has
- %60stateLength%60
  pro
@@ -2155,32 +2155,32 @@
 ion test( t ) %7B%0A
+
 %09t.equal( typeof
@@ -2215,21 +2215,8 @@
 'has
- %60byteLength%60
  pro

Update tests