sundar@1374: /* sundar@1482: * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. sundar@1374: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sundar@1482: * sundar@1374: * This code is free software; you can redistribute it and/or modify it sundar@1374: * under the terms of the GNU General Public License version 2 only, as sundar@1374: * published by the Free Software Foundation. sundar@1482: * sundar@1374: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@1374: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@1374: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@1374: * version 2 for more details (a copy is included in the LICENSE file that sundar@1374: * accompanied this code). sundar@1482: * sundar@1374: * You should have received a copy of the GNU General Public License version sundar@1374: * 2 along with this work; if not, write to the Free Software Foundation, sundar@1374: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sundar@1482: * sundar@1374: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@1374: * or visit www.oracle.com if you need additional information or have any sundar@1374: * questions. sundar@1374: */ sundar@1374: sundar@1374: /** sundar@1374: * JDK-8079145: jdk.nashorn.internal.runtime.arrays.IntArrayData.convert assertion sundar@1374: * sundar@1374: * @test sundar@1374: * @fork sundar@1374: * @option -Dnashorn.debug=true sundar@1374: * @run sundar@1374: */ sundar@1374: sundar@1374: var Byte = java.lang.Byte; sundar@1374: var Short = java.lang.Short; sundar@1374: var Integer = java.lang.Integer; sundar@1374: var Long = java.lang.Long; sundar@1374: var Float = java.lang.Float; sundar@1374: var Double = java.lang.Double; sundar@1374: var Character = java.lang.Character; sundar@1374: sundar@1374: function checkWiden(arr, value, name) { sundar@1374: switch (typeof value) { sundar@1374: case 'object': sundar@1374: case 'undefined': sundar@1374: print(name + ": check widen for " + value); sundar@1374: break; sundar@1374: default: sundar@1374: print(name + ": check widen for " + value + sundar@1374: " [" + Debug.getClass(value) + "]"); sundar@1374: } sundar@1374: sundar@1374: arr[0] = value; sundar@1374: } sundar@1374: sundar@1374: function checkIntWiden(value) { sundar@1374: checkWiden([34], value, "int array"); sundar@1374: } sundar@1374: sundar@1374: function checkLongWiden(value) { sundar@1374: checkWiden([Integer.MAX_VALUE + 1], value, "long array"); sundar@1374: } sundar@1374: sundar@1374: function checkNumberWiden(value) { sundar@1374: checkWiden([Math.PI], value, "number array"); sundar@1374: } sundar@1374: sundar@1374: function checkObjectWiden(value) { sundar@1374: checkWiden([null], value, "object array"); sundar@1374: } sundar@1374: sundar@1374: var values = [{}, null, undefined, false, true, new Byte(34), sundar@1374: new Integer(344454), new Long(454545), new Long(Integer.MAX_VALUE + 1), sundar@1374: new Float(34.3), new Double(Math.PI), new Character('s')]; sundar@1374: sundar@1374: for each (var v in values) { sundar@1374: checkIntWiden(v); sundar@1374: } sundar@1374: sundar@1374: for each (var v in values) { sundar@1374: checkLongWiden(v); sundar@1374: } sundar@1374: sundar@1374: for each (var v in values) { sundar@1374: checkNumberWiden(v); sundar@1374: } sundar@1374: sundar@1374: for each (var v in values) { sundar@1374: checkObjectWiden(v); sundar@1374: }