summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/while
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/language/statements/while')
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A1.js65
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A10.js31
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A11.js23
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A14_T1.js27
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A14_T2.js27
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A15.js22
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A2.js29
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A3.js32
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A4_T1.js36
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A4_T2.js31
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A4_T3.js31
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A4_T4.js31
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A4_T5.js26
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A5.js40
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A6_T1.js20
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A6_T2.js20
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A6_T3.js20
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A6_T4.js20
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A6_T5.js20
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A6_T6.js20
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A7.js33
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A8.js31
-rw-r--r--js/src/tests/test262/language/statements/while/S12.6.2_A9.js29
-rw-r--r--js/src/tests/test262/language/statements/while/browser.js0
-rw-r--r--js/src/tests/test262/language/statements/while/cptn-abrupt-empty.js32
-rw-r--r--js/src/tests/test262/language/statements/while/cptn-iter.js25
-rw-r--r--js/src/tests/test262/language/statements/while/cptn-no-iter.js21
-rw-r--r--js/src/tests/test262/language/statements/while/decl-async-fun.js21
-rw-r--r--js/src/tests/test262/language/statements/while/decl-async-gen.js21
-rw-r--r--js/src/tests/test262/language/statements/while/decl-cls.js15
-rw-r--r--js/src/tests/test262/language/statements/while/decl-const.js15
-rw-r--r--js/src/tests/test262/language/statements/while/decl-fun.js15
-rw-r--r--js/src/tests/test262/language/statements/while/decl-gen.js16
-rw-r--r--js/src/tests/test262/language/statements/while/decl-let.js15
-rw-r--r--js/src/tests/test262/language/statements/while/labelled-fn-stmt.js19
-rw-r--r--js/src/tests/test262/language/statements/while/let-array-with-newline.js22
-rw-r--r--js/src/tests/test262/language/statements/while/let-block-with-newline.js18
-rw-r--r--js/src/tests/test262/language/statements/while/let-identifier-with-newline.js18
-rw-r--r--js/src/tests/test262/language/statements/while/shell.js16
-rw-r--r--js/src/tests/test262/language/statements/while/tco-body-strict.js25
40 files changed, 978 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A1.js b/js/src/tests/test262/language/statements/while/S12.6.2_A1.js
new file mode 100644
index 0000000000..2400c75215
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A1.js
@@ -0,0 +1,65 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ Expression from "while" IterationStatement is evaluated first; "false",
+ "0", "null", "undefined" and "empty" strings used as the Expression are
+ evaluated to "false"
+es5id: 12.6.2_A1
+description: Evaluating various Expressions
+---*/
+
+var __in__do;
+
+while ( false ) __in__do=1;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (__in__do !== undefined) {
+ throw new Test262Error('#1: false evaluates to false');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+while ( 0 ) __in__do=2;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__in__do !== undefined) {
+ throw new Test262Error('#2: 0 evaluates to false');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+while ( "" ) __in__do=3;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+if (__in__do !== undefined) {
+ throw new Test262Error('#3: empty string evaluates to false');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+while ( null ) __in__do=4;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#4
+if (__in__do !== undefined) {
+ throw new Test262Error('#4: null evaluates to false');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+while ( undefined ) __in__do=35;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#5
+if (__in__do !== undefined) {
+ throw new Test262Error('#5: undefined evaluates to false');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A10.js b/js/src/tests/test262/language/statements/while/S12.6.2_A10.js
new file mode 100644
index 0000000000..2f68c564e7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A10.js
@@ -0,0 +1,31 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ FunctionExpression within a "while" IterationStatement is allowed, but no
+ function with the given name will appear in the global context
+es5id: 12.6.2_A10
+description: Testing FunctionExpression too
+---*/
+
+var check=0;
+while(function f(){}){
+ if(typeof(f) === "function") {
+ check = -1;
+ break;
+ } else {
+ check = 1;
+ break;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (check !== 1) {
+ throw new Test262Error('#1: FunctionExpression inside while construction expression allowed but function not declare');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A11.js b/js/src/tests/test262/language/statements/while/S12.6.2_A11.js
new file mode 100644
index 0000000000..abd33a0511
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A11.js
@@ -0,0 +1,23 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: "\"{}\" Block within a \"while\" Expression is evaluated to true"
+es5id: 12.6.2_A11
+description: Checking if execution of "while({}){}" passes
+---*/
+
+while({}){
+ var __in__do=1;
+ if(__in__do)break;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (__in__do !== 1) {
+ throw new Test262Error('#1: "{}" in while expression evaluates to true');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A14_T1.js b/js/src/tests/test262/language/statements/while/S12.6.2_A14_T1.js
new file mode 100644
index 0000000000..369d1ddf21
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A14_T1.js
@@ -0,0 +1,27 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: FunctionExpression within a "while" Expression is allowed
+es5id: 12.6.2_A14_T1
+description: Using "function __func(){return 0;}" as an Expression
+---*/
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#
+while(function __func(){return 0;}){
+ var __reached = 1;
+ break;
+};
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__reached !== 1) {
+ throw new Test262Error('#2: function expression inside of while expression is allowed');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A14_T2.js b/js/src/tests/test262/language/statements/while/S12.6.2_A14_T2.js
new file mode 100644
index 0000000000..96c3befa0e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A14_T2.js
@@ -0,0 +1,27 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: FunctionExpression within a "while" Expression is allowed
+es5id: 12.6.2_A14_T2
+description: Using function call as an Expression
+---*/
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#
+while(function __func(){return 1;}()){
+ var __reached = 1;
+ break;
+};
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__reached !== 1) {
+ throw new Test262Error('#2: function expression inside of while expression is allowed');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A15.js b/js/src/tests/test262/language/statements/while/S12.6.2_A15.js
new file mode 100644
index 0000000000..eede00a012
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A15.js
@@ -0,0 +1,22 @@
+// |reftest| error:SyntaxError
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Block within a "while" Expression is not allowed
+es5id: 12.6.2_A15
+description: Expression is "{0}"
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#
+while({1}){
+ break ;
+};
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A2.js b/js/src/tests/test262/language/statements/while/S12.6.2_A2.js
new file mode 100644
index 0000000000..c33562daac
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A2.js
@@ -0,0 +1,29 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ While evaluating The production IterationStatement: "while ( Expression )
+ Statement", Expression is evaluated first
+es5id: 12.6.2_A2
+description: Evaluating Statement with error Expression
+---*/
+
+try {
+ while ((function(){throw 1})()) __in__while = "reached";
+ throw new Test262Error('#1: \'while ((function(){throw 1})()) __in__while = "reached"\' lead to throwing exception');
+} catch (e) {
+ if (e !== 1) {
+ throw new Test262Error('#1: Exception === 1. Actual: Exception ==='+e);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (typeof __in__while !== "undefined") {
+ throw new Test262Error('#1.1: typeof __in__while === "undefined". Actual: typeof __in__while ==='+typeof __in__while);
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A3.js b/js/src/tests/test262/language/statements/while/S12.6.2_A3.js
new file mode 100644
index 0000000000..cc40494eeb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A3.js
@@ -0,0 +1,32 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ When "while" IterationStatement is evaluated, (normal, V, empty) is
+ returned
+es5id: 12.6.2_A3
+description: Using eval
+---*/
+
+var __evaluated, __in__do;
+
+__evaluated = eval("while (false) __in__do=1;");
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#
+if (__in__do !== undefined) {
+ throw new Test262Error('#1: __in__do === undefined. Actual: __in__do ==='+ __in__do );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__evaluated !== undefined) {
+ throw new Test262Error('#2: __evaluated === undefined. Actual: __evaluated ==='+ __evaluated );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A4_T1.js b/js/src/tests/test262/language/statements/while/S12.6.2_A4_T1.js
new file mode 100644
index 0000000000..bc2b1edb38
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A4_T1.js
@@ -0,0 +1,36 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ "break" within a "while" Statement is allowed and performed as described
+ in 12.8
+es5id: 12.6.2_A4_T1
+description: "\"break\" within a \"while\" Statement"
+---*/
+
+var __in__do__before__break, __in__do__after__break;
+
+while(1===1){
+ __in__do__before__break="reached";
+ break;
+ __in__do__after__break="where am i";
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (__in__do__before__break !== "reached") {
+ throw new Test262Error('#1: __in__do__before__break === "reached". Actual: __in__do__before__break ==='+ __in__do__before__break );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (typeof __in__do__after__break !== "undefined") {
+ throw new Test262Error('#2: typeof __in__do__after__break === "undefined". Actual: typeof __in__do__after__break ==='+ typeof __in__do__after__break );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A4_T2.js b/js/src/tests/test262/language/statements/while/S12.6.2_A4_T2.js
new file mode 100644
index 0000000000..5e0eb1c85b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A4_T2.js
@@ -0,0 +1,31 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ "break" within a "while" Statement is allowed and performed as described
+ in 12.8
+es5id: 12.6.2_A4_T2
+description: "\"break\" and VariableDeclaration within a \"while\" Statement"
+---*/
+
+do_out : while(1===1) {
+ if (__in__do__before__break) break;
+ var __in__do__before__break="black";
+ do_in : while (1) {
+ var __in__do__IN__before__break="hole";
+ break do_in;
+ var __in__do__IN__after__break="sun";
+ } ;
+ var __in__do__after__break="won't you come";
+};
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (!(__in__do__before__break&&__in__do__IN__before__break&&!__in__do__IN__after__break&&__in__do__after__break)) {
+ throw new Test262Error('#1: Break inside do-while is allowed as its described at standard');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A4_T3.js b/js/src/tests/test262/language/statements/while/S12.6.2_A4_T3.js
new file mode 100644
index 0000000000..a13cd34073
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A4_T3.js
@@ -0,0 +1,31 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ "break" within a "while" Statement is allowed and performed as described
+ in 12.8
+es5id: 12.6.2_A4_T3
+description: "\"break\" and VariableDeclaration within a \"while\" Statement"
+---*/
+
+do_out : while(1===1) {
+ if (__in__do__before__break) break;
+ var __in__do__before__break="once";
+ do_in : while (1) {
+ var __in__do__IN__before__break="in";
+ break do_out;
+ var __in__do__IN__after__break="the";
+ } ;
+ var __in__do__after__break="lifetime";
+} ;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (!(__in__do__before__break&&__in__do__IN__before__break&&!__in__do__IN__after__break&&!__in__do__after__break)) {
+ throw new Test262Error('#1: Break inside do-while is allowed as its described at standard');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A4_T4.js b/js/src/tests/test262/language/statements/while/S12.6.2_A4_T4.js
new file mode 100644
index 0000000000..d25a3662cd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A4_T4.js
@@ -0,0 +1,31 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ "break" within a "while" Statement is allowed and performed as described
+ in 12.8
+es5id: 12.6.2_A4_T4
+description: "\"break\" and VariableDeclaration within a \"while\" Statement"
+---*/
+
+do_out : while(1===1) {
+ if(__in__do__before__break)break;
+ var __in__do__before__break="can't";
+ do_in : while (1) {
+ var __in__do__IN__before__break="get";
+ break;
+ var __in__do__IN__after__break="no";
+ } ;
+ var __in__do__after__break="Satisfaction";
+} ;
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (!(__in__do__before__break&&__in__do__IN__before__break&&!__in__do__IN__after__break&&__in__do__after__break)) {
+ throw new Test262Error('#1: Break inside do-while is allowed as its described at standard');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A4_T5.js b/js/src/tests/test262/language/statements/while/S12.6.2_A4_T5.js
new file mode 100644
index 0000000000..808f602683
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A4_T5.js
@@ -0,0 +1,26 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ "break" within a "while" Statement is allowed and performed as described
+ in 12.8
+es5id: 12.6.2_A4_T5
+description: Using labeled "break" in order to continue a "while" loop
+---*/
+
+//CHECK#1
+var i = 0;
+woohoo:{
+ while(true){
+ i++;
+ if ( i == 10 ) {
+ break woohoo;
+ throw new Test262Error('#1.1: "break woohoo" must break loop');
+ }
+ }
+ throw new Test262Error('This code should be unreacheable');
+}
+assert.sameValue(i, 10);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A5.js b/js/src/tests/test262/language/statements/while/S12.6.2_A5.js
new file mode 100644
index 0000000000..ad9486e290
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A5.js
@@ -0,0 +1,40 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ While using "while" within an eval statement, source "break" is allowed
+ and (normal, V, empty) is returned
+es5id: 12.6.2_A5
+description: Using eval
+---*/
+
+var __evaluated, __in__do__before__break, __in__do__after__break;
+
+__evaluated = eval("while(1) {__in__do__before__break=1; break; __in__do__after__break=2;}");
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (__in__do__before__break !== 1) {
+ throw new Test262Error('#1: __in__do__before__break === 1. Actual: __in__do__before__break ==='+ __in__do__before__break );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (typeof __in__do__after__break !== "undefined") {
+ throw new Test262Error('#2: typeof __in__do__after__break === "undefined". Actual: typeof __in__do__after__break ==='+ typeof __in__do__after__break );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#3
+if (__evaluated !== 1) {
+ throw new Test262Error('#3: __evaluated === 1. Actual: __evaluated ==='+ __evaluated );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A6_T1.js b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T1.js
new file mode 100644
index 0000000000..a60298bed1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T1.js
@@ -0,0 +1,20 @@
+// |reftest| error:SyntaxError
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Expression in "while" IterationStatement is bracketed with braces
+es5id: 12.6.2_A6_T1
+description: Checking if execution of "while 1 break" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+while 1 break;
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A6_T2.js b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T2.js
new file mode 100644
index 0000000000..15db49c2c4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T2.js
@@ -0,0 +1,20 @@
+// |reftest| error:SyntaxError
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Expression in "while" IterationStatement is bracketed with braces
+es5id: 12.6.2_A6_T2
+description: Checking if execution of "while 0 break" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+while 0 break;
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A6_T3.js b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T3.js
new file mode 100644
index 0000000000..458c8921fa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T3.js
@@ -0,0 +1,20 @@
+// |reftest| error:SyntaxError
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Expression in "while" IterationStatement is bracketed with braces
+es5id: 12.6.2_A6_T3
+description: Checking if execution of "while true break" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+while true break;
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A6_T4.js b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T4.js
new file mode 100644
index 0000000000..a4f37f8066
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T4.js
@@ -0,0 +1,20 @@
+// |reftest| error:SyntaxError
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Expression in "while" IterationStatement is bracketed with braces
+es5id: 12.6.2_A6_T4
+description: Checking if execution of "while false break" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+while false break;
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A6_T5.js b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T5.js
new file mode 100644
index 0000000000..c923aa1f89
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T5.js
@@ -0,0 +1,20 @@
+// |reftest| error:SyntaxError
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Expression in "while" IterationStatement is bracketed with braces
+es5id: 12.6.2_A6_T5
+description: Checking if execution of "while '' break" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+while '' break;
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A6_T6.js b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T6.js
new file mode 100644
index 0000000000..0ce691ecd8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A6_T6.js
@@ -0,0 +1,20 @@
+// |reftest| error:SyntaxError
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Expression in "while" IterationStatement is bracketed with braces
+es5id: 12.6.2_A6_T6
+description: Checking if execution of "while 'hood' break" fails
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+while 'hood' break;
+//
+//////////////////////////////////////////////////////////////////////////////
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A7.js b/js/src/tests/test262/language/statements/while/S12.6.2_A7.js
new file mode 100644
index 0000000000..b8ebf62d0a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A7.js
@@ -0,0 +1,33 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ The "while" Statement is evaluted according to 12.6.2 and returns
+ (normal, V, empty)
+es5id: 12.6.2_A7
+description: using eval
+---*/
+
+var __evaluated;
+var __condition=0
+
+__evaluated = eval("while (__condition<5) eval(\"__condition++\");");
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (__condition !== 5) {
+ throw new Test262Error('#1: The "while" statement is evaluated as described in the Standard');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__evaluated !== 4) {
+ throw new Test262Error('#2: The "while" statement returns (normal, V, empty)');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A8.js b/js/src/tests/test262/language/statements/while/S12.6.2_A8.js
new file mode 100644
index 0000000000..f9eae898d4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A8.js
@@ -0,0 +1,31 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: "\"continue\" statement within a \"while\" Statement is allowed"
+es5id: 12.6.2_A8
+description: using eval
+---*/
+
+var __evaluated;
+var __condition = 0, __odds=0;
+
+__evaluated = eval("while(__condition < 10) { __condition++; if (((''+__condition/2).split('.')).length>1) continue; __odds++;}");
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+if (__odds !== 5) {
+ throw new Test262Error('#1: __odds === 5. Actual: __odds ==='+ __odds );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#2
+if (__evaluated !== 4) {
+ throw new Test262Error('#2: __evaluated === 4. Actual: __evaluated ==='+ __evaluated );
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/S12.6.2_A9.js b/js/src/tests/test262/language/statements/while/S12.6.2_A9.js
new file mode 100644
index 0000000000..c1739db70d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/S12.6.2_A9.js
@@ -0,0 +1,29 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: "\"while\" Statement is evaluated without syntax checks"
+es5id: 12.6.2_A9
+description: Throwing system exception inside "while" loop
+---*/
+
+//////////////////////////////////////////////////////////////////////////////
+//CHECK#1
+try {
+ while(x!=1) {
+ var x = 1;
+ abaracadabara;
+ };
+ throw new Test262Error('#1: "abbracadabra" lead to throwing exception');
+
+} catch (e) {
+ if (e instanceof Test262Error) throw e;
+}
+
+if (x !== 1) {
+ throw new Test262Error('#1.1: while statement evaluates as is, without syntax checks');
+}
+//
+//////////////////////////////////////////////////////////////////////////////
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/browser.js b/js/src/tests/test262/language/statements/while/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/browser.js
diff --git a/js/src/tests/test262/language/statements/while/cptn-abrupt-empty.js b/js/src/tests/test262/language/statements/while/cptn-abrupt-empty.js
new file mode 100644
index 0000000000..3ac8963068
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/cptn-abrupt-empty.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.7.3.6
+description: >
+ Completion value when iteration completes due to an empty abrupt completion
+info: |
+ IterationStatement : while ( Expression ) Statement
+
+ 1. Let V = undefined.
+ 2. Repeat
+ a. Let exprRef be the result of evaluating Expression.
+ b. Let exprValue be GetValue(exprRef).
+ c. ReturnIfAbrupt(exprValue).
+ d. If ToBoolean(exprValue) is false, return NormalCompletion(V).
+ e. Let stmt be the result of evaluating Statement.
+ f. If LoopContinues (stmt, labelSet) is false, return
+ Completion(UpdateEmpty(stmt, V)).
+---*/
+
+assert.sameValue(eval('1; while (true) { break; }'), undefined);
+assert.sameValue(eval('2; while (true) { 3; break; }'), 3);
+
+assert.sameValue(
+ eval('4; outer: do { while (true) { continue outer; } } while (false)'),
+ undefined
+);
+assert.sameValue(
+ eval('5; outer: do { while (true) { 6; continue outer; } } while (false)'), 6
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/cptn-iter.js b/js/src/tests/test262/language/statements/while/cptn-iter.js
new file mode 100644
index 0000000000..37ad74646b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/cptn-iter.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.7.3.6
+description: >
+ Completion value when iteration completes due to expression value
+info: |
+ IterationStatement : while ( Expression ) Statement
+
+ 1. Let V = undefined.
+ 2. Repeat
+ a. Let exprRef be the result of evaluating Expression.
+ b. Let exprValue be GetValue(exprRef).
+ c. ReturnIfAbrupt(exprValue).
+ d. If ToBoolean(exprValue) is false, return NormalCompletion(V).
+ e. Let stmt be the result of evaluating Statement.
+ f. If LoopContinues (stmt, labelSet) is false, return
+ Completion(UpdateEmpty(stmt, V)).
+ g. If stmt.[[value]] is not empty, let V = stmt.[[value]].
+---*/
+
+assert.sameValue(eval('var count1 = 2; 1; while (count1 -= 1) { }'), undefined);
+assert.sameValue(eval('var count2 = 2; 2; while (count2 -= 1) { 3; }'), 3);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/cptn-no-iter.js b/js/src/tests/test262/language/statements/while/cptn-no-iter.js
new file mode 100644
index 0000000000..79ca3de7c8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/cptn-no-iter.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.7.3.6
+description: >
+ Completion value when no iteration occurs
+info: |
+ IterationStatement : while ( Expression ) Statement
+
+ 1. Let V = undefined.
+ 2. Repeat
+ a. Let exprRef be the result of evaluating Expression.
+ b. Let exprValue be GetValue(exprRef).
+ c. ReturnIfAbrupt(exprValue).
+ d. If ToBoolean(exprValue) is false, return NormalCompletion(V).
+---*/
+
+assert.sameValue(eval('1; while (false) { }'), undefined);
+assert.sameValue(eval('2; while (false) { 3; }'), undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/decl-async-fun.js b/js/src/tests/test262/language/statements/while/decl-async-fun.js
new file mode 100644
index 0000000000..3fe7a471cd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/decl-async-fun.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-while-statement
+description: >
+ AsyncFunctionDeclaration is not allowed in statement position
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-functions]
+---*/
+
+$DONOTEVALUATE();
+
+while (false) async function f() {}
diff --git a/js/src/tests/test262/language/statements/while/decl-async-gen.js b/js/src/tests/test262/language/statements/while/decl-async-gen.js
new file mode 100644
index 0000000000..4bed807262
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/decl-async-gen.js
@@ -0,0 +1,21 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-while-statement
+description: >
+ AsyncGeneratorDeclaration is not allowed in statement position
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-iteration]
+---*/
+
+$DONOTEVALUATE();
+
+while (false) async function* g() {}
diff --git a/js/src/tests/test262/language/statements/while/decl-cls.js b/js/src/tests/test262/language/statements/while/decl-cls.js
new file mode 100644
index 0000000000..46ebe8e0aa
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/decl-cls.js
@@ -0,0 +1,15 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: Class declaration not allowed in statement position
+esid: sec-while-statement
+es6id: 13.7.3
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+while (false) class C {}
diff --git a/js/src/tests/test262/language/statements/while/decl-const.js b/js/src/tests/test262/language/statements/while/decl-const.js
new file mode 100644
index 0000000000..745a7d8e49
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/decl-const.js
@@ -0,0 +1,15 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: Lexical declaration (const) not allowed in statement position
+esid: sec-while-statement
+es6id: 13.7.3
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+while (false) const x = null;
diff --git a/js/src/tests/test262/language/statements/while/decl-fun.js b/js/src/tests/test262/language/statements/while/decl-fun.js
new file mode 100644
index 0000000000..8b286ca3d5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/decl-fun.js
@@ -0,0 +1,15 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: Function declaration not allowed in statement position
+esid: sec-while-statement
+es6id: 13.7.3
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+while (false) function f() {}
diff --git a/js/src/tests/test262/language/statements/while/decl-gen.js b/js/src/tests/test262/language/statements/while/decl-gen.js
new file mode 100644
index 0000000000..5df6b6ec54
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/decl-gen.js
@@ -0,0 +1,16 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: Generator declaration not allowed in statement position
+esid: sec-while-statement
+es6id: 13.7.3
+negative:
+ phase: parse
+ type: SyntaxError
+features: [generators]
+---*/
+
+$DONOTEVALUATE();
+
+while (false) function* g() {}
diff --git a/js/src/tests/test262/language/statements/while/decl-let.js b/js/src/tests/test262/language/statements/while/decl-let.js
new file mode 100644
index 0000000000..4dedea5212
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/decl-let.js
@@ -0,0 +1,15 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: Lexical declaration (let) not allowed in statement position
+esid: sec-while-statement
+es6id: 13.7.3
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+while (false) let x;
diff --git a/js/src/tests/test262/language/statements/while/labelled-fn-stmt.js b/js/src/tests/test262/language/statements/while/labelled-fn-stmt.js
new file mode 100644
index 0000000000..4260ee2fe1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/labelled-fn-stmt.js
@@ -0,0 +1,19 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: It is a Syntax Error if IsLabelledFunction(Statement) is true.
+negative:
+ phase: parse
+ type: SyntaxError
+esid: sec-semantics-static-semantics-early-errors
+es6id: 13.7.1.1
+info: |
+ Although Annex B describes an extension which permits labelled function
+ declarations outside of strict mode, this early error is applied regardless
+ of the language mode.
+---*/
+
+$DONOTEVALUATE();
+
+while (false) label1: label2: function f() {}
diff --git a/js/src/tests/test262/language/statements/while/let-array-with-newline.js b/js/src/tests/test262/language/statements/while/let-array-with-newline.js
new file mode 100644
index 0000000000..27c86cbb29
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/let-array-with-newline.js
@@ -0,0 +1,22 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-while-statement
+description: >
+ ExpressionStatement has a lookahead restriction for `let [`.
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+negative:
+ phase: parse
+ type: SyntaxError
+flags: [noStrict]
+---*/
+
+$DONOTEVALUATE();
+
+while (false) let
+[a] = 0;
diff --git a/js/src/tests/test262/language/statements/while/let-block-with-newline.js b/js/src/tests/test262/language/statements/while/let-block-with-newline.js
new file mode 100644
index 0000000000..3ee10d92ba
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/let-block-with-newline.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-while-statement
+description: >
+ ExpressionStatement doesn't have a lookahead restriction for `let {`.
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+flags: [noStrict]
+---*/
+
+while (false) let // ASI
+{}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/let-identifier-with-newline.js b/js/src/tests/test262/language/statements/while/let-identifier-with-newline.js
new file mode 100644
index 0000000000..a1658c15d5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/let-identifier-with-newline.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-while-statement
+description: >
+ ExpressionStatement doesn't have a lookahead restriction for `let <binding-identifier>`.
+info: |
+ ExpressionStatement[Yield, Await] :
+ [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
+ Expression[+In, ?Yield, ?Await] ;
+flags: [noStrict]
+---*/
+
+while (false) let // ASI
+x = 1;
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/while/shell.js b/js/src/tests/test262/language/statements/while/shell.js
new file mode 100644
index 0000000000..43295587f4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/shell.js
@@ -0,0 +1,16 @@
+// GENERATED, DO NOT EDIT
+// file: tcoHelper.js
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ This defines the number of consecutive recursive function calls that must be
+ made in order to prove that stack frames are properly destroyed according to
+ ES2015 tail call optimization semantics.
+defines: [$MAX_ITERATIONS]
+---*/
+
+
+
+
+var $MAX_ITERATIONS = 100000;
diff --git a/js/src/tests/test262/language/statements/while/tco-body-strict.js b/js/src/tests/test262/language/statements/while/tco-body-strict.js
new file mode 100644
index 0000000000..89d01601de
--- /dev/null
+++ b/js/src/tests/test262/language/statements/while/tco-body-strict.js
@@ -0,0 +1,25 @@
+// |reftest| skip -- tail-call-optimization is not supported
+'use strict';
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: Statement within statement is a candidate for tail-call optimization.
+esid: sec-static-semantics-hascallintailposition
+flags: [onlyStrict]
+features: [tail-call-optimization]
+includes: [tcoHelper.js]
+---*/
+
+var callCount = 0;
+(function f(n) {
+ if (n === 0) {
+ callCount += 1
+ return;
+ }
+ while (true) {
+ return f(n - 1);
+ }
+}($MAX_ITERATIONS));
+assert.sameValue(callCount, 1);
+
+reportCompare(0, 0);