Skip to content

Commit

Permalink
Agrego opts.duckTyping
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoefe committed Nov 1, 2016
1 parent 697da14 commit 84d1d62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/discrepances.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function isSimpleValue(classType) {
}

discrepances = function discrepances(a, b, opts){
opts = changing({unordered:true}, opts||{});
opts = changing({unordered:true, duckTyping:false}, opts||{});
if(a === b){ return null; }
var typeA = getType(a);
var typeB = getType(b);
Expand All @@ -173,7 +173,7 @@ discrepances = function discrepances(a, b, opts){
var r = {classes:[classA,classB]};
if(isSimpleValue(classA) && isSimpleValue(classB)) { r.values=[a,b]; }
return r;
} else if(a.constructor !== b.constructor) {
} else if(!opts.duckTyping && a.constructor !== b.constructor) {
return {classes:[constructorName(a),constructorName(b)]};
} else {
switch(classA) {
Expand Down
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ describe("discrepances", function(){
},
opts:{unordered:false}
},
{a: new Example({uno:1}) , b: {uno:1} , expect: null, opts:{duckTyping:true} },
];
// esto es para evitar que values:[] tenga fechas distintas a 'a' y 'b'
var dateFixtures = [
Expand Down

0 comments on commit 84d1d62

Please sign in to comment.