NASHORN-221.js revision 877:cf4d2252d444
194742Sobrien/*
294742Sobrien * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
394742Sobrien * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
494742Sobrien *
594742Sobrien * This code is free software; you can redistribute it and/or modify it
694772Simp * under the terms of the GNU General Public License version 2 only, as
794772Simp * published by the Free Software Foundation.
894772Simp *
994844Srwatson * This code is distributed in the hope that it will be useful, but WITHOUT
1094772Simp * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1194742Sobrien * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1294778Simp * version 2 for more details (a copy is included in the LICENSE file that
1394778Simp * accompanied this code).
1494778Simp *
1594845Smarkm * You should have received a copy of the GNU General Public License version
1694845Smarkm * 2 along with this work; if not, write to the Free Software Foundation,
1794845Smarkm * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1894845Smarkm *
1994845Smarkm * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2094847Sjhb * or visit www.oracle.com if you need additional information or have any
2194847Sjhb * questions.
2294847Sjhb */
2394847Sjhb
2494847Sjhb/**
2594849Sphk * NASHORN-221 : Error and subtypes should not have "message" property if constructor was called without message argument
2694849Sphk *
2794849Sphk * @test
2894849Sphk * @run
2994849Sphk */
3094849Sphk
3194849Sphkfunction check(name) {
3294849Sphk    var e = new this[name]();
33    if (e.hasOwnProperty("message")) {
34        fail(name + " has 'message' property");
35    }
36
37    e = new this[name]("error!!");
38    if (! e.hasOwnProperty("message")) {
39        fail(name + " does not have 'message' property");
40    }
41}
42
43check("Error");
44check("EvalError");
45check("RangeError");
46check("ReferenceError");
47check("SyntaxError");
48check("TypeError");
49check("URIError");
50
51
52