1 var test = require('tape');
2 var stringify = require('../');
4 test('nested', function (t) {
6 var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
7 t.equal(stringify(obj), '{"a":3,"b":[{"x":4,"y":5,"z":6},7],"c":8}');
10 test('cyclic (default)', function (t) {
13 var two = { a: 2, one: one };
18 t.equal(ex.toString(), 'TypeError: Converting circular structure to JSON');
22 test('cyclic (specifically allowed)', function (t) {
25 var two = { a: 2, one: one };
27 t.equal(stringify(one, {cycles:true}), '{"a":1,"two":{"a":2,"one":"__cycle__"}}');
30 test('repeated non-cyclic value', function(t) {
33 var two = { a: one, b: one };
34 t.equal(stringify(two), '{"a":{"x":1},"b":{"x":1}}');