]> source.dussan.org Git - jquery-ui.git/commitdiff
Tests: Lint.
authorScott González <scott.gonzalez@gmail.com>
Thu, 19 Apr 2012 02:36:15 +0000 (22:36 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 19 Apr 2012 02:36:15 +0000 (22:36 -0400)
14 files changed:
grunt.js
tests/unit/spinner/spinner_core.js
tests/unit/spinner/spinner_methods.js
tests/unit/spinner/spinner_options.js
tests/unit/subsuite.js
tests/unit/subsuiteRunner.js
tests/unit/swarminject.js
tests/unit/tabs/tabs_deprecated.js
tests/unit/tabs/tabs_methods.js
tests/unit/testsuite.js
tests/unit/tooltip/tooltip_methods.js
tests/unit/tooltip/tooltip_options.js
tests/unit/widget/widget_core.js
tests/unit/widget/widget_extend.js

index 02c889d7491f14c2f21701318be7269c1fe71e1a..0295b399c9ce06c43c7f756bb1dc10a2b871506b 100644 (file)
--- a/grunt.js
+++ b/grunt.js
@@ -345,13 +345,31 @@ grunt.initConfig({
                                        browser: true,
                                        jquery: true
                                }, defaults ),
+                               // TODO: don't create so many globals in tests
                                globals: {
+                                       accordion_state: true,
+                                       asyncTest: true,
+                                       commonWidgetTests: true,
+                                       deepEqual: true,
+                                       dlg: true,
+                                       domEqual: true,
+                                       drag: true,
+                                       el: true,
+                                       equal: true,
+                                       expect: true,
+                                       Globalize: true,
+                                       menu_click: true,
+                                       menu_log: true,
                                        module: true,
-                                       test: true,
                                        ok: true,
-                                       equal: true,
-                                       deepEqual: true,
-                                       QUnit: true
+                                       QUnit: true,
+                                       spinner_simulateKeyDownUp: true,
+                                       start: true,
+                                       strictEqual: true,
+                                       stop: true,
+                                       tabs_state: true,
+                                       tabs_disabled: true,
+                                       test: true
                                }
                        }
                };
index e12d1af2f25d725e0f333b9e65aaa6fc3c8a5c05..e38b467a3508e67a59ec8d5da06a74391064a87e 100644 (file)
@@ -99,7 +99,7 @@ test( "mouse click on up button, increases value not greater than max", function
                min: 0
        }),
        button = element.spinner( "widget" ).find( ".ui-spinner-down" );
-       
+
        button.trigger( "mousedown" ).trigger( "mouseup" );
        equal( element.val(), 1 );
        button.trigger( "mousedown" ).trigger( "mouseup" );
