Changeset 51

Show
Ignore:
Timestamp:
03/16/06 15:47:01 (3 years ago)
Author:
Jan-Klaas Kollhof
Message:

updating operators for equality testing and using repr() in testin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/jsolait/lib/operators.js

    r47 r51  
    5555            return b.__eq__(a); 
    5656        }else{ 
    57             return a==b; 
     57            return a===b; 
    5858        } 
    5959    }; 
     
    6565            return b.__ne__(a); 
    6666        }else{ 
    67             return a != b; 
     67            return a !== b; 
    6868        } 
    6969    }; 
     
    117117    }; 
    118118 
     119 
     120    Array.prototype.__eq__ = function(a){ 
     121        if(this.length != a.length){ 
     122            return false; 
     123        }else{ 
     124            for(var i=0;i<this.length;i++){ 
     125                if(! mod.eq(this[i], a[i])){ 
     126                    return false; 
     127                } 
     128            } 
     129            return true; 
     130        } 
     131    }; 
     132     
     133    Array.prototype.__neq__ = function(a){ 
     134        if(this.length != a.length){ 
     135            return true; 
     136        }else{ 
     137            for(var i=0;i<this.length;i++){ 
     138                if(mod.neq(this[i], a[i])){ 
     139                    return true; 
     140                } 
     141            } 
     142            return false; 
     143        } 
     144    }; 
     145     
    119146    mod.__main__=function(){ 
    120147 
  • trunk/jsolait/lib/testing.js

    r47 r51  
    168168 
    169169        if(value!==true){ 
    170             throw new mod.AssertFailed(comment, failMsg===undefined ? "Expected true but found: %s".format(value) : failMsg); 
     170            throw new mod.AssertFailed(comment, failMsg===undefined ? "Expected true but found: %s".format(repr(value)) : failMsg); 
    171171        } 
    172172    }; 
     
    182182            comment =''; 
    183183        } 
    184         mod.assert(comment, value===true, "Expected true but found: %s".format(value)); 
     184        mod.assert(comment, value===true, "Expected true but found: %s".format(repr(value))); 
    185185    }; 
    186186 
     
    195195            comment =''; 
    196196        } 
    197         mod.assert(comment, value===false, "Expected false but found: %s".format(value)); 
     197        mod.assert(comment, value===false, "Expected false but found: %s".format(repr(value))); 
    198198    }; 
    199199 
     
    209209            comment =''; 
    210210        } 
    211         mod.assert(comment, ops.eq(value1, value2), "Expected %s == %s.".format(value1, value2)); 
     211        mod.assert(comment, ops.eq(value1, value2), "Expected %s === %s.".format(repr(value1), repr(value2))); 
    212212    }; 
    213213         
     
    218218            comment =''; 
    219219        } 
    220         mod.assert(comment, ops.ne(value1, value2), "Expected %s != %s.".format(value1, value2)); 
     220        mod.assert(comment, ops.ne(value1, value2), "Expected %s !== %s.".format(repr(value1), repr(value2))); 
    221221    }; 
    222222 
     
    227227            comment =''; 
    228228        } 
    229         mod.assert(comment, ops.is(value1, value2), "Expected %s === %s.".format(value1, value2)); 
     229        mod.assert(comment, ops.is(value1, value2), "Expected %s === %s.".format(repr(value1), repr(value2))); 
    230230    }; 
    231231         
     
    236236            comment =''; 
    237237        } 
    238         mod.assert(comment, ops.isnot(value1, value2), "Expected %s !== %s.".format(value1, value2)); 
     238        mod.assert(comment, ops.isnot(value1, value2), "Expected %s !== %s.".format(repr(value1), repr(value2))); 
    239239    }; 
    240240     
     
    244244            comment =''; 
    245245        } 
    246         mod.assert(comment, value===null, "Expected %s === null.".format(value)); 
     246        mod.assert(comment, value===null, "Expected %s === null.".format(repr(value))); 
    247247    }; 
    248248 
     
    252252            comment =''; 
    253253        } 
    254         mod.assert(comment, value !==null, "Expected %s !== null.".format(value)); 
     254        mod.assert(comment, value !==null, "Expected %s !== null.".format(repr(value))); 
    255255    }; 
    256256 
     
    260260            comment =''; 
    261261        } 
    262         mod.assert(comment, value===undefined, "Expected %s === undefined.".format(value)); 
     262        mod.assert(comment, value===undefined, "Expected %s === undefined.".format(repr(value))); 
    263263    }; 
    264264 
     
    268268            comment =''; 
    269269        } 
    270         mod.assert(comment, value!==undefined, "Expected %s !== undefined".format(value)); 
     270        mod.assert(comment, value!==undefined, "Expected %s !== undefined".format(repr(value))); 
    271271    }; 
    272272 
     
    276276            comment =''; 
    277277        } 
    278         mod.assert(comment, isNaN(value)===true, "Expected %s === NaN.".format(value)); 
     278        mod.assert(comment, isNaN(value)===true, "Expected %s === NaN.".format(repr(value))); 
    279279    }; 
    280280 
     
    284284            comment =''; 
    285285        } 
    286         mod.assert(comment, isNaN(value)!==true, "Expected %s !== NaN".format(value)); 
     286        mod.assert(comment, isNaN(value)!==true, "Expected %s !== NaN".format(repr(value))); 
    287287    }; 
    288288