Debian Codegraph @

rhino/testsrc/tests/js1_6/Array/regress-386030.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 var gTestfile = 'regress-386030.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 386030;
9 var summary = 'Array.reduce should ignore holes';
10 var actual = '';
11 var expect = '';
12
13
14 //-----------------------------------------------------------------------------
15 test();
16 //-----------------------------------------------------------------------------
17
18 function test()
19 {
20 enterFunc ('test');
21 printBugNumber(BUGNUMBER);
22 printStatus (summary);
23
24 function add(a, b) { return a + b; }
25 function testreduce(v) { return v == 3 ? "PASS" : "FAIL"; }
26
27 expect = 'PASS';
28
29 try {
30 a = new Array(2);
31 a[1] = 3;
32 actual = testreduce(a.reduce(add));
33 } catch (e) {
34 actual = "FAIL, reduce";
35 }
36 reportCompare(expect, actual, summary + ': 1');
37
38 try {
39 a = new Array(2);
40 a[0] = 3;
41 actual = testreduce(a.reduceRight(add));
42 } catch (e) {
43 actual = "FAIL, reduceRight";
44 }
45 reportCompare(expect, actual, summary + ': 2');
46
47 try {
48 a = new Array(2);
49 a.reduce(add);
50 actual = "FAIL, empty reduce";
51 } catch (e) {
52 actual = "PASS";
53 }
54 reportCompare(expect, actual, summary + ': 3');
55
56 try {
57 a = new Array(2);
58 print(a.reduceRight(add));
59 actual = "FAIL, empty reduceRight";
60 } catch (e) {
61 actual = "PASS";
62 }
63 reportCompare(expect, actual, summary + ': 4');
64
65 exitFunc ('test');
66 }