@@ -189,8 +189,8 @@ test( "don't clear invalid value on blur", function() {
 
 test( "precision", function() {
        expect( 2 );
-       var element = $( "#spin" ).val( .05 ).spinner({
-               step: .0001
+       var element = $( "#spin" ).val( 0.05 ).spinner({
+               step: 0.0001
        });
        element.spinner( "stepUp" );
        equal( element.val(), "0.0501", "precision from step" );
index 9c82218e182d7e2f5b8f2700b3be8848f944e894..2cb3c849f66745407064e0cfefae15628be707e2 100644 (file)
@@ -54,7 +54,7 @@ test( "disable", function() {
 
 test( "enable", function() {
        expect( 5 );
-       var element = $( "#spin" ).val( 1 ).spinner({ disabled: true })
+       var element = $( "#spin" ).val( 1 ).spinner({ disabled: true }),
                wrapper = element.spinner( "widget" );
 
        ok( wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper has ui-spinner-disabled class" );
index cbad3f870bb57f70d968b8d0d513c49b1ea0572e..6f5090d3ab1db48734befe5520f59394f2cf4e11 100644 (file)
@@ -191,7 +191,7 @@ test( "min, string", function() {
        equal( element.spinner( "option", "min" ), -100, "option converted to number" );
 
        element.spinner( "value", -1000 );
-       equal( element.val(), "($100.00)", "min constrained in value method")
+       equal( element.val(), "($100.00)", "min constrained in value method" );
 });
 
 test( "step, 2", function() {
index 03e8c97061ef0b107b0a02b0dace8962caeb7ccd..6f966590b145a8d8a9b32efecfcf917bcfa27676 100644 (file)
@@ -1,12 +1,11 @@
 (function() {
 
-var versions = [ "1.6", "1.6.1", "1.6.2", "1.6.3", "1.6.4", "1.7", "1.7.1", "1.7.2", "git" ];
-
-var additionalTests = {
-       accordion: [ "accordion_deprecated.html" ],
-       position: [ "position_deprecated.html" ],
-       tabs: [ "tabs_deprecated.html" ]
-};
+var versions = [ "1.6", "1.6.1", "1.6.2", "1.6.3", "1.6.4", "1.7", "1.7.1", "1.7.2", "git" ],
+       additionalTests = {
+               accordion: [ "accordion_deprecated.html" ],
+               position: [ "position_deprecated.html" ],
+               tabs: [ "tabs_deprecated.html" ]
+       };
 
 window.testAllVersions = function( widget ) {
        QUnit.testSuites( $.map(
index ddfccc7c1e1028532594ae9cd369de685fddc9ef..2d6de2de11dafb40de4bde938ffa0d1c6f3e67fa 100644 (file)
@@ -4,13 +4,16 @@ var subsuiteFrame;
 
 QUnit.extend( QUnit, {
        testSuites: function( suites ) {
+               function generateSuite( suite ) {
+                       asyncTest( suite, function() {
+                               QUnit.runSuite( suite );
+                       });
+               }
+
                for ( var i = 0; i < suites.length; i++ ) {
-                       (function( suite ) {
-                               asyncTest( suite, function() {
-                                       QUnit.runSuite( suite );
-                               });
-                       }( suites[i] ) );
+                       generateSuite( suites[ i ] );
                }
+
                QUnit.done = function() {
                        subsuiteFrame.style.display = "none";
                };
@@ -23,10 +26,12 @@ QUnit.extend( QUnit, {
 
        testDone: function() {
                var current = QUnit.id( this.config.current.id ),
-                       children = current.children;
+                       children = current.children,
+                       i = 0,
+                       length = children.length;
 
                // undo the auto-expansion of failed tests
-               for ( var i = 0; i < children.length; i++ ) {
+               for ( ; i < length; i++ ) {
                        if ( children[i].nodeName === "OL" ) {
                                children[i].style.display = "none";
                        }
@@ -34,10 +39,11 @@ QUnit.extend( QUnit, {
        },
 
        runSuite: function( suite ) {
-               var body = document.getElementsByTagName( "body" )[0],
-                       iframe = subsuiteFrame = document.createElement( "iframe" ),
-                       iframeWin;
+               var iframeWin,
+                       body = document.getElementsByTagName( "body" )[0],
+                       iframe = document.createElement( "iframe" );
 
+               subsuiteFrame = iframe;
                iframe.className = "qunit-subsuite";
                body.appendChild( iframe );
 
index db69326abe169bc9963146f58cdfdf3410432bb2..78d37ef4690c45d92f0900fd2cfda009e5ba3a18 100644 (file)
@@ -5,5 +5,5 @@
        if ( !url || url.indexOf("http") !== 0 ) {
                return;
        }
-    document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
+    document.write( "<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() + "'></scr" + "ipt>" );
 })();
index 80bc4a326da0ef8f3da748776434b3471e0da79c..c8f0e2881d043c359b11e12a5363797e4683efac 100644 (file)
@@ -89,10 +89,11 @@ test( "tabTemplate + panelTemplate", function() {
        // defaults are tested in the add method test
        expect( 11 );
 
-       var element = $( "#tabs2" ).tabs({
-               tabTemplate: "<li class='customTab'><a href='http://example.com/#{href}'>#{label}</a></li>",
-               panelTemplate: "<div class='customPanel'></div>"
-       });
+       var tab, anchor,
+               element = $( "#tabs2" ).tabs({
+                       tabTemplate: "<li class='customTab'><a href='http://example.com/#{href}'>#{label}</a></li>",
+                       panelTemplate: "<div class='customPanel'></div>"
+               });
        element.one( "tabsadd", function( event, ui ) {
                var anchor = $( ui.tab );
                equal( ui.index, 5, "ui.index" );
@@ -103,8 +104,8 @@ test( "tabTemplate + panelTemplate", function() {
                ok( $( ui.panel ).hasClass( "customPanel" ), "panel custom class" );
        });
        element.tabs( "add", "#new", "New" );
-       var tab = element.find( ".ui-tabs-nav li" ).last(),
-               anchor = tab.find( "a" );
+       tab = element.find( ".ui-tabs-nav li" ).last();
+       anchor = tab.find( "a" );
        equal( tab.text(), "New", "label" );
        ok( tab.hasClass( "customTab" ), "tab custom class" );
        equal( anchor.attr( "href" ), "http://example.com/#new", "href" );
@@ -393,7 +394,8 @@ module( "tabs (deprecated): methods" );
 test( "add", function() {
        expect( 27 );
 
-       var element = $( "#tabs1" ).tabs();
+       var tab, anchor,
+               element = $( "#tabs1" ).tabs();
        tabs_state( element, 1, 0, 0 );
 
        // add without index
@@ -404,8 +406,8 @@ test( "add", function() {
        });
        element.tabs( "add", "#new", "New" );
        tabs_state( element, 1, 0, 0, 0 );
-       var tab = element.find( ".ui-tabs-nav li" ).last(),
-               anchor = tab.find( "a" );
+       tab = element.find( ".ui-tabs-nav li" ).last();
+       anchor = tab.find( "a" );
        equal( tab.text(), "New", "label" );
        equal( anchor.attr( "href" ), "#new", "href" );
        equal( anchor.attr( "aria-controls" ), "new", "aria-controls" );
index fee87db96b7993e69ac5f59d870bb016c5f137a8..0a59ae302d2096f33a0dfc576da68eeacba67b1f 100644 (file)
@@ -167,9 +167,8 @@ asyncTest( "load", function() {
        element.one( "tabsload", function( event, ui ) {
                // TODO: remove wrapping in 2.0
                var uiTab = $( ui.tab ),
-                       uiPanel = $( ui.panel );
-
-               var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+                       uiPanel = $( ui.panel ),
+                       tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
                        panelId = tab.attr( "aria-controls" ),
                        panel = $( "#" + panelId );
 
@@ -215,9 +214,8 @@ asyncTest( "load", function() {
                element.one( "tabsload", function( event, ui ) {
                        // TODO: remove wrapping in 2.0
                        var uiTab = $( ui.tab ),
-                               uiPanel = $( ui.panel );
-
-                       var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+                               uiPanel = $( ui.panel ),
+                               tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
                                panelId = tab.attr( "aria-controls" ),
                                panel = $( "#" + panelId );
 
index d37e27f7bb7bfe4f26f32f4ddfd24c831d8a5e54..2ef6bf472c27c10158da6f0af5dfd8b104dd97eb 100644 (file)
@@ -63,7 +63,7 @@ window.commonWidgetTests = function( widget, settings ) {
        test( "version", function() {
                ok( "version" in $.ui[ widget ].prototype, "version property exists" );
        });
-}
+};
 
 /*
  * Experimental assertion for comparing DOM objects.
@@ -72,20 +72,22 @@ window.commonWidgetTests = function( widget, settings ) {
  * Then compares the result using deepEqual.
  */
 window.domEqual = function( selector, modifier, message ) {
-       var attributes = ["class", "role", "id", "tabIndex", "aria-activedescendant"];
+       var expected, actual,
+               attributes = ["class", "role", "id", "tabIndex", "aria-activedescendant"];
 
        function extract(value) {
                if (!value || !value.length) {
                        QUnit.push( false, actual, expected, "domEqual failed, can't extract " + selector + ", message was: " + message );
                        return;
                }
-               var result = {};
+               var children,
+                       result = {};
                result.nodeName = value[0].nodeName;
                $.each(attributes, function(index, attr) {
                        result[attr] = value.prop(attr);
                });
                result.children = [];
-               var children = value.children();
+               children = value.children();
                if (children.length) {
                        children.each(function() {
                                result.children.push(extract($(this)));
@@ -95,11 +97,11 @@ window.domEqual = function( selector, modifier, message ) {
                }
                return result;
        }
-       var expected = extract($(selector));
-       modifier($(selector));
+       expected = extract( $( selector ) );
+       modifier( $( selector ) );
 
-       var actual = extract($(selector));
+       actual = extract( $( selector ) );
        QUnit.push( QUnit.equiv(actual, expected), actual, expected, message );
-}
+};
 
 }());
index 3e8256c50a0e4ccd645ad315a41da3e0d813501c..eaab1c0d188ee88a2d70e85c155e3a2bb8b2d1b5 100644 (file)
@@ -16,11 +16,12 @@ test( "destroy", function() {
 test( "open/close", function() {
        expect( 3 );
        $.fx.off = true;
-       var element = $( "#tooltipped1" ).tooltip();
+       var tooltip,
+               element = $( "#tooltipped1" ).tooltip();
        equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
 
        element.tooltip( "open" );
-       var tooltip = $( "#" + element.attr( "aria-describedby" ) );
+       tooltip = $( "#" + element.attr( "aria-describedby" ) );
        ok( tooltip.is( ":visible" ) );
 
        element.tooltip( "close" );
@@ -31,11 +32,12 @@ test( "open/close", function() {
 test( "enable/disable", function() {
        expect( 7 );
        $.fx.off = true;
-       var element = $( "#tooltipped1" ).tooltip();
+       var tooltip,
+               element = $( "#tooltipped1" ).tooltip();
        equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
 
        element.tooltip( "open" );
-       var tooltip = $( "#" + element.attr( "aria-describedby" ) );
+       tooltip = $( "#" + element.attr( "aria-describedby" ) );
        ok( tooltip.is( ":visible" ) );
 
        element.tooltip( "disable" );
index 42529e08756be04df0bd081871daa2c73e9115d1..4f994f8de907ee61ef700ec31bc49c702bf498d3 100644 (file)
@@ -45,11 +45,12 @@ asyncTest( "content: sync + async callback", function() {
 
 test( "items", function() {
        expect( 2 );
-       var element = $( "#qunit-fixture" ).tooltip({
-               items: "#fixture-span"
-       });
+       var event,
+               element = $( "#qunit-fixture" ).tooltip({
+                       items: "#fixture-span"
+               });
 
-       var event = $.Event( "mouseenter" );
+       event = $.Event( "mouseenter" );
        event.target = $( "#fixture-span" )[ 0 ];
        element.tooltip( "open", event );
        deepEqual( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" );
@@ -63,7 +64,7 @@ test( "items", function() {
 });
 
 test( "tooltipClass", function() {
-       expect( 1 )
+       expect( 1 );
        var element = $( "#tooltipped1" ).tooltip({
                tooltipClass: "custom"
        }).tooltip( "open" );
index e104d4ae91e25dc4ca30913de7e6c020d9ed025f..38495e282116252644fb253c144b4b50bde162ae 100644 (file)
@@ -84,7 +84,8 @@ test( "custom selector expression", function() {
 test( "jQuery usage", function() {
        expect( 16 );
 
-       var shouldCreate = false;
+       var elem, instance, ret, bcInstance,
+               shouldCreate = false;
 
        $.widget( "ui.testWidget", {
                getterSetterVal: 5,
@@ -113,22 +114,22 @@ test( "jQuery usage", function() {
        });
 
        shouldCreate = true;
-       var elem = $( "<div>" )
+       elem = $( "<div>" )
                .bind( "testwidgetcreate", function() {
                        ok( shouldCreate, "create event triggered on instantiation" );
                })
                .testWidget();
        shouldCreate = false;
 
-       var instance = elem.data( "ui-testWidget" );
+       instance = elem.data( "ui-testWidget" );
        equal( typeof instance, "object", "instance stored in .data(pluginName)" );
        equal( instance.element[0], elem[0], "element stored on widget" );
-       var ret = elem.testWidget( "methodWithParams", "value1", "value2" );
+       ret = elem.testWidget( "methodWithParams", "value1", "value2" );
        equal( ret, elem, "jQuery object returned from method call" );
 
        // 1.9 BC for #7810
        // TODO remove
-       var bcInstance = elem.data("testWidget");
+       bcInstance = elem.data("testWidget");
        equal( typeof bcInstance, "object", "instance stored in .data(pluginName)" );
        equal( bcInstance.element[0], elem[0], "element stored on widget" );
 
@@ -148,7 +149,8 @@ test( "jQuery usage", function() {
 test( "direct usage", function() {
        expect( 9 );
 
-       var shouldCreate = false;
+       var elem, instance, ret,
+               shouldCreate = false;
 
        $.widget( "ui.testWidget", {
                getterSetterVal: 5,
@@ -171,17 +173,17 @@ test( "direct usage", function() {
                }
        });
 
-       var elem = $( "<div>" )[ 0 ];
+       elem = $( "<div>" )[ 0 ];
 
        shouldCreate = true;
-       var instance = new $.ui.testWidget( {}, elem );
+       instance = new $.ui.testWidget( {}, elem );
        shouldCreate = false;
 
        equal( $( elem ).data( "ui-testWidget" ), instance,
                "instance stored in .data(pluginName)" );
        equal( instance.element[ 0 ], elem, "element stored on widget" );
 
-       var ret = instance.methodWithParams( "value1", "value2" );
+       ret = instance.methodWithParams( "value1", "value2" );
        equal( ret, instance, "plugin returned from method call" );
 
        ret = instance.getterSetterMethod();
@@ -439,11 +441,12 @@ test( ".option() - getter", function() {
                _create: function() {}
        });
 
-       var div = $( "<div>" ).testWidget({
-               foo: "bar",
-               baz: 5,
-               qux: [ "quux", "quuux" ]
-       });
+       var options,
+               div = $( "<div>" ).testWidget({
+                       foo: "bar",
+                       baz: 5,
+                       qux: [ "quux", "quuux" ]
+               });
 
        deepEqual( div.testWidget( "option", "x" ), null, "non-existent option" );
        deepEqual( div.testWidget( "option", "foo"), "bar", "single option - string" );
@@ -451,7 +454,7 @@ test( ".option() - getter", function() {
        deepEqual( div.testWidget( "option", "qux"), [ "quux", "quuux" ],
                "single option - array" );
 
-       var options = div.testWidget( "option" );
+       options = div.testWidget( "option" );
        deepEqual( options, {
                create: null,
                disabled: false,
@@ -483,14 +486,15 @@ test( ".option() - deep option getter", function() {
 });
 
 test( ".option() - delegate to ._setOptions()", function() {
-       var calls = [];
+       var div,
+               calls = [];
        $.widget( "ui.testWidget", {
                _create: function() {},
                _setOptions: function( options ) {
                        calls.push( options );
                }
        });
-       var div = $( "<div>" ).testWidget();
+       div = $( "<div>" ).testWidget();
 
        calls = [];
        div.testWidget( "option", "foo", "bar" );
@@ -506,7 +510,8 @@ test( ".option() - delegate to ._setOptions()", function() {
 });
 
 test( ".option() - delegate to ._setOption()", function() {
-       var calls = [];
+       var div,
+               calls = [];
        $.widget( "ui.testWidget", {
                _create: function() {},
                _setOption: function( key, val ) {
@@ -516,7 +521,7 @@ test( ".option() - delegate to ._setOption()", function() {
                        });
                }
        });
-       var div = $( "<div>" ).testWidget();
+       div = $( "<div>" ).testWidget();
 
        calls = [];
        div.testWidget( "option", "foo", "bar" );
@@ -603,7 +608,7 @@ test( ".widget() - overriden", function() {
 
 test( "._bind() to element (default)", function() {
        expect( 12 );
-       var that;
+       var that, widget;
        $.widget( "ui.testWidget", {
                _create: function() {
                        that = this;
@@ -623,7 +628,7 @@ test( "._bind() to element (default)", function() {
                        equal( "keydown", event.type );
                }
        });
-       var widget = $( "<div></div>" )
+       widget = $( "<div></div>" )
                .testWidget()
                .trigger( "keyup" )
                .trigger( "keydown" );
@@ -643,7 +648,7 @@ test( "._bind() to element (default)", function() {
 
 test( "._bind() to descendent", function() {
        expect( 12 );
-       var that;
+       var that, widget, descendant;
        $.widget( "ui.testWidget", {
                _create: function() {
                        that = this;
@@ -664,28 +669,28 @@ test( "._bind() to descendent", function() {
                }
        });
        // trigger events on both widget and descendent to ensure that only descendent receives them
-       var widget = $( "<div><p><strong>hello</strong> world</p></div>" )
+       widget = $( "<div><p><strong>hello</strong> world</p></div>" )
                .testWidget()
                .trigger( "keyup" )
                .trigger( "keydown" );
-       var descendent = widget.find( "strong" )
+       descendant = widget.find( "strong" )
                .trigger( "keyup" )
                .trigger( "keydown" );
        widget
                .testWidget( "disable" )
                .trigger( "keyup" )
                .trigger( "keydown" );
-       descendent
+       descendant
                .trigger( "keyup" )
                .trigger( "keydown" );
        widget
                .testWidget( "enable" )
                .trigger( "keyup" )
                .trigger( "keydown" );
-       descendent
+       descendant
                .trigger( "keyup" )
                .trigger( "keydown" );
-       descendent
+       descendant
                .addClass( "ui-state-disabled" )
                .trigger( "keyup" )
                .trigger( "keydown" );
@@ -693,7 +698,7 @@ test( "._bind() to descendent", function() {
                .testWidget( "destroy" )
                .trigger( "keyup" )
                .trigger( "keydown" );
-       descendent
+       descendant
                .trigger( "keyup" )
                .trigger( "keydown" );
 });
@@ -942,10 +947,10 @@ test( "._trigger() - array as ui", function() {
                                                qux: 5,
                                                quux: 20
                                        }
+                               },
+                               extra = {
+                                       bar: 5
                                };
-                       var extra = {
-                               bar: 5
-                       };
                        this._trigger( "foo", null, [ ui, extra ] );
                }
        });
@@ -983,8 +988,7 @@ test( "._trigger() - instance as element", function() {
        $.widget( "ui.testWidget", {
                defaultElement: null,
                testEvent: function() {
-                       var ui = { foo: "bar" };
-                       this._trigger( "foo", null, ui );
+                       this._trigger( "foo", null, { foo: "bar" } );
                }
        });
        var instance = $.ui.testWidget({
index 90e686e18efc57b45e7ded627f1a04ca2a000aa6..36cd999dde028cac9d272951065e8d5fcf2a6f46 100644 (file)
@@ -1,7 +1,9 @@
 test( "$.widget.extend()", function() {
        expect( 26 );
 
-       var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
+       var ret, empty, optionsWithLength, optionsWithDate, myKlass, customObject, optionsWithCustomObject, nullUndef,
+               target, recursive, obj, input, output,
+               settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
                options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
                optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
                merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
@@ -10,8 +12,7 @@ test( "$.widget.extend()", function() {
                deep2copy = { foo: { baz: true }, foo2: document },
                deepmerged = { foo: { bar: true, baz: true }, foo2: document },
                arr = [1, 2, 3],
-               nestedarray = { arr: arr },
-               ret;
+               nestedarray = { arr: arr };
 
        $.widget.extend( settings, options );
        deepEqual( settings, merged, "Check if extended: settings must be extended" );
@@ -25,19 +26,19 @@ test( "$.widget.extend()", function() {
        strictEqual( $.widget.extend({}, nestedarray).arr, arr, "Don't clone arrays" );
        ok( $.isPlainObject( $.widget.extend({ arr: arr }, { arr: {} }).arr ), "Cloned object heve to be an plain object" );
 
-       var empty = {};
-       var optionsWithLength = { foo: { length: -1 } };
+       empty = {};
+       optionsWithLength = { foo: { length: -1 } };
        $.widget.extend( empty, optionsWithLength );
        deepEqual( empty.foo, optionsWithLength.foo, "The length property must copy correctly" );
 
        empty = {};
-       var optionsWithDate = { foo: { date: new Date } };
+       optionsWithDate = { foo: { date: new Date() } };
        $.widget.extend( empty, optionsWithDate );
        deepEqual( empty.foo, optionsWithDate.foo, "Dates copy correctly" );
 
-       var myKlass = function() {};
-       var customObject = new myKlass();
-       var optionsWithCustomObject = { foo: { date: customObject } };
+       myKlass = function() {};
+       customObject = new myKlass();
+       optionsWithCustomObject = { foo: { date: customObject } };
        empty = {};
        $.widget.extend( empty, optionsWithCustomObject );
        strictEqual( empty.foo.date, customObject, "Custom objects copy correctly (no methods)" );
@@ -48,10 +49,9 @@ test( "$.widget.extend()", function() {
        $.widget.extend( empty, optionsWithCustomObject );
        strictEqual( empty.foo.date, customObject, "Custom objects copy correctly" );
 
-       ret = $.widget.extend({ foo: 4 }, { foo: new Number(5) } );
+       ret = $.widget.extend({ foo: 4 }, { foo: Number(5) } );
        equal( ret.foo, 5, "Wrapped numbers copy correctly" );
 
-       var nullUndef;
        nullUndef = $.widget.extend( {}, options, { xnumber2: null } );
        strictEqual( nullUndef.xnumber2, null, "Check to make sure null values are copied");
 
@@ -61,8 +61,8 @@ test( "$.widget.extend()", function() {
        nullUndef = $.widget.extend( {}, options, { xnumber0: null } );
        strictEqual( nullUndef.xnumber0, null, "Check to make sure null values are inserted");
 
-       var target = {};
-       var recursive = { foo:target, bar:5 };
+       target = {};
+       recursive = { foo:target, bar:5 };
        $.widget.extend( target, recursive );
        deepEqual( target, { foo: {}, bar: 5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
 
@@ -75,7 +75,7 @@ test( "$.widget.extend()", function() {
        ret = $.widget.extend( { foo:"bar" }, { foo:null } );
        strictEqual( typeof ret.foo, "object", "Make sure a null value doesn't crash with deep extend, for #1908" );
 
-       var obj = { foo:null };
+       obj = { foo:null };
        $.widget.extend( obj, { foo:"notnull" } );
        equal( obj.foo, "notnull", "Make sure a null value can be overwritten" );
 
@@ -87,16 +87,16 @@ test( "$.widget.extend()", function() {
                options2Copy = { xstring2: "xx", xxx: "newstringx" },
                merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
 
-       var settings = $.widget.extend( {}, defaults, options1, options2 );
+       settings = $.widget.extend( {}, defaults, options1, options2 );
        deepEqual( settings, merged2, "Check if extended: settings must be extended" );
        deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
        deepEqual( options1, options1Copy, "Check if not modified: options1 must not be modified" );
        deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" );
 
-       var input = {
+       input = {
                key: [ 1, 2, 3 ]
        };
-       var output = $.widget.extend( {}, input );
+       output = $.widget.extend( {}, input );
        deepEqual( input, output, "don't clone arrays" );
        input.key[0] = 10;
        deepEqual( input, output, "don't clone arrays" );