JDK-8030199.js revision 787:2127ddc06a35
1/*
2 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24/**
25 * JDK-8030199: Nashorn: Uint8ClampedArray - Incorrect ToUint8Clamp implementation
26 *
27 * @test
28 * @run
29 */
30
31function testTypedArray(ArrayType) {
32    print(ArrayType.BYTES_PER_ELEMENT);
33    var a = new ArrayType(7);
34    a[0] = 4294967296;
35    a[1] = -4294967295;
36    a[2] = 4294967298;
37    a[3] = -4294967298;
38    a[4] = Infinity;
39    a[5] = -Infinity;
40    a[6] = NaN;
41    print(Array.prototype.join.call(a));
42}
43
44testTypedArray(Uint8ClampedArray);
45testTypedArray(Uint8Array);
46testTypedArray(Int8Array);
47testTypedArray(Uint16Array);
48testTypedArray(Int16Array);
49testTypedArray(Uint32Array);
50testTypedArray(Int32Array);
51