Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jfseb committed Mar 10, 2017
1 parent f7aa90b commit 92da3cb
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion test/utils/circularser.nunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ exports.testCircular = function (test) {
/**
* Unit test for sth
*/
exports.testCircular2 = function (test) {
exports.testCircularSer = function (test) {
'use strict';
var a = { a : 1};
var b = { a: 2 };
Expand Down Expand Up @@ -84,5 +84,51 @@ exports.testCircular2 = function (test) {
test.equal(obj.circ === obj.circ[4],true,' 3 same cir ref');
test.deepEqual(obj.b1.exec('efAbbc')[1], 'bb',' regex ame cir ref');

test.done();
};






/**
* Unit test for sth
*/
exports.testCircularSerWrite = function (test) {
'use strict';
var a = { a : 1};
var b = { a: 2 };


var obj = {
arr : [a,a,b,{ a: 1}],
'b' : { a : a, b : {a: 1 } },
circ : [a, b],
b1 : /a(b+)c/gi
};

obj.circ[4] = obj.circ;

//console.log(JSON.stringify(obj.arr));
test.equal(obj.arr[0] == obj.arr[1],true,' 1 arr ref ok');
test.equal(obj.arr[0] !== obj.arr[3],true,' 2 same ref 2');
test.equal(obj.circ === obj.circ[4], true,' 3 same cir ref');
test.deepEqual(obj.b1.exec('efAbbc')[1], 'bb',' regex ame cir ref');

var res = CircularSer.load('abc.def');
test.deepEqual(res, undefined, 'nonexistent file');
CircularSer.save('tmp.json', obj);

obj = CircularSer.load('tmp.json');

//var s = CircularSer.stringify(obj);
//console.log(s + '\n');
//obj = CircularSer.parse(s);
test.equal(obj.arr[0] == obj.arr[1],true,' 1 arr ref ok');
test.equal(obj.arr[0] !== obj.arr[3],true,' 2 same ref 2');
test.equal(obj.circ === obj.circ[4],true,' 3 same cir ref');
test.deepEqual(obj.b1.exec('efAbbc')[1], 'bb',' regex ame cir ref');

test.done();
};

0 comments on commit 92da3cb

Please sign in to comment.