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