Skip to content

Commit

Permalink
boolean test
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoefe committed Nov 8, 2016
1 parent 26902d0 commit 4c81918
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/discrepances.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ function getClassOnlyForSomeOfBuiltIns(variable) {
if(variable instanceof RegExp) { return 'RegExp'; }
if(variable instanceof Array) { return 'Array'; }
if(variable instanceof Object) { return 'Object'; }
throw new Error('undetected class type');
// console.log("SS", JSON.stringify(variable));
throw new Error('undetected class type:' + typeof variable);
}

function timeStr(dt) { return datetime(dt).toYmdHmsM().substr(11); }
Expand Down Expand Up @@ -166,6 +167,7 @@ var defaultOpts = {
discrepances = function discrepances(a, b, opts){
opts = changing(defaultOpts, opts||{});
if(a === b){ return null; }
// console.log("D", a, b, opts)
/*eslint-disable eqeqeq */
if(opts.autoTypeCast && a == b){ return null; }
/*eslint-enable eqeqeq */
Expand All @@ -174,6 +176,7 @@ discrepances = function discrepances(a, b, opts){
if(typeA === typeB) {
if(typeA === 'number') { return {difference:a-b, values:[a,b]}; }
if(typeA === 'string') { return compareStrings(a, b); }
if(typeA === 'boolean') { return {values:[a, b]}; }
if(typeA==='object' && typeB==='object') {
var classA = getClassOnlyForSomeOfBuiltIns(a);
var classB = getClassOnlyForSomeOfBuiltIns(b);
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe("discrepances", function(){
{a:76 , b:"76" , expect:discrepances(76, "76"), },
{skip:true, a:{a:7} , b:no , expect:null , opts:{duckTyping:true} },
{skip:true, a:{a:7} , b:no , expect:{classes:['Object', '#null__proto__']} },
{skip:true, a:false , b:true , expect:{values:[false, true]} },
{a:false , b:true , expect:{values:[false, true]} },
];
// esto es para evitar que values:[] tenga fechas distintas a 'a' y 'b'
var dateFixtures = [
Expand Down

0 comments on commit 4c81918

Please sign in to comment.