mirror of
https://github.com/flynx/test.js.git
synced 2025-10-28 10:20:09 +00:00
rewrote arrayCmp(..)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
793c96bdc0
commit
3c47f6b85d
@ -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
32
test.js
@ -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...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user