Skip to content

Commit ff9dcfb

Browse files
committed
Tests: Clean up isNumeric tests
(cherry picked from commit d05f4bd)
1 parent e1192af commit ff9dcfb

File tree

1 file changed

+42
-47
lines changed

1 file changed

+42
-47
lines changed

test/unit/core.js

Lines changed: 42 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -460,56 +460,51 @@ test( "isNumeric", function() {
460460
expect( 38 );
461461

462462
var t = jQuery.isNumeric,
463-
Traditionalists = /** @constructor */ function(n) {
464-
this.value = n;
465-
this.toString = function(){
466-
return String(this.value);
463+
ToString = function( value ) {
464+
this.toString = function() {
465+
return String( value );
467466
};
468-
},
469-
answer = new Traditionalists( "42" ),
470-
rong = new Traditionalists( "Devo" );
471-
472-
ok( t("-10"), "Negative integer string");
473-
ok( t("0"), "Zero string");
474-
ok( t("5"), "Positive integer string");
475-
ok( t(-16), "Negative integer number");
476-
ok( t(0), "Zero integer number");
477-
ok( t(32), "Positive integer number");
478-
ok( t("040"), "Octal integer literal string");
479-
// OctalIntegerLiteral has been deprecated since ES3/1999
480-
// It doesn't pass lint, so disabling until a solution can be found
481-
//ok( t(0144), "Octal integer literal");
482-
ok( t("0xFF"), "Hexadecimal integer literal string");
483-
ok( t(0xFFF), "Hexadecimal integer literal");
484-
ok( t("-1.6"), "Negative floating point string");
485-
ok( t("4.536"), "Positive floating point string");
486-
ok( t(-2.6), "Negative floating point number");
487-
ok( t(3.1415), "Positive floating point number");
488-
ok( t(1.5999999999999999), "Very precise floating point number" );
489-
ok( t(8e5), "Exponential notation");
490-
ok( t("123e-2"), "Exponential notation string");
491-
ok( t(answer), "Custom .toString returning number");
492-
equal( t(""), false, "Empty string");
493-
equal( t(" "), false, "Whitespace characters string");
494-
equal( t("\t\t"), false, "Tab characters string");
495-
equal( t("abcdefghijklm1234567890"), false, "Alphanumeric character string");
496-
equal( t("xabcdefx"), false, "Non-numeric character string");
497-
equal( t(true), false, "Boolean true literal");
498-
equal( t(false), false, "Boolean false literal");
499-
equal( t("bcfed5.2"), false, "Number with preceding non-numeric characters");
500-
equal( t("7.2acdgs"), false, "Number with trailling non-numeric characters");
501-
equal( t(undefined), false, "Undefined value");
502-
equal( t(null), false, "Null value");
503-
equal( t(NaN), false, "NaN value");
504-
equal( t(Infinity), false, "Infinity primitive");
505-
equal( t(Number.POSITIVE_INFINITY), false, "Positive Infinity");
506-
equal( t(Number.NEGATIVE_INFINITY), false, "Negative Infinity");
507-
equal( t(rong), false, "Custom .toString returning non-number");
508-
equal( t({}), false, "Empty object");
467+
};
468+
469+
ok( t( "-10" ), "Negative integer string" );
470+
ok( t( "0" ), "Zero string" );
471+
ok( t( "5" ), "Positive integer string" );
472+
ok( t( -16 ), "Negative integer number" );
473+
ok( t( 0 ), "Zero integer number" );
474+
ok( t( 32 ), "Positive integer number" );
475+
ok( t( "040" ), "Octal integer literal string" );
476+
ok( t( "0xFF" ), "Hexadecimal integer literal string" );
477+
ok( t( 0xFFF ), "Hexadecimal integer literal" );
478+
ok( t( "-1.6" ), "Negative floating point string" );
479+
ok( t( "4.536" ), "Positive floating point string" );
480+
ok( t( -2.6 ), "Negative floating point number" );
481+
ok( t( 3.1415 ), "Positive floating point number" );
482+
ok( t( 1.5999999999999999 ), "Very precise floating point number" );
483+
ok( t( 8e5 ), "Exponential notation" );
484+
ok( t( "123e-2" ), "Exponential notation string" );
485+
ok( t( new ToString( "42" ) ), "Custom .toString returning number" );
486+
487+
equal( t( "" ), false, "Empty string" );
488+
equal( t( " " ), false, "Whitespace characters string" );
489+
equal( t( "\t\t" ), false, "Tab characters string" );
490+
equal( t( "abcdefghijklm1234567890" ), false, "Alphanumeric character string" );
491+
equal( t( "xabcdefx" ), false, "Non-numeric character string" );
492+
equal( t( true ), false, "Boolean true literal" );
493+
equal( t( false ), false, "Boolean false literal" );
494+
equal( t( "bcfed5.2" ), false, "Number with preceding non-numeric characters" );
495+
equal( t( "7.2acdgs" ), false, "Number with trailling non-numeric characters" );
496+
equal( t( undefined ), false, "Undefined value" );
497+
equal( t( null ), false, "Null value" );
498+
equal( t( NaN ), false, "NaN value" );
499+
equal( t( Infinity ), false, "Infinity primitive" );
500+
equal( t( Number.POSITIVE_INFINITY ), false, "Positive Infinity" );
501+
equal( t( Number.NEGATIVE_INFINITY ), false, "Negative Infinity" );
502+
equal( t( new ToString( "Devo" ) ), false, "Custom .toString returning non-number" );
503+
equal( t( {} ), false, "Empty object" );
509504
equal( t( [] ), false, "Empty array" );
510505
equal( t( [ 42 ] ), false, "Array with one number" );
511-
equal( t(function(){} ), false, "Instance of a function");
512-
equal( t( new Date() ), false, "Instance of a Date");
506+
equal( t( function(){} ), false, "Instance of a function" );
507+
equal( t( new Date() ), false, "Instance of a Date" );
513508
});
514509

515510
test("isXMLDoc - HTML", function() {

0 commit comments

Comments
 (0)