source: imaps-frontend/node_modules/fastest-stable-stringify/test/nested.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 630 bytes
Line 
1'use strict';
2
3var test = require('tape');
4var stringify = require('../');
5
6test('nested', function (t) {
7 t.plan(1);
8 var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
9 t.equal(stringify(obj), '{"a":3,"b":[{"x":4,"y":5,"z":6},7],"c":8}');
10});
11
12test('repeated non-cyclic value', function(t) {
13 t.plan(1);
14 var one = { x: 1 };
15 var two = { a: one, b: one };
16 t.equal(stringify(two), '{"a":{"x":1},"b":{"x":1}}');
17});
18
19test('acyclic but with reused obj-property pointers', function (t) {
20 t.plan(1);
21 var x = { a: 1 };
22 var y = { b: x, c: x };
23 t.equal(stringify(y), '{"b":{"a":1},"c":{"a":1}}');
24});
Note: See TracBrowser for help on using the repository browser.