1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_6/Array/regress-386030.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* 1.6 + * Any copyright is dedicated to the Public Domain. 1.7 + * http://creativecommons.org/licenses/publicdomain/ 1.8 + * Contributor: Blake Kaplan 1.9 + */ 1.10 + 1.11 +//----------------------------------------------------------------------------- 1.12 +var BUGNUMBER = 386030; 1.13 +var summary = 'Array.reduce should ignore holes'; 1.14 +var actual = ''; 1.15 +var expect = ''; 1.16 + 1.17 + 1.18 +//----------------------------------------------------------------------------- 1.19 +test(); 1.20 +//----------------------------------------------------------------------------- 1.21 + 1.22 +function test() 1.23 +{ 1.24 + enterFunc ('test'); 1.25 + printBugNumber(BUGNUMBER); 1.26 + printStatus (summary); 1.27 + 1.28 + function add(a, b) { return a + b; } 1.29 + function testreduce(v) { return v == 3 ? "PASS" : "FAIL"; } 1.30 + 1.31 + expect = 'PASS'; 1.32 + 1.33 + try { 1.34 + a = new Array(2); 1.35 + a[1] = 3; 1.36 + actual = testreduce(a.reduce(add)); 1.37 + } catch (e) { 1.38 + actual = "FAIL, reduce"; 1.39 + } 1.40 + reportCompare(expect, actual, summary + ': 1'); 1.41 + 1.42 + try { 1.43 + a = new Array(2); 1.44 + a[0] = 3; 1.45 + actual = testreduce(a.reduceRight(add)); 1.46 + } catch (e) { 1.47 + actual = "FAIL, reduceRight"; 1.48 + } 1.49 + reportCompare(expect, actual, summary + ': 2'); 1.50 + 1.51 + try { 1.52 + a = new Array(2); 1.53 + a.reduce(add); 1.54 + actual = "FAIL, empty reduce"; 1.55 + } catch (e) { 1.56 + actual = "PASS"; 1.57 + } 1.58 + reportCompare(expect, actual, summary + ': 3'); 1.59 + 1.60 + try { 1.61 + a = new Array(2); 1.62 + print(a.reduceRight(add)); 1.63 + actual = "FAIL, empty reduceRight"; 1.64 + } catch (e) { 1.65 + actual = "PASS"; 1.66 + } 1.67 + reportCompare(expect, actual, summary + ': 4'); 1.68 + 1.69 + exitFunc ('test'); 1.70 +}