From 2868db0d41b8d1d7b141c0494c262120dd9864b7 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Sun, 24 Jan 2016 19:51:06 -0500 Subject: [PATCH] Core: Update isNumeric tests for pre-ES2015 safety Ref 7103d8ef47e04a4cf373abee0e8bfa9062fd616f --- test/unit/core.js | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/test/unit/core.js b/test/unit/core.js index 4099119b8..4f77e0626 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -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 ) { @@ -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" ); -- 2.39.5