Tests: Clean up isNumeric tests

(cherry picked from commit d05f4bda1c)
This commit is contained in:
Richard Gibson 2014-06-07 14:33:36 -04:00
parent e1192af872
commit ff9dcfb0c4

View File

@ -460,14 +460,11 @@ test( "isNumeric", function() {
expect( 38 ); expect( 38 );
var t = jQuery.isNumeric, var t = jQuery.isNumeric,
Traditionalists = /** @constructor */ function(n) { ToString = function( value ) {
this.value = n;
this.toString = function() { this.toString = function() {
return String(this.value); return String( value );
};
}; };
},
answer = new Traditionalists( "42" ),
rong = new Traditionalists( "Devo" );
ok( t( "-10" ), "Negative integer string" ); ok( t( "-10" ), "Negative integer string" );
ok( t( "0" ), "Zero string" ); ok( t( "0" ), "Zero string" );
@ -476,9 +473,6 @@ test( "isNumeric", function() {
ok( t( 0 ), "Zero integer number" ); ok( t( 0 ), "Zero integer number" );
ok( t( 32 ), "Positive integer number" ); ok( t( 32 ), "Positive integer number" );
ok( t( "040" ), "Octal integer literal string" ); ok( t( "040" ), "Octal integer literal string" );
// OctalIntegerLiteral has been deprecated since ES3/1999
// It doesn't pass lint, so disabling until a solution can be found
//ok( t(0144), "Octal integer literal");
ok( t( "0xFF" ), "Hexadecimal integer literal string" ); ok( t( "0xFF" ), "Hexadecimal integer literal string" );
ok( t( 0xFFF ), "Hexadecimal integer literal" ); ok( t( 0xFFF ), "Hexadecimal integer literal" );
ok( t( "-1.6" ), "Negative floating point string" ); ok( t( "-1.6" ), "Negative floating point string" );
@ -488,7 +482,8 @@ test( "isNumeric", function() {
ok( t( 1.5999999999999999 ), "Very precise floating point number" ); ok( t( 1.5999999999999999 ), "Very precise floating point number" );
ok( t( 8e5 ), "Exponential notation" ); ok( t( 8e5 ), "Exponential notation" );
ok( t( "123e-2" ), "Exponential notation string" ); ok( t( "123e-2" ), "Exponential notation string" );
ok( t(answer), "Custom .toString returning number"); ok( t( new ToString( "42" ) ), "Custom .toString returning number" );
equal( t( "" ), false, "Empty string" ); equal( t( "" ), false, "Empty string" );
equal( t( " " ), false, "Whitespace characters string" ); equal( t( " " ), false, "Whitespace characters string" );
equal( t( "\t\t" ), false, "Tab characters string" ); equal( t( "\t\t" ), false, "Tab characters string" );
@ -504,7 +499,7 @@ test( "isNumeric", function() {
equal( t( Infinity ), false, "Infinity primitive" ); equal( t( Infinity ), false, "Infinity primitive" );
equal( t( Number.POSITIVE_INFINITY ), false, "Positive Infinity" ); equal( t( Number.POSITIVE_INFINITY ), false, "Positive Infinity" );
equal( t( Number.NEGATIVE_INFINITY ), false, "Negative Infinity" ); equal( t( Number.NEGATIVE_INFINITY ), false, "Negative Infinity" );
equal( t(rong), false, "Custom .toString returning non-number"); equal( t( new ToString( "Devo" ) ), false, "Custom .toString returning non-number" );
equal( t( {} ), false, "Empty object" ); equal( t( {} ), false, "Empty object" );
equal( t( [] ), false, "Empty array" ); equal( t( [] ), false, "Empty array" );
equal( t( [ 42 ] ), false, "Array with one number" ); equal( t( [ 42 ] ), false, "Array with one number" );