Skip to content

Commit

Permalink
Core: Update isNumeric tests for pre-ES2015 safety
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Jan 25, 2016
1 parent 7103d8e commit 2868db0
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions test/unit/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ QUnit.test( "isFunction", function( assert ) {
} );

QUnit.test( "isNumeric", function( assert ) {
assert.expect( 41 );
assert.expect( 43 );

var t = jQuery.isNumeric,
ToString = function( value ) {
Expand All @@ -464,38 +464,34 @@ QUnit.test( "isNumeric", function( assert ) {
assert.ok( t( -16 ), "Negative integer number" );
assert.ok( t( 0 ), "Zero integer number" );
assert.ok( t( 32 ), "Positive integer number" );
assert.ok( t( "-1.6" ), "Negative floating point string" );
assert.ok( t( "4.536" ), "Positive floating point string" );
assert.ok( t( -2.6 ), "Negative floating point number" );
assert.ok( t( 3.1415 ), "Positive floating point number" );
assert.ok( t( 1.5999999999999999 ), "Very precise floating point number" );
assert.ok( t( 8e5 ), "Exponential notation" );
assert.ok( t( "123e-2" ), "Exponential notation string" );
assert.ok( t( "040" ), "Legacy octal integer literal string" );
assert.ok( t( "0xFF" ), "Hexadecimal integer literal string (0x...)" );
assert.ok( t( "0Xba" ), "Hexadecimal integer literal string (0X...)" );
assert.ok( t( 0xFFF ), "Hexadecimal integer literal" );

if ( +"0b1" === 1 ) {
assert.ok( t( "0b111110" ), "Binary integer literal string" ); // jshint ignore:line
} else {
assert.ok( true, "Browser does not support binary integer literal" );
}

assert.ok( t( "040" ), "Octal integer literal string" );

assert.ok( t( "0xFF" ), "Hexadecimal integer literal string" );

if ( +"0b1" === 1 ) {
assert.ok( t( 0b111110 ), "Binary integer literal" ); // jshint ignore:line
assert.ok( t( "0b111110" ), "Binary integer literal string (0b...)" );
assert.ok( t( "0B111110" ), "Binary integer literal string (0B...)" );
} else {
assert.ok( true, "Browser does not support binary integer literal" );
assert.ok( true, "Browser does not support binary integer literal (0b...)" );
assert.ok( true, "Browser does not support binary integer literal (0B...)" );
}

if ( +"0o1" === 1 ) {
assert.ok( t( 0o76 ), "Octal integer literal" ); // jshint ignore:line
assert.ok( t( "0o76" ), "Octal integer literal string (0o...)" );
assert.ok( t( "0O76" ), "Octal integer literal string (0O...)" );
} else {
assert.ok( true, "Browser does not support octal integer literal" );
assert.ok( true, "Browser does not support octal integer literal (0o...)" );
assert.ok( true, "Browser does not support octal integer literal (0O...)" );
}

assert.ok( t( 0xFFF ), "Hexadecimal integer literal" );
assert.ok( t( "-1.6" ), "Negative floating point string" );
assert.ok( t( "4.536" ), "Positive floating point string" );
assert.ok( t( -2.6 ), "Negative floating point number" );
assert.ok( t( 3.1415 ), "Positive floating point number" );
assert.ok( t( 1.5999999999999999 ), "Very precise floating point number" );
assert.ok( t( 8e5 ), "Exponential notation" );
assert.ok( t( "123e-2" ), "Exponential notation string" );

assert.equal( t( new ToString( "42" ) ), false, "Only limited to strings and numbers" );
assert.equal( t( "" ), false, "Empty string" );
assert.equal( t( " " ), false, "Whitespace characters string" );
Expand Down

0 comments on commit 2868db0

Please sign in to comment.