test/script/basic/JDK-8079145.js

Tue, 28 Jul 2015 14:52:34 +0530

author
sundar
date
Tue, 28 Jul 2015 14:52:34 +0530
changeset 1482
58791cd01bc9
parent 1374
2937f5b9e985
permissions
-rw-r--r--

8132092: Nashorn copyright has to be updated
Reviewed-by: jlaskey, hannesw, mhaupt

sundar@1374 1 /*
sundar@1482 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
sundar@1374 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sundar@1482 4 *
sundar@1374 5 * This code is free software; you can redistribute it and/or modify it
sundar@1374 6 * under the terms of the GNU General Public License version 2 only, as
sundar@1374 7 * published by the Free Software Foundation.
sundar@1482 8 *
sundar@1374 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sundar@1374 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sundar@1374 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sundar@1374 12 * version 2 for more details (a copy is included in the LICENSE file that
sundar@1374 13 * accompanied this code).
sundar@1482 14 *
sundar@1374 15 * You should have received a copy of the GNU General Public License version
sundar@1374 16 * 2 along with this work; if not, write to the Free Software Foundation,
sundar@1374 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sundar@1482 18 *
sundar@1374 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sundar@1374 20 * or visit www.oracle.com if you need additional information or have any
sundar@1374 21 * questions.
sundar@1374 22 */
sundar@1374 23
sundar@1374 24 /**
sundar@1374 25 * JDK-8079145: jdk.nashorn.internal.runtime.arrays.IntArrayData.convert assertion
sundar@1374 26 *
sundar@1374 27 * @test
sundar@1374 28 * @fork
sundar@1374 29 * @option -Dnashorn.debug=true
sundar@1374 30 * @run
sundar@1374 31 */
sundar@1374 32
sundar@1374 33 var Byte = java.lang.Byte;
sundar@1374 34 var Short = java.lang.Short;
sundar@1374 35 var Integer = java.lang.Integer;
sundar@1374 36 var Long = java.lang.Long;
sundar@1374 37 var Float = java.lang.Float;
sundar@1374 38 var Double = java.lang.Double;
sundar@1374 39 var Character = java.lang.Character;
sundar@1374 40
sundar@1374 41 function checkWiden(arr, value, name) {
sundar@1374 42 switch (typeof value) {
sundar@1374 43 case 'object':
sundar@1374 44 case 'undefined':
sundar@1374 45 print(name + ": check widen for " + value);
sundar@1374 46 break;
sundar@1374 47 default:
sundar@1374 48 print(name + ": check widen for " + value +
sundar@1374 49 " [" + Debug.getClass(value) + "]");
sundar@1374 50 }
sundar@1374 51
sundar@1374 52 arr[0] = value;
sundar@1374 53 }
sundar@1374 54
sundar@1374 55 function checkIntWiden(value) {
sundar@1374 56 checkWiden([34], value, "int array");
sundar@1374 57 }
sundar@1374 58
sundar@1374 59 function checkLongWiden(value) {
sundar@1374 60 checkWiden([Integer.MAX_VALUE + 1], value, "long array");
sundar@1374 61 }
sundar@1374 62
sundar@1374 63 function checkNumberWiden(value) {
sundar@1374 64 checkWiden([Math.PI], value, "number array");
sundar@1374 65 }
sundar@1374 66
sundar@1374 67 function checkObjectWiden(value) {
sundar@1374 68 checkWiden([null], value, "object array");
sundar@1374 69 }
sundar@1374 70
sundar@1374 71 var values = [{}, null, undefined, false, true, new Byte(34),
sundar@1374 72 new Integer(344454), new Long(454545), new Long(Integer.MAX_VALUE + 1),
sundar@1374 73 new Float(34.3), new Double(Math.PI), new Character('s')];
sundar@1374 74
sundar@1374 75 for each (var v in values) {
sundar@1374 76 checkIntWiden(v);
sundar@1374 77 }
sundar@1374 78
sundar@1374 79 for each (var v in values) {
sundar@1374 80 checkLongWiden(v);
sundar@1374 81 }
sundar@1374 82
sundar@1374 83 for each (var v in values) {
sundar@1374 84 checkNumberWiden(v);
sundar@1374 85 }
sundar@1374 86
sundar@1374 87 for each (var v in values) {
sundar@1374 88 checkObjectWiden(v);
sundar@1374 89 }

mercurial