<commit_before>'use strict';

// MODULES //

var vm = require( 'vm' ); // TODO: handle in-browser tests
var tape = require( 'tape' );
var inherit = require( '@stdlib/utils/inherit' );
var isRangeError = require( './../lib' );


// TESTS //

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

tape( 'the function returns `true` if provided a `RangeError` object', function test( t ) {
	var values;
	var i;

	values = [
		new RangeError( 'range error' )
	];

	for ( i = 0; i < values.length; i++ ) {
		t.strictEqual( isRangeError( values[ i ] ), true, 'returns true when provided '+values[i] );
	}
	t.end();
});

tape( 'the function returns `true` if provided an object inheriting from `RangeError`', function test( t ) {
	function CustomError( msg ) {
		RangeError.call( this );
		this.name = 'CustomError';
		this.message = msg;
		return this;
	}

	inherit( CustomError, RangeError );

	t.strictEqual( isRangeError( new CustomError( 'custom error' ) ), true, 'returns true when provided a value which inherits from RangeError' );
	t.end();
});

tape( 'the function returns `true` if provided a `RangeError` object from a different realm', function test( t ) {
	var error = vm.runInNewContext( 'new RangeError()' );
	t.strictEqual( isRangeError( error ), true, 'returns true' );
	t.end();
});

tape( 'the function returns `true` if provided an object from a different realm which inherits from a `RangeError` object', function test( t ) {
	var error = vm.runInNewContext( 'function Err() { return this; }; Err.prototype = new RangeError(); new Err();' );
	t.strictEqual( isRangeError( error ), true, 'returns true' );
	t.end();
});

tape( 'the function returns `false` if not provided a `RangeError` object', function test( t ) {
	var values;
	var i;

	values = [
		'5',
		5,
		NaN,
		true,
		false,
		null,
		undefined,
		[],
		{},<commit_msg>Skip vm tests in browser<commit_after>'use strict';

// MODULES //

var vm = require( 'vm' ); // TODO: handle in-browser tests
var tape = require( 'tape' );
var IS_BROWSER = require( '@stdlib/assert/is-browser' );
var inherit = require( '@stdlib/utils/inherit' );
var isRangeError = require( './../lib' );


// VARIABLES //

var opts = {
	'skip': IS_BROWSER
};


// TESTS //

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

tape( 'the function returns `true` if provided a `RangeError` object', function test( t ) {
	var values;
	var i;

	values = [
		new RangeError( 'range error' )
	];

	for ( i = 0; i < values.length; i++ ) {
		t.strictEqual( isRangeError( values[ i ] ), true, 'returns true when provided '+values[i] );
	}
	t.end();
});

tape( 'the function returns `true` if provided an object inheriting from `RangeError`', function test( t ) {
	function CustomError( msg ) {
		RangeError.call( this );
		this.name = 'CustomError';
		this.message = msg;
		return this;
	}

	inherit( CustomError, RangeError );

	t.strictEqual( isRangeError( new CustomError( 'custom error' ) ), true, 'returns true when provided a value which inherits from RangeError' );
	t.end();
});

tape( 'the function returns `true` if provided a `RangeError` object from a different realm', opts, function test( t ) {
	var error = vm.runInNewContext( 'new RangeError()' );
	t.strictEqual( isRangeError( error ), true, 'returns true' );
	t.end();
});

tape( 'the function returns `true` if provided an object from a different realm which inherits from a `RangeError` object', opts, function test( t ) {
	var error = vm.runInNewContext( 'function Err() { return this; }; Err.prototype = new RangeError(); new Err();' );
	t.strictEqual( isRangeError( error ), true, 'returns true' );
	t.end();
});

tape( 'the function returns `false` if not provided a `RangeError` object', function test( t ) {
	var values;
	var i;

	values = [
		'5',
		5,
		NaN,
		true,
		false,
		null,
		undefined,
		[],
		{},
{'fraction_non_alphanumeric': 0.15386503067484664, 'fraction_numerical': 0.00147239263803681, 'mean_word_length': 3.863961813842482, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6645140', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1336, 'n_words': 471}