www.reboot.components.bower_components.json5.test.stringify.js Maven / Gradle / Ivy
// tests stringify()
/*global require console exports */
// set to true to show performance stats
var DEBUG = false;
var assert = require('assert');
var JSON5 = require('../lib/json5');
// Test JSON5.stringify() by comparing its output for each case with
// native JSON.stringify(). The only differences will be in how object keys are
// handled.
var simpleCases = [
null,
9, -9, +9, +9.878,
'', "''", '999', '9aa', 'aaa', 'aa a', 'aa\na', 'aa\\a', '\'', '\\\'', '\\"',
undefined,
true, false,
{}, [], function(){},
Date.now(), new Date(Date.now())
];
exports.stringify = {};
exports.stringify.simple = function test() {
for (var i=0; i