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 |
|
---|
3 | var test = require('tape');
|
---|
4 | var stringify = require('../');
|
---|
5 |
|
---|
6 | test('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 |
|
---|
12 | test('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 |
|
---|
19 | test('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.