PageRenderTime 16ms CodeModel.GetById 13ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/jit-test/tests/basic/testSwitch.js

http://github.com/zpao/v8monkey
JavaScript | 25 lines | 25 code | 0 blank | 0 comment | 2 complexity | bc8c4fe588e093ff962af01dff26e6b0 MD5 | raw file
 1function testSwitch() {
 2    var x = 0;
 3    var ret = 0;
 4    for (var i = 0; i < 100; ++i) {
 5        switch (x) {
 6            case 0:
 7                ret += 1;
 8                break;
 9            case 1:
10                ret += 2;
11                break;
12            case 2:
13                ret += 3;
14                break;
15            case 3:
16                ret += 4;
17                break;
18            default:
19                x = 0;
20        }
21        x++;
22    }
23    return ret;
24}
25assertEq(testSwitch(), 226);