summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/js/script-tests/array-iterate-backwards.js
blob: 56120d9832e1c3151f6a6ea60879cdcb4ed6df19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
description(
"This test checks that iterating a large array backwards works correctly."
);

var bytes = new Array();

function prepare(nbytes) {
    var i = nbytes - 1;
    while (i >= 0) {
        bytes[i] = new Number(i);
        i -= 1;
    }
}

function verify(nbytes) {
    var i = nbytes - 1;
    while (i >= 0) {
        if (bytes[i] != i)
            return false;
        i -= 1;
    }
    return true;
}

prepare(32768);
shouldBeTrue('verify(32768)');

prepare(65536);
shouldBeTrue('verify(65536)');

prepare(120000);
shouldBeTrue('verify(120000)');