rewrote arrayCmp(..)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-01-05 05:43:01 +03:00
parent 793c96bdc0
commit 3c47f6b85d
2 changed files with 22 additions and 12 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-test", "name": "ig-test",
"version": "1.5.7", "version": "1.5.8",
"description": "experimental test runner....", "description": "experimental test runner....",
"main": "test.js", "main": "test.js",
"bin": { "bin": {

32
test.js
View File

@ -105,17 +105,27 @@ function(){
// compare two arrays by items... // compare two arrays by items...
// XXX this is defined in object.js/test.js and here, need to chose one... // XXX this is defined in object.js/test.js and here, need to chose one...
var arrayCmp = function(a, b){ var arrayCmp =
var ka = Object.keys(a) module.arrayCmp =
var kb = Object.keys(b) function(a, b){
return a === b if(a === b){
|| (a.length == b.length return true }
&& ka if(a.length != b.length){
// keep only non matching stuff... return false }
.filter(function(k){ // check elements...
return a[k] !== b[k] for(var [i, e] of Object.entries(a)){
&& a[k] != b[k] }) // XXX not sure how strict should we be here???
.length == 0) } //if(typeof(e) !== typeof(b[i])){
if(e.constructor !== b[i].constructor){
return false }
if(e instanceof Array){
if(arrayCmp(e, b[i])){
continue }
return false }
if(e !== b[i]
&& e != b[i]){
return false } }
return true }
// Assert constructor... // Assert constructor...