NASHORN-164.js revision 2:da1e581c933b
1178479Sjb/*
2178479Sjb * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
3178479Sjb * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4178479Sjb *
5178479Sjb * This code is free software; you can redistribute it and/or modify it
6178479Sjb * under the terms of the GNU General Public License version 2 only, as
7178479Sjb * published by the Free Software Foundation.
8178479Sjb *
9178479Sjb * This code is distributed in the hope that it will be useful, but WITHOUT
10178479Sjb * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11178479Sjb * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12178479Sjb * version 2 for more details (a copy is included in the LICENSE file that
13178479Sjb * accompanied this code).
14178479Sjb *
15178479Sjb * You should have received a copy of the GNU General Public License version
16178479Sjb * 2 along with this work; if not, write to the Free Software Foundation,
17178479Sjb * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18178479Sjb *
19178479Sjb * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20178479Sjb * or visit www.oracle.com if you need additional information or have any
21178479Sjb * questions.
22178479Sjb */
23210767Srpaulo
24238558Spfg/**
25253725Spfg * NASHORN-164 :  JSON.stringify should serialize only own properties of an object (like Object.keys)
26178479Sjb *
27178479Sjb * @test
28178479Sjb * @run
29178479Sjb */
30178479Sjb
31178479Sjbvar obj2 = { bar: 'hello' };
32178479Sjbvar obj = Object.create(obj2);
33178479Sjbobj.foo = 22;
34178479Sjb
35178479Sjbif (JSON.stringify(obj) != '{"foo":22}') {
36178479Sjb    throw Error("expected '{\"foo\":22}' got " + JSON.stringify(obj));
37178479Sjb}
38178479Sjb