NASHORN-187.js revision 6:5a1b0714df0e
1294336Sdes/*
2124208Sdes * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3124208Sdes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4124208Sdes *
5124208Sdes * This code is free software; you can redistribute it and/or modify it
6124208Sdes * under the terms of the GNU General Public License version 2 only, as
7124208Sdes * published by the Free Software Foundation.
8124208Sdes *
9124208Sdes * This code is distributed in the hope that it will be useful, but WITHOUT
10124208Sdes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11124208Sdes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12124208Sdes * version 2 for more details (a copy is included in the LICENSE file that
13124208Sdes * accompanied this code).
14124208Sdes *
15124208Sdes * You should have received a copy of the GNU General Public License version
16124208Sdes * 2 along with this work; if not, write to the Free Software Foundation,
17124208Sdes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18124208Sdes *
19124208Sdes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20124208Sdes * or visit www.oracle.com if you need additional information or have any
21124208Sdes * questions.
22124208Sdes */
23124208Sdes
24124208Sdes/**
25124208Sdes * NASHORN-187 :  Accessor property descriptor with undefined 'set' or 'get' property results in TypeError.
26124208Sdes *
27124208Sdes * @test
28124208Sdes * @run
29124208Sdes */
30124208Sdes
31124208Sdesvar obj = {};
32240075Sdes
33240075Sdestry {
34240075Sdes    Object.defineProperty(obj, "foo", {
35294328Sdes         get: function() { return 22; },
36294336Sdes         set: undefined
37124208Sdes    });
38124208Sdes} catch (e) {
39124208Sdes    fail("failed", e);
40240075Sdes}
41240075Sdes
42240075Sdestry {
43240075Sdes    Object.defineProperty(obj, "bar", {
44124208Sdes        get: undefined
45124208Sdes    });
46124208Sdes} catch (e) {
47124208Sdes    fail("failed", e);
48124208Sdes}
49126274Sdes