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 unwraps Boolean objects.
298defd9ff6930b4e24729971a61cf7469daf119beSteve Block
308defd9ff6930b4e24729971a61cf7469daf119beSteve Block// See: http://code.google.com/p/v8/issues/detail?id=752
318defd9ff6930b4e24729971a61cf7469daf119beSteve Block
328defd9ff6930b4e24729971a61cf7469daf119beSteve Blockfunction replacer(key, value) {
338defd9ff6930b4e24729971a61cf7469daf119beSteve Block  return value === 42 ? new Boolean(false) : value;
348defd9ff6930b4e24729971a61cf7469daf119beSteve Block}
358defd9ff6930b4e24729971a61cf7469daf119beSteve Block
363fb3ca8c7ca439d408449a395897395c0faae8d1Ben MurdochassertEquals("[false]", JSON.stringify([42], replacer));
37