Debian Codegraph @

js/src/tests/test262/language/statements/for/S12.6.3_A1.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: |
6 The "for {;;}" for Statement with empty expressions is allowed and leads
7 to performing an infinite loop
8 es5id: 12.6.3_A1
9 description: Breaking an infinite loop by throwing exception
10 ---*/
11
12 var __in__for = 0;
13
14 //////////////////////////////////////////////////////////////////////////////
15 //CHECK#1
16 try {
17 for (;;){
18 //__in__for++;
19 if(++__in__for>100)throw 1;
20 }
21 } catch (e) {
22 if (e !== 1) {
23 throw new Test262Error('#1: for {;;} is admitted and leads to infinite loop');
24 }
25 }
26 //
27 //////////////////////////////////////////////////////////////////////////////
28
29 //////////////////////////////////////////////////////////////////////////////
30 //CHECK#2
31 if (__in__for !== 101) {
32 throw new Test262Error('#2: __in__for === 101. Actual: __in__for ==='+ __in__for );
33 }
34 //
35 //////////////////////////////////////////////////////////////////////////////
36
37 reportCompare(0, 0);