mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
parent
e1192af872
commit
ff9dcfb0c4
@ -460,56 +460,51 @@ 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( value );
|
||||||
return String(this.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" );
|
||||||
ok( t("5"), "Positive integer string");
|
ok( t( "5" ), "Positive integer string" );
|
||||||
ok( t(-16), "Negative integer number");
|
ok( t( -16 ), "Negative integer number" );
|
||||||
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
|
ok( t( "0xFF" ), "Hexadecimal integer literal string" );
|
||||||
// It doesn't pass lint, so disabling until a solution can be found
|
ok( t( 0xFFF ), "Hexadecimal integer literal" );
|
||||||
//ok( t(0144), "Octal integer literal");
|
ok( t( "-1.6" ), "Negative floating point string" );
|
||||||
ok( t("0xFF"), "Hexadecimal integer literal string");
|
ok( t( "4.536" ), "Positive floating point string" );
|
||||||
ok( t(0xFFF), "Hexadecimal integer literal");
|
ok( t( -2.6 ), "Negative floating point number" );
|
||||||
ok( t("-1.6"), "Negative floating point string");
|
ok( t( 3.1415 ), "Positive floating point number" );
|
||||||
ok( t("4.536"), "Positive floating point string");
|
ok( t( 1.5999999999999999 ), "Very precise floating point number" );
|
||||||
ok( t(-2.6), "Negative floating point number");
|
ok( t( 8e5 ), "Exponential notation" );
|
||||||
ok( t(3.1415), "Positive floating point number");
|
ok( t( "123e-2" ), "Exponential notation string" );
|
||||||
ok( t(1.5999999999999999), "Very precise floating point number" );
|
ok( t( new ToString( "42" ) ), "Custom .toString returning number" );
|
||||||
ok( t(8e5), "Exponential notation");
|
|
||||||
ok( t("123e-2"), "Exponential notation string");
|
equal( t( "" ), false, "Empty string" );
|
||||||
ok( t(answer), "Custom .toString returning number");
|
equal( t( " " ), false, "Whitespace characters string" );
|
||||||
equal( t(""), false, "Empty string");
|
equal( t( "\t\t" ), false, "Tab characters string" );
|
||||||
equal( t(" "), false, "Whitespace characters string");
|
equal( t( "abcdefghijklm1234567890" ), false, "Alphanumeric character string" );
|
||||||
equal( t("\t\t"), false, "Tab characters string");
|
equal( t( "xabcdefx" ), false, "Non-numeric character string" );
|
||||||
equal( t("abcdefghijklm1234567890"), false, "Alphanumeric character string");
|
equal( t( true ), false, "Boolean true literal" );
|
||||||
equal( t("xabcdefx"), false, "Non-numeric character string");
|
equal( t( false ), false, "Boolean false literal" );
|
||||||
equal( t(true), false, "Boolean true literal");
|
equal( t( "bcfed5.2" ), false, "Number with preceding non-numeric characters" );
|
||||||
equal( t(false), false, "Boolean false literal");
|
equal( t( "7.2acdgs" ), false, "Number with trailling non-numeric characters" );
|
||||||
equal( t("bcfed5.2"), false, "Number with preceding non-numeric characters");
|
equal( t( undefined ), false, "Undefined value" );
|
||||||
equal( t("7.2acdgs"), false, "Number with trailling non-numeric characters");
|
equal( t( null ), false, "Null value" );
|
||||||
equal( t(undefined), false, "Undefined value");
|
equal( t( NaN ), false, "NaN value" );
|
||||||
equal( t(null), false, "Null value");
|
equal( t( Infinity ), false, "Infinity primitive" );
|
||||||
equal( t(NaN), false, "NaN value");
|
equal( t( Number.POSITIVE_INFINITY ), false, "Positive Infinity" );
|
||||||
equal( t(Infinity), false, "Infinity primitive");
|
equal( t( Number.NEGATIVE_INFINITY ), false, "Negative Infinity" );
|
||||||
equal( t(Number.POSITIVE_INFINITY), false, "Positive Infinity");
|
equal( t( new ToString( "Devo" ) ), false, "Custom .toString returning non-number" );
|
||||||
equal( t(Number.NEGATIVE_INFINITY), false, "Negative Infinity");
|
equal( t( {} ), false, "Empty object" );
|
||||||
equal( t(rong), false, "Custom .toString returning non-number");
|
|
||||||
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" );
|
||||||
equal( t(function(){} ), false, "Instance of a function");
|
equal( t( function(){} ), false, "Instance of a function" );
|
||||||
equal( t( new Date() ), false, "Instance of a Date");
|
equal( t( new Date() ), false, "Instance of a Date" );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("isXMLDoc - HTML", function() {
|
test("isXMLDoc - HTML", function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user