Path: blob/aarch64-shenandoah-jdk8u272-b10/nashorn/test/script/trusted/JDK-8032060.js
32284 views
/*1* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* JDK-8032060: PropertyMap of Error objects is not stable25*26* @test27* @option -Dnashorn.debug=true28* @fork29* @run30*/3132function checkMap(e1, e2) {33if (! Debug.identical(Debug.map(e1), Debug.map(e2))) {34fail("e1 and e2 have different maps");35}3637var m1, m2;3839try {40throw e141} catch (e) {42m1 = Debug.map(e)43}4445try {46throw e247} catch (e) {48m2 = Debug.map(e)49}5051if (! Debug.identical(m1, m2)) {52fail("e1 and e2 have different maps after being thrown");53}54}5556checkMap(new Error(), new Error());57checkMap(new EvalError(), new EvalError());58checkMap(new RangeError(), new RangeError());59checkMap(new ReferenceError(), new ReferenceError());60checkMap(new SyntaxError(), new SyntaxError());61checkMap(new TypeError(), new TypeError());62checkMap(new URIError(), new URIError());6364// now try with message param65checkMap(new Error("x"), new Error("y"));66checkMap(new EvalError("x"), new EvalError("y"));67checkMap(new RangeError("x"), new RangeError("y"));68checkMap(new ReferenceError("x"), new ReferenceError("y"));69checkMap(new SyntaxError("x"), new SyntaxError("y"));70checkMap(new TypeError("x"), new TypeError("y"));71checkMap(new URIError("x"), new URIError("y"));727374