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",
"version": "1.5.7",
"version": "1.5.8",
"description": "experimental test runner....",
"main": "test.js",
"bin": {

32
test.js
View File

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