Changeset 14309

Show
Ignore:
Timestamp:
07/07/08 09:28:26 (5 months ago)
Author:
dylan
Message:

fixes #6249, add doh.assertNotEqual, thanks harobed for the patch/cla, \!strict

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • util/trunk/doh/runner.js

    r14122 r14309  
    622622} 
    623623 
     624doh.isNot = doh.assertNotEqual = function(/*Object*/ notExpected, /*Object*/ actual){ 
     625        // summary: 
     626        //              are the passed notexpected and actual objects/values deeply 
     627        //              not equivalent? 
     628 
     629        // Compare undefined always with three equal signs, because undefined==null 
     630        // is true, but undefined===null is false.  
     631        if((notExpected === undefined)&&(actual === undefined)){  
     632        throw new doh._AssertFailure("assertNotEqual() failed: not expected |"+notExpected+"| but got |"+actual+"|"); 
     633        } 
     634        if(arguments.length < 2){  
     635                throw doh._AssertFailure("assertEqual failed because it was not passed 2 arguments");  
     636        }  
     637        if((notExpected === actual)||(notExpected == actual)){  
     638        throw new doh._AssertFailure("assertNotEqual() failed: not expected |"+notExpected+"| but got |"+actual+"|"); 
     639        } 
     640        if(     (this._isArray(notExpected) && this._isArray(actual))&& 
     641                (this._arrayEq(notExpected, actual)) ){ 
     642                throw new doh._AssertFailure("assertNotEqual() failed: not expected |"+notExpected+"| but got |"+actual+"|"); 
     643        } 
     644        if( ((typeof notExpected == "object")&&((typeof actual == "object")))&& 
     645                (this._objPropEq(notExpected, actual)) ){ 
     646        throw new doh._AssertFailure("assertNotEqual() failed: not expected |"+notExpected+"| but got |"+actual+"|"); 
     647        } 
     648    return true; 
     649} 
     650 
    624651doh._arrayEq = function(expected, actual){ 
    625652        if(expected.length != actual.length){ return false; } 
     
    635662                return actual instanceof Date && expected.getTime()==actual.getTime(); 
    636663        } 
     664        var x; 
    637665        // Make sure ALL THE SAME properties are in both objects! 
    638         for(var x in actual){ // Lets check "actual" here, expected is checked below. 
     666        for(x in actual){ // Lets check "actual" here, expected is checked below. 
    639667                if(expected[x] === undefined){ 
    640668                        return false; 
     
    642670        }; 
    643671 
    644         for(var x in expected){ 
     672        for(x in expected){ 
    645673                if(!doh.assertEqual(expected[x], actual[x])){ 
    646674                        return false; 
     
    917945(function(){ 
    918946        // scope protection 
     947        var x; 
    919948        try{ 
    920949                if(typeof dojo != "undefined"){ 
     
    963992                                // find runner.js, load _browserRunner relative to it 
    964993                                var scripts = document.getElementsByTagName("script"); 
    965                                 for(var x=0; x<scripts.length; x++){ 
     994                                for(x=0; x<scripts.length; x++){ 
    966995                                        var s = scripts[x].src; 
    967996                                        if(s && (s.substr(-9) == "runner.js")){ 
     
    9831012                        var testUrl = ""; 
    9841013                        var testModule = "dojo.tests.module"; 
    985                         for(var x=0; x<arguments.length; x++){ 
     1014                        for(x=0; x<arguments.length; x++){ 
    9861015                                if(arguments[x].indexOf("=") > 0){ 
    9871016                                        var tp = arguments[x].split("=");