OLD | NEW |
| (Empty) |
1 1.0 Single Argument Testing | |
2 The following tests forEach with one argument, the callback. It should print the
contents of the array [2, 5, 9] alongside each index. | |
3 | |
4 [0] is 2 | |
5 [1] is 5 | |
6 [2] is 9 | |
7 | |
8 2.0 Two Argument Testing | |
9 The following tests forEach with two arguments, the callback and the applied "th
is" object. It should print the contents of the array. | |
10 | |
11 2 | |
12 5 | |
13 9 | |
14 | |
15 3.0 Array Mutation Tests | |
16 These tests the affects of array mutation during execution of forEach. | |
17 | |
18 3.1 Array Element Removal | |
19 This test removes elements from the array, these elements should thus not appear
since forEach doesn't iterate over non-existing properties. | |
20 | |
21 [0] is 2 | |
22 [1] is 5 | |
23 | |
24 3.2 Array Element Addition | |
25 This test adds elements to the array, these elements should not appear since for
Each uses the original length to create the range it iterates over. It should be
identical to 1.0. | |
26 | |
27 [0] is 2 | |
28 [1] is 5 | |
29 [2] is 9 | |
30 | |
31 3.3 Array Element Changing | |
32 This test changes elements in the array, these elements should appear in their m
utated form when reached by forEach. | |
33 | |
34 [0] is 2 | |
35 [1] is 5 | |
36 [2] is changed | |
37 | |
38 4.0 Exception Test | |
39 This test uses a function that throws an exception, and thus halts the execution
of forEach. | |
40 | |
41 [0] is 2 | |
42 [1] is 5 | |
43 Exception thrown, execution halted! | |
44 | |
45 5.0 Wrong Type for Callback Test This test sends in incorrect types for the call
back parameter of forEach. An exception should be thrown in each case. There sho
uld be 6 type errors (and no crashes!): | |
46 | |
47 TypeError: Type error | |
48 TypeError: Type error | |
49 TypeError: Type error | |
50 TypeError: Type error | |
51 TypeError: Type error | |
52 TypeError: Type error | |
53 | |
54 6.0 Behavior for Holes in Arrays | |
55 This test checks that holes in arrays (indexes which have been deleted or are no
t present) are not included in enumeration: | |
56 | |
57 Manually deleted index not enumerated | |
58 Array created using constructor has no properties, so no indexes enumerated | |
59 | |
60 7.0 Return Value | |
61 This test checks that the return value of Array.prototype.forEach is undefined: | |
62 | |
63 Return value is undefined! | |
64 | |
OLD | NEW |