js/src/tests/js1_6/Array/regress-386030.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:ce625071af11
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * Any copyright is dedicated to the Public Domain.
4 * http://creativecommons.org/licenses/publicdomain/
5 * Contributor: Blake Kaplan
6 */
7
8 //-----------------------------------------------------------------------------
9 var BUGNUMBER = 386030;
10 var summary = 'Array.reduce should ignore holes';
11 var actual = '';
12 var expect = '';
13
14
15 //-----------------------------------------------------------------------------
16 test();
17 //-----------------------------------------------------------------------------
18
19 function test()
20 {
21 enterFunc ('test');
22 printBugNumber(BUGNUMBER);
23 printStatus (summary);
24
25 function add(a, b) { return a + b; }
26 function testreduce(v) { return v == 3 ? "PASS" : "FAIL"; }
27
28 expect = 'PASS';
29
30 try {
31 a = new Array(2);
32 a[1] = 3;
33 actual = testreduce(a.reduce(add));
34 } catch (e) {
35 actual = "FAIL, reduce";
36 }
37 reportCompare(expect, actual, summary + ': 1');
38
39 try {
40 a = new Array(2);
41 a[0] = 3;
42 actual = testreduce(a.reduceRight(add));
43 } catch (e) {
44 actual = "FAIL, reduceRight";
45 }
46 reportCompare(expect, actual, summary + ': 2');
47
48 try {
49 a = new Array(2);
50 a.reduce(add);
51 actual = "FAIL, empty reduce";
52 } catch (e) {
53 actual = "PASS";
54 }
55 reportCompare(expect, actual, summary + ': 3');
56
57 try {
58 a = new Array(2);
59 print(a.reduceRight(add));
60 actual = "FAIL, empty reduceRight";
61 } catch (e) {
62 actual = "PASS";
63 }
64 reportCompare(expect, actual, summary + ': 4');
65
66 exitFunc ('test');
67 }

mercurial