diff options
Diffstat (limited to 'js/src/tests/test262/ch12/12.8')
21 files changed, 582 insertions, 0 deletions
diff --git a/js/src/tests/test262/ch12/12.8/12.8-1.js b/js/src/tests/test262/ch12/12.8/12.8-1.js new file mode 100644 index 000000000..e32f54168 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/12.8-1.js @@ -0,0 +1,23 @@ +/// Copyright (c) 2012 Ecma International. All rights reserved.
+/// Ecma International makes this code available under the terms and conditions set
+/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
+/// "Use Terms"). Any redistribution of this code must retain the above
+/// copyright and this notice and otherwise comply with the Use Terms.
+/**
+ * @path ch12/12.8/12.8-1.js
+ * @description The break Statement - a break statement without an identifier may have a LineTerminator before the semi-colon
+ */
+
+
+function testcase() {
+ var sum = 0;
+ for (var i = 1; i <= 10; i++) {
+ if (i === 6) {
+ break
+ ;
+ }
+ sum += i;
+ }
+ return sum === 15;
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A1_T1.js b/js/src/tests/test262/ch12/12.8/S12.8_A1_T1.js new file mode 100644 index 000000000..546e66780 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Appearing of break without an IterationStatement leads to syntax error + * + * @path ch12/12.8/S12.8_A1_T1.js + * @description Checking if break statement with no loop fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +var x=1; +break; +var y=2; +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A1_T2.js b/js/src/tests/test262/ch12/12.8/S12.8_A1_T2.js new file mode 100644 index 000000000..c141c7722 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A1_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Appearing of break without an IterationStatement leads to syntax error + * + * @path ch12/12.8/S12.8_A1_T2.js + * @description Checking if break Identifier with no loop fails + * @negative + */ + +LABEL : x=3.14; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +var x=1; +break LABEL; +var y=2; +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A1_T3.js b/js/src/tests/test262/ch12/12.8/S12.8_A1_T3.js new file mode 100644 index 000000000..6627be368 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A1_T3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Appearing of break without an IterationStatement leads to syntax error + * + * @path ch12/12.8/S12.8_A1_T3.js + * @description Checking if break statement with no loop, placed into a block, fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +{ + var x=1; + break; + var y=2; +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A1_T4.js b/js/src/tests/test262/ch12/12.8/S12.8_A1_T4.js new file mode 100644 index 000000000..1663fc5f5 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A1_T4.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. + +/** + * Appearing of break without an IterationStatement leads to syntax error + * + * @path ch12/12.8/S12.8_A1_T4.js + * @description Checking if break Identifier with no loop, placed into a block, fails + * @negative + */ + +LABEL : x=3.14; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +{ + var x=1; + break LABEL; + var y=2; +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A2.js b/js/src/tests/test262/ch12/12.8/S12.8_A2.js new file mode 100644 index 000000000..a1154aeca --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A2.js @@ -0,0 +1,64 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Since LineTerminator between "break" and Identifier is not allowed, "break" is evaluated without label + * + * @path ch12/12.8/S12.8_A2.js + * @description Checking by using eval, inserting LineTerminator between break and Identifier + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + eval("FOR1 : for(var i=1;i<2;i++){ LABEL1 : do {var x =1;break\u000AFOR1;var y=2;} while(0);}"); + if (i!==2) { + $ERROR('#1: Since LineTerminator(U-000A) between break and Identifier not allowed break evaluates without label'); + } +} catch(e){ + $ERROR('#1.1: eval("FOR1 : for(var i=1;i<2;i++){ LABEL1 : do {var x =1;break\\u000AFOR1;var y=2;} while(0);}") does not lead to throwing exception'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try{ + eval("FOR2 : for(var i=1;i<2;i++){ LABEL2 : do {var x =1;break\u000DFOR2;var y=2;} while(0);}"); + if (i!==2) { + $ERROR('#2: Since LineTerminator(U-000D) between break and Identifier not allowed break evaluates without label'); + } +} catch(e){ + $ERROR('#2.1: eval("FOR2 : for(var i=1;i<2;i++){ LABEL2 : do {var x =1;break\\u000DFOR2;var y=2;} while(0);}") does not lead to throwing exception'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +try{ + eval("FOR3 : for(var i=1;i<2;i++){ LABEL3 : do {var x =1;break\u2028FOR3;var y=2;} while(0);}"); + if (i!==2) { + $ERROR('#3: Since LineTerminator(U-2028) between break and Identifier not allowed break evaluates without label'); + } +} catch(e){ + $ERROR('#3.1: eval("FOR3 : for(var i=1;i<2;i++){ LABEL3 : do {var x =1;break\\u2028FOR3;var y=2;} while(0);}") does not lead to throwing exception'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +try{ + eval("FOR4 : for(var i=1;i<2;i++){ LABEL4 : do {var x =1;break\u2029FOR4;var y=2;} while(0);}"); + if (i!==2) { + $ERROR('#4: Since LineTerminator(U-2029) between break and Identifier not allowed break evaluates without label'); + } +} catch(e){ + $ERROR('#4.1: eval("FOR4 : for(var i=1;i<2;i++){ LABEL4 : do {var x =1;break\\u2029FOR4;var y=2;} while(0);}") does not lead to throwing exception'); +} +// +////////////////////////////////////////////////////////////////////////////// + + + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A3.js b/js/src/tests/test262/ch12/12.8/S12.8_A3.js new file mode 100644 index 000000000..d2aaa5ad3 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A3.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When "break" is evaluated, (break, empty, empty) is returned + * + * @path ch12/12.8/S12.8_A3.js + * @description Using "break" without Identifier within labeled loop + */ + +LABEL_OUT : var x=0, y=0; + +LABEL_DO_LOOP : do { + LABEL_IN : x=2; + break ; + LABEL_IN_2 : var y=2; + + function IN_DO_FUNC(){} +} while(0); + +LABEL_ANOTHER_LOOP : do { + ; +} while(0); + +function OUT_FUNC(){} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((x!==2)&&(y!==0)) { + $ERROR('#1: x === 2 and y === 0. Actual: x ==='+x+' and y ==='+y); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A4_T1.js b/js/src/tests/test262/ch12/12.8/S12.8_A4_T1.js new file mode 100644 index 000000000..86e258a4e --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A4_T1.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When "break Identifier" is evaluated, (break, empty, Identifier) is returned + * + * @path ch12/12.8/S12.8_A4_T1.js + * @description Using "break Identifier" within labaeled loop + */ + +LABEL_OUT : var x=0, y=0; +(function(){ +LABEL_DO_LOOP : do { + LABEL_IN : x++; + if(x===10)return; + break LABEL_DO_LOOP; + LABEL_IN_2 : y++; + + function IN_DO_FUNC(){} +} while(0); + +LABEL_ANOTHER_LOOP : do { + ; +} while(0); + +function OUT_FUNC(){} +})(); +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((x!==1)&&(y!==0)) { + $ERROR('#1: x === 1 and y === 0. Actual: x === '+x+' and y ==='+ y ); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A4_T2.js b/js/src/tests/test262/ch12/12.8/S12.8_A4_T2.js new file mode 100644 index 000000000..8662cf829 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A4_T2.js @@ -0,0 +1,41 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When "break Identifier" is evaluated, (break, empty, Identifier) is returned + * + * @path ch12/12.8/S12.8_A4_T2.js + * @description Using embedded and labeled loops, breaking to nested loop + */ + +LABEL_OUT : var x=0, y=0, xx=0, yy=0; +(function(){ +LABEL_DO_LOOP : do { + LABEL_IN : x++; + if(x===10)return; + LABEL_NESTED_LOOP : do { + LABEL_IN_NESTED : xx++; + if(xx===10)return; + break LABEL_NESTED_LOOP; + LABEL_IN_NESTED_2 : yy++; + } while (0); + + LABEL_IN_2 : y++; + + function IN_DO_FUNC(){} +} while(0); + +LABEL_ANOTHER_LOOP : do { + ; +} while(0); + +function OUT_FUNC(){} +})(); +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((x!==1)&&(y!==1)&&(xx!==1)&(yy!==0)) { + $ERROR('#1: x === 1 and y === 1 and xx === 1 and yy === 0. Actual: x==='+x+' and y==='+y+' and xx==='+xx+' and yy==='+yy ); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A4_T3.js b/js/src/tests/test262/ch12/12.8/S12.8_A4_T3.js new file mode 100644 index 000000000..7ca7fc2d6 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A4_T3.js @@ -0,0 +1,41 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When "break Identifier" is evaluated, (break, empty, Identifier) is returned + * + * @path ch12/12.8/S12.8_A4_T3.js + * @description Using embedded and labeled loops, breaking to outer loop + */ + +LABEL_OUT : var x=0, y=0, xx=0, yy=0; +(function(){ +LABEL_DO_LOOP : do { + LABEL_IN : x++; + if(x===10)return; + LABEL_NESTED_LOOP : do { + LABEL_IN_NESTED : xx++; + if(xx===10)return; + break LABEL_DO_LOOP; + LABEL_IN_NESTED_2 : yy++; + } while (0); + + LABEL_IN_2 : y++; + + function IN_DO_FUNC(){} +} while(0); + +LABEL_ANOTHER_LOOP : do { + ; +} while(0); + +function OUT_FUNC(){} +})(); +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((x!==1)&&(y!==0)&&(xx!==1)&(yy!==0)) { + $ERROR('#1: x === 1 and y === 0 and xx === 1 and yy === 0. Actual: x==='+x+' and y==='+y+' and xx==='+xx+' and yy==='+yy ); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A5_T1.js b/js/src/tests/test262/ch12/12.8/S12.8_A5_T1.js new file mode 100644 index 000000000..34fbed938 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A5_T1.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. + +/** + * Identifier must be label in the label set of an enclosing (but not crossing function boundaries) IterationStatement + * + * @path ch12/12.8/S12.8_A5_T1.js + * @description Checking if breaking another labeled loop fails + * @negative + */ + +(function(){ + LABEL_OUT : var x=0, y=0; + LABEL_DO_LOOP : do { + LABEL_IN : x++; + if(x===10) + return; + break LABEL_ANOTHER_LOOP; + LABEL_IN_2 : y++; + function IN_DO_FUNC(){} + } while(0); + + LABEL_ANOTHER_LOOP : do { + ; + } while(0); + + function OUT_FUNC(){} +})(); + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A5_T2.js b/js/src/tests/test262/ch12/12.8/S12.8_A5_T2.js new file mode 100644 index 000000000..f843c3bb1 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A5_T2.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. + +/** + * Identifier must be label in the label set of an enclosing (but not crossing function boundaries) IterationStatement + * + * @path ch12/12.8/S12.8_A5_T2.js + * @description Checking if using function name as an Identifier appears to be invalid + * @negative + */ + +(function(){ + LABEL_OUT : var x=0, y=0; + LABEL_DO_LOOP : do { + LABEL_IN : x++; + if(x===10) + return; + break IN_DO_FUNC; + LABEL_IN_2 : y++; + function IN_DO_FUNC(){} + } while(0); + + LABEL_ANOTHER_LOOP : do { + ; + } while(0); + + function OUT_FUNC(){} +})(); + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A5_T3.js b/js/src/tests/test262/ch12/12.8/S12.8_A5_T3.js new file mode 100644 index 000000000..d6f930705 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A5_T3.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. + +/** + * Identifier must be label in the label set of an enclosing (but not crossing function boundaries) IterationStatement + * + * @path ch12/12.8/S12.8_A5_T3.js + * @description Checking if using internal loop label as an Identifier appears to be invalid + * @negative + */ + +(function(){ + LABEL_OUT : var x=0, y=0; + LABEL_DO_LOOP : do { + LABEL_IN : x++; + if(x===10) + return; + break LABEL_IN; + LABEL_IN_2 : y++; + + function IN_DO_FUNC(){} + + } while(0); + + LABEL_ANOTHER_LOOP : do { + ; + } while(0); + + function OUT_FUNC(){} + +})(); + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A6.js b/js/src/tests/test262/ch12/12.8/S12.8_A6.js new file mode 100644 index 000000000..264f74d86 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A6.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Appearing of "break" within a function call that is nested in a IterationStatement yields SyntaxError + * + * @path ch12/12.8/S12.8_A6.js + * @description Checking if using "break Identifier" within a function body appears to be invalid + * @negative + */ + +var x=0,y=0; + +LABEL1 : do { + x++; + (function(){break LABEL1;})(); + y++; +} while(0); + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A7.js b/js/src/tests/test262/ch12/12.8/S12.8_A7.js new file mode 100644 index 000000000..a5f5bebaf --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A7.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. + +/** + * Appearing of "break" within eval statement that is nested in an IterationStatement yields SyntaxError + * + * @path ch12/12.8/S12.8_A7.js + * @description Using eval "eval("break LABEL1")" + */ + +var x=0,y=0; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + LABEL1 : do { + x++; + eval("break LABEL1"); + y++; + } while(0); + $ERROR('#1: eval("break LABEL1") does not lead to throwing exception'); +} catch(e){ + if(!(e instanceof SyntaxError)){ + $ERROR("1.1: Appearing of break within eval statement inside of IterationStatement yields SyntaxError"); + } +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A8_T1.js b/js/src/tests/test262/ch12/12.8/S12.8_A8_T1.js new file mode 100644 index 000000000..cbcba7f69 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A8_T1.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. + +/** + * Appearing of "break" within "try/catch" Block yields SyntaxError + * + * @path ch12/12.8/S12.8_A8_T1.js + * @description Checking if using "break Identifier" from within catch Block appears to be invalid + * @negative + */ + +var x=0,y=0; + +try{ + LABEL1 : do { + x++; + throw "gonna leave it"; + y++; + } while(0); + $ERROR('#1: throw "gonna leave it" lead to throwing exception'); +} catch(e){ + break LABEL2; + LABEL2 : do { + x++; + y++; + } while(0); +} + + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A8_T2.js b/js/src/tests/test262/ch12/12.8/S12.8_A8_T2.js new file mode 100644 index 000000000..92771babf --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A8_T2.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. + +/** + * Appearing of "break" within "try/catch" Block yields SyntaxError + * + * @path ch12/12.8/S12.8_A8_T2.js + * @description Checking if using "break Identifier" from within catch Block appears to be invalid + * @negative + */ + +var x=0,y=0; + +try{ + LABEL1 : do { + x++; + throw "gonna leave it"; + y++; + } while(0); + $ERROR('#1: throw "gonna leave it" lead to throwing exception'); +} catch(e){ + break; + LABEL2 : do { + x++; + y++; + } while(0); +} + + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A9_T1.js b/js/src/tests/test262/ch12/12.8/S12.8_A9_T1.js new file mode 100644 index 000000000..60da11ef2 --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A9_T1.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. + +/** + * Using "break" within "try/catch" statement that is nested in a loop is allowed + * + * @path ch12/12.8/S12.8_A9_T1.js + * @description Using "continue Identifier" within "catch" statement + */ + +var x=0,y=0; + +(function(){ +FOR : for(;;){ + try{ + x++; + if(x===10)return; + throw 1; + } catch(e){ + break FOR; + } +} +})(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x!==1) { + $ERROR('#1: break inside of try-catch nested in loop is allowed'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.8/S12.8_A9_T2.js b/js/src/tests/test262/ch12/12.8/S12.8_A9_T2.js new file mode 100644 index 000000000..53dc3555c --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/S12.8_A9_T2.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. + +/** + * Using "break" within "try/catch" statement that is nested in a loop is allowed + * + * @path ch12/12.8/S12.8_A9_T2.js + * @description Using "continue Identifier" within "catch" statement + */ + +var x=0,y=0; + +(function(){ +FOR : for(;;){ + try{ + x++; + if(x===10)return; + throw 1; + } catch(e){ + break ; + } +} +})(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x!==1) { + $ERROR('#1: break inside of try-catch nested in loop is allowed'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.8/browser.js b/js/src/tests/test262/ch12/12.8/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/browser.js diff --git a/js/src/tests/test262/ch12/12.8/shell.js b/js/src/tests/test262/ch12/12.8/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch12/12.8/shell.js |