js/src/jit-test/tests/parallel/Array-throws.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 load(libdir + "asserts.js");
michael@0 2
michael@0 3 function testArrayThrows() {
michael@0 4 // Test kernel not being callable.
michael@0 5 var a = [1,2,3,4,5,6,7,8];
michael@0 6 for (var [opName, args] in ["mapPar", [{}],
michael@0 7 "filterPar", [{}],
michael@0 8 "reducePar", [{}],
michael@0 9 "scanPar", [{}]])
michael@0 10 {
michael@0 11 assertThrowsInstanceOf(function () { a[opName].apply(a, args); }, TypeError);
michael@0 12 }
michael@0 13
michael@0 14 assertThrowsInstanceOf(function () {
michael@0 15 a.scatterPar(a, 0, {});
michael@0 16 }, TypeError);
michael@0 17
michael@0 18 assertThrowsInstanceOf(function () {
michael@0 19 Array.buildPar(1024, {});
michael@0 20 }, TypeError);
michael@0 21
michael@0 22 // Test bad lengths.
michael@0 23 assertThrowsInstanceOf(function () {
michael@0 24 Array.buildPar(0xffffffff + 1, function () {});
michael@0 25 }, RangeError);
michael@0 26
michael@0 27 assertThrowsInstanceOf(function () {
michael@0 28 a.scatterPar(a, 0, function () {}, 0xffffffff + 1);
michael@0 29 }, RangeError);
michael@0 30
michael@0 31 // Test empty reduction.
michael@0 32 for (var opName in ["reducePar", "scanPar"]) {
michael@0 33 assertThrowsInstanceOf(function () {
michael@0 34 var a = [];
michael@0 35 a[opName](function (v, p) { return v * p; });
michael@0 36 }, TypeError);
michael@0 37 }
michael@0 38
michael@0 39 // Test scatter:
michael@0 40 // - no conflict function.
michael@0 41 // - out of bounds
michael@0 42 var p = [1,2,3,4,5];
michael@0 43
michael@0 44 assertThrowsInstanceOf(function () {
michael@0 45 p.scatterPar([0,1,0,3,4]);
michael@0 46 }, Error);
michael@0 47
michael@0 48 assertThrowsInstanceOf(function () {
michael@0 49 p.scatterPar([0,1,0,3,11]);
michael@0 50 }, Error);
michael@0 51 }
michael@0 52
michael@0 53 if (getBuildConfiguration().parallelJS)
michael@0 54 testArrayThrows();

mercurial