18defd9ff6930b4e24729971a61cf7469daf119beSteve Block// Copyright 2010 the V8 project authors. All rights reserved.
28defd9ff6930b4e24729971a61cf7469daf119beSteve Block// Redistribution and use in source and binary forms, with or without
38defd9ff6930b4e24729971a61cf7469daf119beSteve Block// modification, are permitted provided that the following conditions are
48defd9ff6930b4e24729971a61cf7469daf119beSteve Block// met:
58defd9ff6930b4e24729971a61cf7469daf119beSteve Block//
68defd9ff6930b4e24729971a61cf7469daf119beSteve Block//     * Redistributions of source code must retain the above copyright
78defd9ff6930b4e24729971a61cf7469daf119beSteve Block//       notice, this list of conditions and the following disclaimer.
88defd9ff6930b4e24729971a61cf7469daf119beSteve Block//     * Redistributions in binary form must reproduce the above
98defd9ff6930b4e24729971a61cf7469daf119beSteve Block//       copyright notice, this list of conditions and the following
108defd9ff6930b4e24729971a61cf7469daf119beSteve Block//       disclaimer in the documentation and/or other materials provided
118defd9ff6930b4e24729971a61cf7469daf119beSteve Block//       with the distribution.
128defd9ff6930b4e24729971a61cf7469daf119beSteve Block//     * Neither the name of Google Inc. nor the names of its
138defd9ff6930b4e24729971a61cf7469daf119beSteve Block//       contributors may be used to endorse or promote products derived
148defd9ff6930b4e24729971a61cf7469daf119beSteve Block//       from this software without specific prior written permission.
158defd9ff6930b4e24729971a61cf7469daf119beSteve Block//
168defd9ff6930b4e24729971a61cf7469daf119beSteve Block// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
178defd9ff6930b4e24729971a61cf7469daf119beSteve Block// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
188defd9ff6930b4e24729971a61cf7469daf119beSteve Block// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
198defd9ff6930b4e24729971a61cf7469daf119beSteve Block// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
208defd9ff6930b4e24729971a61cf7469daf119beSteve Block// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
218defd9ff6930b4e24729971a61cf7469daf119beSteve Block// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
228defd9ff6930b4e24729971a61cf7469daf119beSteve Block// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
238defd9ff6930b4e24729971a61cf7469daf119beSteve Block// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
248defd9ff6930b4e24729971a61cf7469daf119beSteve Block// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
258defd9ff6930b4e24729971a61cf7469daf119beSteve Block// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
268defd9ff6930b4e24729971a61cf7469daf119beSteve Block// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
278defd9ff6930b4e24729971a61cf7469daf119beSteve Block
288defd9ff6930b4e24729971a61cf7469daf119beSteve Block// Test that JSON.stringify correctly truncates floating point numbers.
298defd9ff6930b4e24729971a61cf7469daf119beSteve Block// This test is based on chapter15/15.12/15.12.3/15.12.3-6-a-2.js in the
308defd9ff6930b4e24729971a61cf7469daf119beSteve Block// ES5 conformance tests.
318defd9ff6930b4e24729971a61cf7469daf119beSteve Block
328defd9ff6930b4e24729971a61cf7469daf119beSteve Block// See: http://code.google.com/p/v8/issues/detail?id=753
338defd9ff6930b4e24729971a61cf7469daf119beSteve Block
348defd9ff6930b4e24729971a61cf7469daf119beSteve Blockvar obj = {a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}},a2: 'a2'};
35b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochassertEquals(JSON.stringify(obj, null, 5.99999), JSON.stringify(obj, null, 5));
36