text: /**
  * @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 isnan = require( '@stdlib/math/base/assert/is-nan' );
  var abs = require( '@stdlib/math/base/special/abs' );
  var PINF = require( '@stdlib/constants/math/float64-pinf' );
  var NINF = require( '@stdlib/constants/math/float64-ninf' );
  var EPS = require( '@stdlib/constants/math/float64-eps' );
  var factory = require( './../lib/factory.js' );
  
  
  // FIXTURES //
  
  var largeRate = require( './fixtures/julia/large_rate.json' );
  var largeShape = require( './fixtures/julia/large_shape.json' );
  var bothLarge = require( './fixtures/julia/both_large.json' );
  
  
  // TESTS //
  
  tape( 'main export is a function', function test( t ) {
  	t.ok( true, __filename );
  	t.equal( typeof factory, 'function', 'main export is a function' );
  	t.end();
  });
  
  tape( 'the function returns a function', function test( t ) {
  	var quantile = factory( 0.0, 1.0 );
  	t.equal( typeof quantile, 'function', 'returns a function' );
  	t.end();
  });
  
  tape( 'if provided `NaN` for any parameter, the created function returns `NaN`', function test( t ) {
  	var quantile;
  	var y;
  
  	quantile = factory( 0.0, 1.0 );
  	y = quantile( NaN );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( NaN, 1.0 );
  	y = quantile( 0.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( 1.0, NaN );
  	y = quantile( 0.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( NaN, NaN );
  	y = quantile( 0.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( NaN, NaN );
  	y = quantile( NaN );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	t.end();
  });
  
  tape( 'if provided a finite `alpha` and `beta`, the function returns a function which returns `NaN` when provided a number outside `[0,1]` for `p`', function test( t ) {
  	var quantile;
  	var y;
  
  	quantile = factory( 1.0, 1.0 );
  	y = quantile( -0.1 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	y = quantile( 1.1 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	t.end();
  });
  
  tape( 'if provided a nonpositive `beta`, the created function always returns `NaN`', function test( t ) {
  	var quantile;
  	var y;
  
  	quantile = factory( 2.0, 0.0 );
  
  	y = quantile( 2.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	y = quantile( 0.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( 2.0, -1.0 );
  
  	y = quantile( 2.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	y = quantile( 0.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( 2.0, NINF );
  	y = quantile( 2.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( PINF, NINF );
  	y = quantile( 2.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( NINF, NINF );
  	y = quantile( 2.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( NaN, NINF );
  	y = quantile( 2.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	t.end();
  });
  
  tape( 'if provided a negative `alpha`, the created function always returns `NaN`', function test( t ) {
  	var quantile;
  	var y;
  
  	quantile = factory( -1.0, 0.5 );
  
  	y = quantile( 2.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	y = quantile( 0.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( NINF, 1.0 );
  	y = quantile( 2.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( NINF, PINF );
  	y = quantile( 2.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( NINF, NINF );
  	y = quantile( 2.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	quantile = factory( NINF, NaN );
  	y = quantile( 2.0 );
  	t.equal( isnan( y ), true, 'returns NaN' );
  
  	t.end();
  });
  
  tape( 'if `alpha` equals `0`, the created function evaluates a degenerate distribution centered at `0`', function test( t ) {
  	var quantile;
  	var y;
  
  	quantile = factory( 0.0, 2.0 );
  
  	y = quantile( 0.3 );
  	t.equal( y, 0.0, 'returns 0 for p inside [0,1]' );
  
  	y = quantile( 0.9 );
  	t.equal( y, 0.0, 'returns 0 for p inside [0,1]' );
  
  	y = quantile( 1.1 );
  	t.equal( isnan( y ), true, 'returns NaN for p outside [0,1]' );
  
  	y = quantile( -0.1 );
  	t.equal( isnan( y ), true, 'returns NaN for p outside [0,1]' );
  
  	t.end();
  });
  
  tape( 'the created function evaluates the quantile for `p` given large `alpha` and `beta`', function test( t ) {
  	var expected;
  	var quantile;
  	var alpha;
  	var delta;
  	var beta;
  	var tol;
  	var p;
  	var y;
  	var i;
  
  	expected = bothLarge.expected;
  	p = bothLarge.p;
  	alpha = bothLarge.alpha;
  	beta = bothLarge.beta;
  	for ( i = 0; i < p.length; i++ ) {
  		quantile = factory( alpha[i], beta[i] );
  		y = quantile( p[i] );
  		if ( y === expected[i] ) {
  			t.equal( y, expected[i], 'p: '+p[i]+', alpha:'+alpha[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] );
  		} else {
  			delta = abs( y - expected[ i ] );
  			tol = 1350.0 * EPS * abs( expected[ i ] );
  			t.ok( delta <= tol, 'within tolerance. p: '+p[ i ]+'. alpha: '+alpha[i]+'. beta: '+beta[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
  		}
  	}
  	t.end();
  });
  
  tape( 'the created function evaluates the quantile for `p` given large shape parameter `alpha`', function test( t ) {
  	var expected;
  	var quantile;
  	var alpha;
  	var delta;
  	var beta;
  	var tol;
  	var p;
  	var y;
  	var i;
  
  	expected = largeShape.expected;
  	p = largeShape.p;
  	alpha = largeShape.alpha;
  	beta = largeShape.beta;
  	for ( i = 0; i < p.length; i++ ) {
  		quantile = factory( alpha[i], beta[i] );
  		y = quantile( p[i] );
  		if ( y === expected[i] ) {
  			t.equal( y, expected[i], 'p: '+p[i]+', alpha:'+alpha[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] );
  		} else {
  			delta = abs( y - expected[ i ] );
  			tol = 20.0 * EPS * abs( expected[ i ] );
  			t.ok( delta <= tol, 'within tolerance. p: '+p[ i ]+'. alpha: '+alpha[i]+'. beta: '+beta[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
  		}
  	}
  	t.end();
  });
  
  tape( 'the created function evaluates the quantile for `p` given large rate parameter `beta`', function test( t ) {
  	var expected;
  	var quantile;
  	var alpha;
  	var delta;
  	var beta;
  	var tol;
  	var p;
  	var y;
  	var i;
  
  	expected = largeRate.expected;
  	p = largeRate.p;
  	alpha = largeRate.alpha;
  	beta = largeRate.beta;
  	for ( i = 0; i < p.length; i++ ) {
  		quantile = factory( alpha[i], beta[i] );
  		y = quantile( p[i] );
  		if ( y === expected[i] ) {
  			t.equal( y, expected[i], 'p: '+p[i]+', alpha:'+alpha[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] );
  		} else {
  			delta = abs( y - expected[ i ] );
  			tol = 200.0 * EPS * abs( expected[ i ] );
  			t.ok( delta <= tol, 'within tolerance. p: '+p[ i ]+'. alpha: '+alpha[i]+'. beta: '+beta[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
  		}
  	}
  	t.end();
  });
  