Thu, 20 Nov 2014 11:27:48 -0800
Merge
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/script/basic/JDK-8049407-big-endian.js Thu Nov 20 11:27:48 2014 -0800 1.3 @@ -0,0 +1,33 @@ 1.4 +/* 1.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + */ 1.26 + 1.27 +/** 1.28 + * Verify DataView behavior with little/big endian 1.29 + * 1.30 + * @test 1.31 + * @run 1.32 + * @bigendian 1.33 + */ 1.34 + 1.35 +var dir = typeof(__DIR__) == 'undefined' ? "test/script/basic/" : __DIR__; 1.36 +load(dir + "JDK-8049407-payload.js");
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/script/basic/JDK-8049407-big-endian.js.EXPECTED Thu Nov 20 11:27:48 2014 -0800 2.3 @@ -0,0 +1,1 @@ 2.4 +false
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/script/basic/JDK-8049407-payload.js Thu Nov 20 11:27:48 2014 -0800 3.3 @@ -0,0 +1,37 @@ 3.4 +/* 3.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.23 + * or visit www.oracle.com if you need additional information or have any 3.24 + * questions. 3.25 + */ 3.26 + 3.27 +/** 3.28 + * Verify DataView behavior with little/big endian 3.29 + * 3.30 + * @subtest 3.31 + * @run 3.32 + */ 3.33 + 3.34 +var littleEndian = (function() { 3.35 + var buffer = new ArrayBuffer(2); 3.36 + new DataView(buffer).setInt16(0, 256, true); 3.37 + return new Int16Array(buffer)[0] === 256; 3.38 + })(); 3.39 + 3.40 +print(littleEndian);
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/test/script/basic/JDK-8049407.js Thu Nov 20 11:27:48 2014 -0800 4.3 @@ -0,0 +1,33 @@ 4.4 +/* 4.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. 4.11 + * 4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.15 + * version 2 for more details (a copy is included in the LICENSE file that 4.16 + * accompanied this code). 4.17 + * 4.18 + * You should have received a copy of the GNU General Public License version 4.19 + * 2 along with this work; if not, write to the Free Software Foundation, 4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.21 + * 4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4.23 + * or visit www.oracle.com if you need additional information or have any 4.24 + * questions. 4.25 + */ 4.26 + 4.27 +/** 4.28 + * Verify DataView behavior with little/big endian 4.29 + * 4.30 + * @test 4.31 + * @run 4.32 + * @littleendian 4.33 + */ 4.34 + 4.35 +var dir = typeof(__DIR__) == 'undefined' ? "test/script/basic/" : __DIR__; 4.36 +load(dir + "JDK-8049407-payload.js");
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/test/script/basic/JDK-8049407.js.EXPECTED Thu Nov 20 11:27:48 2014 -0800 5.3 @@ -0,0 +1,1 @@ 5.4 +true
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/test/script/basic/NASHORN-377-big-endian.js Thu Nov 20 11:27:48 2014 -0800 6.3 @@ -0,0 +1,33 @@ 6.4 +/* 6.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.7 + * 6.8 + * This code is free software; you can redistribute it and/or modify it 6.9 + * under the terms of the GNU General Public License version 2 only, as 6.10 + * published by the Free Software Foundation. 6.11 + * 6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6.15 + * version 2 for more details (a copy is included in the LICENSE file that 6.16 + * accompanied this code). 6.17 + * 6.18 + * You should have received a copy of the GNU General Public License version 6.19 + * 2 along with this work; if not, write to the Free Software Foundation, 6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6.21 + * 6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 6.23 + * or visit www.oracle.com if you need additional information or have any 6.24 + * questions. 6.25 + */ 6.26 + 6.27 +/* 6.28 + * NASHORN-377: Typed arrays. 6.29 + * 6.30 + * @test 6.31 + * @run 6.32 + * @bigendian 6.33 + */ 6.34 + 6.35 +var dir = typeof(__DIR__) == 'undefined' ? "test/script/basic/" : __DIR__; 6.36 +load(dir + "NASHORN-377-payload.js");
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/test/script/basic/NASHORN-377-big-endian.js.EXPECTED Thu Nov 20 11:27:48 2014 -0800 7.3 @@ -0,0 +1,34 @@ 7.4 +8 8 true undefined 7.5 +[object ArrayBuffer] [object ArrayBuffer] [object Int8Array] 7.6 +0 8 8 1 7.7 +0 8 8 1 7.8 +0 8 8 1 7.9 +0 8 4 2 7.10 +0 8 4 2 7.11 +0 8 2 4 7.12 +0 8 2 4 7.13 +0 8 2 4 7.14 +0 8 1 8 7.15 +7071727374-807677 7071727374807677 7.16 +727374-807677 2 6 7.17 +72737480 2 4 7.18 +71727374 1 4 7.19 +717273748076 7.20 +7071727374807677 1886483059 1954575991 7.21 +70717273-1020305 1886483059 -16909061 7.22 +70717273fefdfcfb 1886483059 4278058235 7.23 +40490fdafefdfcfb 2 7.24 +400921fb4d12d84a 1 7.25 +400921fb4d12d84a 1074340347 1293080650 7.26 +00000000400921fb4d12d84a 7.27 +400921fb4d12-27b6 400921fb4d12d84a 7.28 +00-100804d12-27b6 ffff00804d12d84a 7.29 +0 1 2 3 4 5 6 7 7.30 +0102030405060708 7.31 +subarray(2,4)=0304 subarray(-6,-4)=0304 7.32 +010203040506 7.33 +03040506 0405 7.34 +0102030405060708090a0b0c0d0e0f10 7.35 +slice(4,8)=05060708 slice(-8,-4)=090a0b0c 7.36 +0102030405060708090a0b0c 7.37 +060708090a0b
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/script/basic/NASHORN-377-payload.js Thu Nov 20 11:27:48 2014 -0800 8.3 @@ -0,0 +1,226 @@ 8.4 +/* 8.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 + * 8.8 + * This code is free software; you can redistribute it and/or modify it 8.9 + * under the terms of the GNU General Public License version 2 only, as 8.10 + * published by the Free Software Foundation. 8.11 + * 8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.15 + * version 2 for more details (a copy is included in the LICENSE file that 8.16 + * accompanied this code). 8.17 + * 8.18 + * You should have received a copy of the GNU General Public License version 8.19 + * 2 along with this work; if not, write to the Free Software Foundation, 8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.21 + * 8.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 8.23 + * or visit www.oracle.com if you need additional information or have any 8.24 + * questions. 8.25 + */ 8.26 + 8.27 +/* 8.28 + * NASHORN-377: Typed arrays. Payload for litte and big endian platforms. 8.29 + * 8.30 + * @subtest 8.31 + * @run 8.32 + */ 8.33 + 8.34 +var types = [Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array]; 8.35 + 8.36 +//--------------------------------------------------------------------------- 8.37 +// utility functions 8.38 +//--------------------------------------------------------------------------- 8.39 +function tohex(d, w) { 8.40 + var hex = Number(d).toString(16); 8.41 + var pad = (w ? w : 8) - hex.length; 8.42 + hex = "00000000".substr(0, pad) + hex; 8.43 + return hex; 8.44 +} 8.45 + 8.46 +function arrstr(a, n, w) { 8.47 + var s = ""; 8.48 + if (typeof n == "undefined") n = a.length; 8.49 + if (typeof w == "undefined") w = a.constructor.BYTES_PER_ELEMENT * 2; 8.50 + for (var i = 0; i < n; i++) { 8.51 + s += tohex(a[i], w); 8.52 + } 8.53 + return s; 8.54 +} 8.55 +function bufstr(b) { 8.56 + if (b.buffer !== undefined) { 8.57 + b = b.buffer; 8.58 + } 8.59 + return arrstr(new Uint8Array(b)); 8.60 +} 8.61 + 8.62 +function assertFail(f) { 8.63 + try { 8.64 + f(); 8.65 + } catch (e) { 8.66 + //print(e); 8.67 + return; 8.68 + } 8.69 + throw "assertion failed: expected exception"; 8.70 +} 8.71 + 8.72 +function assertTrue(f) { 8.73 + if (f() !== true) throw "assertion failed: " + f; 8.74 +} 8.75 + 8.76 +function isUndefined(x) { 8.77 + return typeof x === "undefined"; 8.78 +} 8.79 + 8.80 +function fillArray(a, start) { 8.81 + if (typeof start == "undefined") start = 1; 8.82 + for (var i = 0; i < a.length; i++) { 8.83 + a[i] = i + start; 8.84 + } 8.85 + return a; 8.86 +} 8.87 + 8.88 +//--------------------------------------------------------------------------- 8.89 +// tests 8.90 +//--------------------------------------------------------------------------- 8.91 +(function() { 8.92 + var b = new ArrayBuffer(8); 8.93 + var i8 = new Int8Array(b); 8.94 + print(i8.buffer.byteLength, b.byteLength, i8.buffer === b, b.length); 8.95 + print(b, i8.buffer, i8); 8.96 +})(); 8.97 + 8.98 +(function test_attributes() { 8.99 + var b = new ArrayBuffer(8); 8.100 + for (var i in types) { 8.101 + var x = new types[i](b); 8.102 + print(x.byteOffset, x.byteLength, x.length, x.constructor.BYTES_PER_ELEMENT); 8.103 + assertTrue(function(){ return x.constructor === types[i] }); 8.104 + } 8.105 +})(); 8.106 + 8.107 +(function() { 8.108 + var b = new ArrayBuffer(8); 8.109 + var i8 = new Int8Array(b); 8.110 + fillArray(i8, 0x70); 8.111 + 8.112 + var i8_2 = new Int8Array(b, 2); 8.113 + var i8_2_4 = new Uint8Array(b, 2, 4); 8.114 + 8.115 + i8_2_4[3] = 0x80; 8.116 + 8.117 + print(arrstr(i8, 8, 2) + " " + bufstr(i8)); 8.118 + print(arrstr(i8_2, 6) + " " + i8_2.byteOffset + " " + i8_2.byteLength); 8.119 + print(arrstr(i8_2_4, 4) + " " + i8_2_4.byteOffset + " " + i8_2_4.byteLength); 8.120 + 8.121 + var i8_1_5 = i8.subarray(1, 5); 8.122 + i8_2_4.subarray(1, 5); 8.123 + print(arrstr(i8_1_5, 4) + " " + i8_1_5.byteOffset + " " + i8_1_5.byteLength); 8.124 + 8.125 + print(bufstr(b.slice(1,7))); 8.126 +})(); 8.127 + 8.128 +(function() { 8.129 + var b = new ArrayBuffer(8); 8.130 + fillArray(new Int8Array(b), 0x70); 8.131 + new Int8Array(b)[5] = 0x80; 8.132 + 8.133 + var i32 = new Int32Array(b); 8.134 + var u32 = new Uint32Array(b); 8.135 + print(arrstr(i32), i32[0], i32[1]); 8.136 + i32[1] = 0xfefdfcfb; 8.137 + print(arrstr(i32), i32[0], i32[1]); 8.138 + print(arrstr(u32), u32[0], u32[1]); 8.139 + 8.140 + var pi = 3.1415926; 8.141 + var f32 = new Float32Array(b); 8.142 + var f64 = new Float64Array(b); 8.143 + f32[0] = pi; 8.144 + print(bufstr(b), f32.length); 8.145 + f64[0] = pi; 8.146 + print(bufstr(b), f64.length); 8.147 + print(arrstr(u32), u32[0], u32[1]); 8.148 + 8.149 + var d = new Int32Array(3); 8.150 + d.set(i32,1); 8.151 + print(bufstr(d)); 8.152 + 8.153 + var s = new Int16Array(b); 8.154 + var t = new Uint16Array(b); 8.155 + print(arrstr(s), arrstr(t)); 8.156 + s[0] = -1; s[1] = 0x80; 8.157 + print(arrstr(s), arrstr(t)); 8.158 +})(); 8.159 + 8.160 +(function enumerate_properties() { 8.161 + var i8 = new Int8Array(new ArrayBuffer(8)); 8.162 + var s = ""; for (var i in i8) { s += i + " "; } print(s.trim()); 8.163 +})(); 8.164 + 8.165 +// check that ScriptObject fallback is still working 8.166 +// DISABLED because correct behavior is unclear 8.167 +(function() { 8.168 + // NB: firefox will never set any out-of-bounds or non-array values although it does get both from prototype. 8.169 + var z = new Uint8Array(4); 8.170 + z["asdf"] = "asdf"; print(z["asdf"]); 8.171 + z[0x100000000] = "asdf"; print(z[0x100000000]); 8.172 + z[-1] = "asdf"; print(z[-1]); 8.173 + 8.174 + // v8 and nashorn disagree on out-of-bounds uint32 indices: v8 won't go to the prototype. 8.175 + z[0xf0000000] = "asdf"; print(z[0xf0000000]); 8.176 + z[0xffffffff] = "asdf"; print(z[0xffffffff]); 8.177 + z[0x70000000] = "asdf"; print(z[0x70000000]); 8.178 + 8.179 + // this will work in firefox and nashorn (not in v8). 8.180 + Uint8Array.prototype[4] = "asdf"; print(z[4]); 8.181 +}); 8.182 + 8.183 +(function test_exceptions() { 8.184 + assertFail(function() { new Int32Array(new ArrayBuffer(7)); }); 8.185 + assertFail(function() { new Int32Array(new ArrayBuffer(8), 0, 4); }); 8.186 + assertFail(function() { new Int32Array(new ArrayBuffer(8),-1, 2); }); 8.187 + assertFail(function() { new Int32Array(new ArrayBuffer(8), 0,-1); }); 8.188 +})(); 8.189 + 8.190 +(function test_subarray() { 8.191 + var x = fillArray(new Int8Array(8)); 8.192 + print(arrstr(x)); 8.193 + print("subarray(2,4)=" + arrstr(x.subarray(2, 4)), "subarray(-6,-4)=" + arrstr(x.subarray(-6, -4))); // negative index refers from the end of the array 8.194 + print(arrstr(x.subarray(-10, -2))); // negative index clamped to 0 8.195 + assertTrue(function(){ return arrstr(x.subarray(6, 4)) === ""; }); // negative length clamped to 0 8.196 + print(arrstr(x.subarray(1,-1).subarray(1,-1)), arrstr(x.subarray(1,-1).subarray(1,-1).subarray(1,-1))); // subarray of subarray 8.197 +})(); 8.198 + 8.199 +(function test_slice() { 8.200 + var b = new ArrayBuffer(16); 8.201 + fillArray(new Int8Array(b)); 8.202 + print(bufstr(b)); 8.203 + print("slice(4,8)=" + bufstr(b.slice(4, 8)), "slice(-8,-4)=" + bufstr(b.slice(-8, -4))); // negative index refers from the end of the array 8.204 + print(bufstr(b.slice(-20, -4))); // negative index clamped to 0 8.205 + assertTrue(function(){ return bufstr(b.slice(8, 4)) === ""; }); // negative length clamped to 0 8.206 + print(arrstr(new Int16Array(b.slice(1,-1).slice(2,-1).slice(1,-2).slice(1,-1)))); // slice of slice 8.207 +})(); 8.208 + 8.209 +(function test_clamped() { 8.210 + var a = new Uint8ClampedArray(10); 8.211 + a[0] = -17; // clamped to 0 8.212 + a[1] = 4711; // clamped to 255 8.213 + a[2] = 17.5; // clamped to 18 8.214 + a[3] = 16.5; // clamped to 16 8.215 + a[4] = 255.9; // clamped to 255 8.216 + a[5] = Infinity; // clamped to 255 8.217 + a[6] = -Infinity; // clamped to 0 8.218 + a[7] = NaN; // 0 8.219 + assertTrue(function(){ return a[0] === 0 && a[1] === 255 && a[2] === 18 && a[3] === 16 && a[4] === 255 && a[5] === 255 && a[6] === 0 && a[7] === 0; }); 8.220 +})(); 8.221 + 8.222 +(function test_out_of_bounds() { 8.223 + var a = new Int32Array(10); 8.224 + a[10] = 10; 8.225 + a[100] = 100; 8.226 + a[1000] = 1000; 8.227 + assertTrue(function(){ return isUndefined(a[10]) && isUndefined(a[11]) && isUndefined(a[100]) && isUndefined(a[123]) && isUndefined(a[1000]); }); 8.228 +})(); 8.229 +
9.1 --- a/test/script/basic/NASHORN-377.js Wed Nov 19 11:29:48 2014 -0800 9.2 +++ b/test/script/basic/NASHORN-377.js Thu Nov 20 11:27:48 2014 -0800 9.3 @@ -26,201 +26,8 @@ 9.4 * 9.5 * @test 9.6 * @run 9.7 + * @littleendian 9.8 */ 9.9 9.10 -var types = [Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array]; 9.11 - 9.12 -//--------------------------------------------------------------------------- 9.13 -// utility functions 9.14 -//--------------------------------------------------------------------------- 9.15 -function tohex(d, w) { 9.16 - var hex = Number(d).toString(16); 9.17 - var pad = (w ? w : 8) - hex.length; 9.18 - hex = "00000000".substr(0, pad) + hex; 9.19 - return hex; 9.20 -} 9.21 - 9.22 -function arrstr(a, n, w) { 9.23 - var s = ""; 9.24 - if (typeof n == "undefined") n = a.length; 9.25 - if (typeof w == "undefined") w = a.constructor.BYTES_PER_ELEMENT * 2; 9.26 - for (var i = 0; i < n; i++) { 9.27 - s += tohex(a[i], w); 9.28 - } 9.29 - return s; 9.30 -} 9.31 -function bufstr(b) { 9.32 - if (b.buffer !== undefined) { 9.33 - b = b.buffer; 9.34 - } 9.35 - return arrstr(new Uint8Array(b)); 9.36 -} 9.37 - 9.38 -function assertFail(f) { 9.39 - try { 9.40 - f(); 9.41 - } catch (e) { 9.42 - //print(e); 9.43 - return; 9.44 - } 9.45 - throw "assertion failed: expected exception"; 9.46 -} 9.47 - 9.48 -function assertTrue(f) { 9.49 - if (f() !== true) throw "assertion failed: " + f; 9.50 -} 9.51 - 9.52 -function isUndefined(x) { 9.53 - return typeof x === "undefined"; 9.54 -} 9.55 - 9.56 -function fillArray(a, start) { 9.57 - if (typeof start == "undefined") start = 1; 9.58 - for (var i = 0; i < a.length; i++) { 9.59 - a[i] = i + start; 9.60 - } 9.61 - return a; 9.62 -} 9.63 - 9.64 -//--------------------------------------------------------------------------- 9.65 -// tests 9.66 -//--------------------------------------------------------------------------- 9.67 -(function() { 9.68 - var b = new ArrayBuffer(8); 9.69 - var i8 = new Int8Array(b); 9.70 - print(i8.buffer.byteLength, b.byteLength, i8.buffer === b, b.length); 9.71 - print(b, i8.buffer, i8); 9.72 -})(); 9.73 - 9.74 -(function test_attributes() { 9.75 - var b = new ArrayBuffer(8); 9.76 - for (var i in types) { 9.77 - var x = new types[i](b); 9.78 - print(x.byteOffset, x.byteLength, x.length, x.constructor.BYTES_PER_ELEMENT); 9.79 - assertTrue(function(){ return x.constructor === types[i] }); 9.80 - } 9.81 -})(); 9.82 - 9.83 -(function() { 9.84 - var b = new ArrayBuffer(8); 9.85 - var i8 = new Int8Array(b); 9.86 - fillArray(i8, 0x70); 9.87 - 9.88 - var i8_2 = new Int8Array(b, 2); 9.89 - var i8_2_4 = new Uint8Array(b, 2, 4); 9.90 - 9.91 - i8_2_4[3] = 0x80; 9.92 - 9.93 - print(arrstr(i8, 8, 2) + " " + bufstr(i8)); 9.94 - print(arrstr(i8_2, 6) + " " + i8_2.byteOffset + " " + i8_2.byteLength); 9.95 - print(arrstr(i8_2_4, 4) + " " + i8_2_4.byteOffset + " " + i8_2_4.byteLength); 9.96 - 9.97 - var i8_1_5 = i8.subarray(1, 5); 9.98 - i8_2_4.subarray(1, 5); 9.99 - print(arrstr(i8_1_5, 4) + " " + i8_1_5.byteOffset + " " + i8_1_5.byteLength); 9.100 - 9.101 - print(bufstr(b.slice(1,7))); 9.102 -})(); 9.103 - 9.104 -(function() { 9.105 - var b = new ArrayBuffer(8); 9.106 - fillArray(new Int8Array(b), 0x70); 9.107 - new Int8Array(b)[5] = 0x80; 9.108 - 9.109 - var i32 = new Int32Array(b); 9.110 - var u32 = new Uint32Array(b); 9.111 - print(arrstr(i32), i32[0], i32[1]); 9.112 - i32[1] = 0xfefdfcfb; 9.113 - print(arrstr(i32), i32[0], i32[1]); 9.114 - print(arrstr(u32), u32[0], u32[1]); 9.115 - 9.116 - var pi = 3.1415926; 9.117 - var f32 = new Float32Array(b); 9.118 - var f64 = new Float64Array(b); 9.119 - f32[0] = pi; 9.120 - print(bufstr(b), f32.length); 9.121 - f64[0] = pi; 9.122 - print(bufstr(b), f64.length); 9.123 - print(arrstr(u32), u32[0], u32[1]); 9.124 - 9.125 - var d = new Int32Array(3); 9.126 - d.set(i32,1); 9.127 - print(bufstr(d)); 9.128 - 9.129 - var s = new Int16Array(b); 9.130 - var t = new Uint16Array(b); 9.131 - print(arrstr(s), arrstr(t)); 9.132 - s[0] = -1; s[1] = 0x80; 9.133 - print(arrstr(s), arrstr(t)); 9.134 -})(); 9.135 - 9.136 -(function enumerate_properties() { 9.137 - var i8 = new Int8Array(new ArrayBuffer(8)); 9.138 - var s = ""; for (var i in i8) { s += i + " "; } print(s.trim()); 9.139 -})(); 9.140 - 9.141 -// check that ScriptObject fallback is still working 9.142 -// DISABLED because correct behavior is unclear 9.143 -(function() { 9.144 - // NB: firefox will never set any out-of-bounds or non-array values although it does get both from prototype. 9.145 - var z = new Uint8Array(4); 9.146 - z["asdf"] = "asdf"; print(z["asdf"]); 9.147 - z[0x100000000] = "asdf"; print(z[0x100000000]); 9.148 - z[-1] = "asdf"; print(z[-1]); 9.149 - 9.150 - // v8 and nashorn disagree on out-of-bounds uint32 indices: v8 won't go to the prototype. 9.151 - z[0xf0000000] = "asdf"; print(z[0xf0000000]); 9.152 - z[0xffffffff] = "asdf"; print(z[0xffffffff]); 9.153 - z[0x70000000] = "asdf"; print(z[0x70000000]); 9.154 - 9.155 - // this will work in firefox and nashorn (not in v8). 9.156 - Uint8Array.prototype[4] = "asdf"; print(z[4]); 9.157 -}); 9.158 - 9.159 -(function test_exceptions() { 9.160 - assertFail(function() { new Int32Array(new ArrayBuffer(7)); }); 9.161 - assertFail(function() { new Int32Array(new ArrayBuffer(8), 0, 4); }); 9.162 - assertFail(function() { new Int32Array(new ArrayBuffer(8),-1, 2); }); 9.163 - assertFail(function() { new Int32Array(new ArrayBuffer(8), 0,-1); }); 9.164 -})(); 9.165 - 9.166 -(function test_subarray() { 9.167 - var x = fillArray(new Int8Array(8)); 9.168 - print(arrstr(x)); 9.169 - print("subarray(2,4)=" + arrstr(x.subarray(2, 4)), "subarray(-6,-4)=" + arrstr(x.subarray(-6, -4))); // negative index refers from the end of the array 9.170 - print(arrstr(x.subarray(-10, -2))); // negative index clamped to 0 9.171 - assertTrue(function(){ return arrstr(x.subarray(6, 4)) === ""; }); // negative length clamped to 0 9.172 - print(arrstr(x.subarray(1,-1).subarray(1,-1)), arrstr(x.subarray(1,-1).subarray(1,-1).subarray(1,-1))); // subarray of subarray 9.173 -})(); 9.174 - 9.175 -(function test_slice() { 9.176 - var b = new ArrayBuffer(16); 9.177 - fillArray(new Int8Array(b)); 9.178 - print(bufstr(b)); 9.179 - print("slice(4,8)=" + bufstr(b.slice(4, 8)), "slice(-8,-4)=" + bufstr(b.slice(-8, -4))); // negative index refers from the end of the array 9.180 - print(bufstr(b.slice(-20, -4))); // negative index clamped to 0 9.181 - assertTrue(function(){ return bufstr(b.slice(8, 4)) === ""; }); // negative length clamped to 0 9.182 - print(arrstr(new Int16Array(b.slice(1,-1).slice(2,-1).slice(1,-2).slice(1,-1)))); // slice of slice 9.183 -})(); 9.184 - 9.185 -(function test_clamped() { 9.186 - var a = new Uint8ClampedArray(10); 9.187 - a[0] = -17; // clamped to 0 9.188 - a[1] = 4711; // clamped to 255 9.189 - a[2] = 17.5; // clamped to 18 9.190 - a[3] = 16.5; // clamped to 16 9.191 - a[4] = 255.9; // clamped to 255 9.192 - a[5] = Infinity; // clamped to 255 9.193 - a[6] = -Infinity; // clamped to 0 9.194 - a[7] = NaN; // 0 9.195 - assertTrue(function(){ return a[0] === 0 && a[1] === 255 && a[2] === 18 && a[3] === 16 && a[4] === 255 && a[5] === 255 && a[6] === 0 && a[7] === 0; }); 9.196 -})(); 9.197 - 9.198 -(function test_out_of_bounds() { 9.199 - var a = new Int32Array(10); 9.200 - a[10] = 10; 9.201 - a[100] = 100; 9.202 - a[1000] = 1000; 9.203 - assertTrue(function(){ return isUndefined(a[10]) && isUndefined(a[11]) && isUndefined(a[100]) && isUndefined(a[123]) && isUndefined(a[1000]); }); 9.204 -})(); 9.205 - 9.206 +var dir = typeof(__DIR__) == 'undefined' ? "test/script/basic/" : __DIR__; 9.207 +load(dir + "NASHORN-377-payload.js");
10.1 --- a/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Wed Nov 19 11:29:48 2014 -0800 10.2 +++ b/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Thu Nov 20 11:27:48 2014 -0800 10.3 @@ -46,6 +46,7 @@ 10.4 import java.io.File; 10.5 import java.io.FileReader; 10.6 import java.io.IOException; 10.7 +import java.nio.ByteOrder; 10.8 import java.nio.file.FileSystem; 10.9 import java.nio.file.FileSystems; 10.10 import java.nio.file.FileVisitOption; 10.11 @@ -264,6 +265,12 @@ 10.12 isTest = false; 10.13 isNotTest = true; 10.14 break; 10.15 + case "@bigendian": 10.16 + shouldRun = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; 10.17 + break; 10.18 + case "@littleendian": 10.19 + shouldRun = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN; 10.20 + break; 10.21 case "@runif": { 10.22 final String prop = scanner.next(); 10.23 if (System.getProperty(prop) != null) {