1b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik// Copyright 2010 the V8 project authors. All rights reserved.
2b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik// Redistribution and use in source and binary forms, with or without
3b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik// modification, are permitted provided that the following conditions are
4b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik// met:
5b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik//
6b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik//     * Redistributions of source code must retain the above copyright
7b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik//       notice, this list of conditions and the following disclaimer.
8b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik//     * Redistributions in binary form must reproduce the above
9b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik//       copyright notice, this list of conditions and the following
10b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik//       disclaimer in the documentation and/or other materials provided
11b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik//       with the distribution.
12b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik//     * Neither the name of Google Inc. nor the names of its
13b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik//       contributors may be used to endorse or promote products derived
14b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik//       from this software without specific prior written permission.
15b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik//
16b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzik// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20839f7f23c0a652e2b799345fc3112ae0c5a03098Saleem Abdulrasool// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2129180116e559ead2486c5cf6b4fefe8a6f6443fcNick Kledzik// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22839f7f23c0a652e2b799345fc3112ae0c5a03098Saleem Abdulrasool// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2329180116e559ead2486c5cf6b4fefe8a6f6443fcNick Kledzik// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24839f7f23c0a652e2b799345fc3112ae0c5a03098Saleem Abdulrasool// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25839f7f23c0a652e2b799345fc3112ae0c5a03098Saleem Abdulrasool// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26e45805f0d3f8dafef1297cc7dc49e610713f023bDan Albert// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27e45805f0d3f8dafef1297cc7dc49e610713f023bDan Albert
28e45805f0d3f8dafef1297cc7dc49e610713f023bDan Albert// Test that JSON.stringify correctly truncates floating point numbers.
29e45805f0d3f8dafef1297cc7dc49e610713f023bDan Albert// This test is based on chapter15/15.12/15.12.3/15.12.3-6-a-2.js in the
30e45805f0d3f8dafef1297cc7dc49e610713f023bDan Albert// ES5 conformance tests.
31e45805f0d3f8dafef1297cc7dc49e610713f023bDan Albert
32e45805f0d3f8dafef1297cc7dc49e610713f023bDan Albert// See: http://code.google.com/p/v8/issues/detail?id=753
33e45805f0d3f8dafef1297cc7dc49e610713f023bDan Albert
34b78da9875b6e35187b5d584746c78faaf3230a3dNick Kledzikvar obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
35b78da9875b6e35187b5d584746c78faaf3230a3dNick KledzikassertEquals(JSON.stringify(obj, null, 5.99999), JSON.stringify(obj, null, 5));
36e45805f0d3f8dafef1297cc7dc49e610713f023bDan Albert