'use strict';

// MODULES //

var tape = require( 'tape' );
var kstest = require( '@stdlib/math/generics/statistics/kstest' );
var weibull = require( './../lib' );


// TESTS //

tape( 'main export is a function', function test( t ) {
	t.ok( true, __filename );
	t.equal( typeof weibull, '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 weibull.factory, 'function', 'has `factory` method' );
	t.end();
});

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

tape( 'attached to the main export is the generator seed', function test( t ) {
	t.equal( typeof weibull.SEED, 'number', 'has `SEED` property' );
	t.end();
});

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

// FIXME //

/*
tape( 'the function returns pseudorandom numbers from the specified beta distribution', function test( t ) {
	var rejected;
	var pValue;
	var i;
	var j;
	var x;

	rejected = 0;
	for ( i = 0; i < 300; i++ ) {
		x = new Array( 1e3 );
		for ( j = 0; j < x.length; j++ ) {
			x[ j ] = weibull( 2.0, 4.0 );
		}
		// Test using Kolmogorov-Smirnov goodness-of-fit test:
		pValue = kstest( x, 'beta', 2.0, 4.0 ).pValue;
		t.equal( typeof pValue, 'number', 'returns a p-value' );
		if ( pValue <= 0.05 ) {
			rejected += 1;
		}
	}
	// Use 0.07 instead of 0.05 as cut-off to accomodate randomly failing tests due to small sample sizes and few iterations...
	t.ok( rejected / 300 < 0.07, 'null hypothesis (i.e. that numbers are drawn from Beta(2,4)) is rejected in less than 7% of cases' );
	t.end();
});
*/

'use strict';

// MODULES //

var tape = require( 'tape' );
var kstest = require( '@stdlib/math/generics/statistics/kstest' );
var weibull = require( './../lib' );


// TESTS //

tape( 'main export is a function', function test( t ) {
	t.ok( true, __filename );
	t.equal( typeof weibull, '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 weibull.factory, 'function', 'has `factory` method' );
	t.end();
});

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

tape( 'attached to the main export is the generator seed', function test( t ) {
	t.equal( typeof weibull.SEED, 'number', 'has `SEED` property' );
	t.end();
});

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

// FIXME //

/*
tape( 'the function returns pseudorandom numbers from the specified Weibull distribution', function test( t ) {
	var rejected;
	var pValue;
	var i;
	var j;
	var x;

	rejected = 0;
	for ( i = 0; i < 300; i++ ) {
		x = new Array( 1e3 );
		for ( j = 0; j < x.length; j++ ) {
			x[ j ] = weibull( 2.0, 4.0 );
		}
		// Test using Kolmogorov-Smirnov goodness-of-fit test:
		pValue = kstest( x, 'weibull', 2.0, 4.0 ).pValue;
		t.equal( typeof pValue, 'number', 'returns a p-value' );
		if ( pValue <= 0.05 ) {
			rejected += 1;
		}
	}
	// Use 0.07 instead of 0.05 as cut-off to accomodate randomly failing tests due to small sample sizes and few iterations...
	t.ok( rejected / 300 < 0.07, 'null hypothesis (i.e. that numbers are drawn from Weibull(2,4)) is rejected in less than 7% of cases' );
	t.end();
});
*/

Fix copy-paste error