Skip to content

Commit

Permalink
Pasan los tests para no-contenedores
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoefe committed Nov 14, 2016
1 parent 5bd4675 commit bbbd17e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 6 additions & 6 deletions lib/discrepances.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,6 @@ function compareFunctions(a, b, opts) {
return compareStrings(as, bs);
}

function isSimpleValue(classType) {
return ! classType.match(/^(array|object|regexp)$/i);
}

var defaultOpts = {
unordered:true,
duckTyping:false,
Expand All @@ -202,6 +198,10 @@ function getName(type, variable, clase) {
return type==='object' && variable.constructor ? constructorName(variable):clase;
}

function isNotContainerType(classType) {
return ! classType.match(/^(array|object)$/i);
}

discrepances = function discrepances(a, b, opts){
opts = changing(defaultOpts, opts||{});
if(a === b){ return null; }
Expand All @@ -225,7 +225,7 @@ discrepances = function discrepances(a, b, opts){
var nameB = getName(typeB,b,classB);
if(classA !== classB) {
var r = {classes:[nameA,nameB]};
if(isSimpleValue(classA) && isSimpleValue(classB)) {
if(isNotContainerType(classA) && isNotContainerType(classB)) {
r.values=[a,b];
}
return r;
Expand All @@ -237,7 +237,7 @@ discrepances = function discrepances(a, b, opts){
}
} else {
var r2={types:[typeA,typeB]};
if(isSimpleValue(typeA) && isSimpleValue(typeB)) {
if(isNotContainerType(typeA) && isNotContainerType(typeB)) {
r2.values = [a,b];
}
return r2;
Expand Down
4 changes: 1 addition & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ describe("discrepances", function(){
{a:4 , b:5 , expect:{difference:-1 , values:[4, 5]} },
{a:"4" , b:4 , expect:{types:['string', 'number'], values:["4", 4]} },
{a:null , b:0 , expect:{types:['null' , 'number'], values:[null, 0]} },
{a:fechaActual , b:/a/ , expect:{classes:['Date', 'RegExp'], values:[fechaActual, /a/]}
,skip: "los values sí van porque ambos son clases conocidas que no son contenedores"
},
{a:fechaActual , b:/a/ , expect:{classes:['Date', 'RegExp'], values:[fechaActual, /a/]} },
{a:[1,2,3,4,5] , b:[1,2,33,4,5,6] , expect:{array:{length:discrepances(5,6), 2:discrepances(3,33)}} },
{a:[1,2,3,4,5] , b:[1,2,3,4,5] , expect:null },
{a:{x:1, y:2} , b:{y:3, z:{zz:3}} ,
Expand Down

0 comments on commit bbbd17e

Please sign in to comment.