我想测试我编写的nodejs模块的序列化函数。
在我的测试中,我有以下奇怪的行为:
assert.equal(JSON.stringify(obj1), JSON.stringify(obj2)); // => TEST OK
assert.deepEqual(obj1, obj2); // => TEST FAILS
我不知道这里出了什么问题。在我看来,这些物体看起来很相似。
OBJ1:
{
"config": {
"index_amount": 12,
"ignore_case": true,
"debug": false
},
"indexes": [{
"p": [0, 1],
"e": [0],
"t": [0],
"r": [0, 2],
"a": [1, 2],
"u": [1],
"l": [1],
"m": [2],
"i": [2]
}, {
"pe": [0],
"et": [0],
"te": [0],
"er": [0],
"pa": [1],
"au": [1],
"ul": [1],
"ma": [2],
"ar": [2],
"ri": [2],
"ia": [2]
}, {
"pet": [0],
"ete": [0],
"ter": [0],
"pau": [1],
"aul": [1],
"mar": [2],
"ari": [2],
"ria": [2]
}, {
"pete": [0],
"eter": [0],
"paul": [1],
"mari": [2],
"aria": [2]
}, {
"peter": [0],
"maria": [2]
}, {}, {}, {}, {}, {}, {}, {}],
"data": ["Peter", "Paul", "Maria"],
"data_ptr": 3,
"free_slots": [],
"single_data_counter": 3
}
OBJ2:
{
"config": {
"index_amount": 12,
"ignore_case": true,
"debug": false
},
"indexes": [{
"p": [0, 1],
"e": [0],
"t": [0],
"r": [0, 2],
"a": [1, 2],
"u": [1],
"l": [1],
"m": [2],
"i": [2]
}, {
"pe": [0],
"et": [0],
"te": [0],
"er": [0],
"pa": [1],
"au": [1],
"ul": [1],
"ma": [2],
"ar": [2],
"ri": [2],
"ia": [2]
}, {
"pet": [0],
"ete": [0],
"ter": [0],
"pau": [1],
"aul": [1],
"mar": [2],
"ari": [2],
"ria": [2]
}, {
"pete": [0],
"eter": [0],
"paul": [1],
"mari": [2],
"aria": [2]
}, {
"peter": [0],
"maria": [2]
}, {}, {}, {}, {}, {}, {}, {}],
"data": ["Peter", "Paul", "Maria"],
"data_ptr": 3,
"free_slots": [],
"single_data_counter": 3
}