diff options
Diffstat (limited to 'js/src/tests/test262/language/statements/break')
22 files changed, 634 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/break/12.8-1.js b/js/src/tests/test262/language/statements/break/12.8-1.js new file mode 100644 index 0000000000..0302583434 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/12.8-1.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.8-1 +description: > + The break Statement - a break statement without an identifier may + have a LineTerminator before the semi-colon +---*/ + + var sum = 0; + for (var i = 1; i <= 10; i++) { + if (i === 6) { + break + ; + } + sum += i; + } + +assert.sameValue(sum, 15, 'sum'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/break/S12.8_A1_T1.js b/js/src/tests/test262/language/statements/break/S12.8_A1_T1.js new file mode 100644 index 0000000000..0944e1c41c --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A1_T1.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: Appearing of break without an IterationStatement leads to syntax error +es5id: 12.8_A1_T1 +description: Checking if break statement with no loop fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +var x=1; +break; +var y=2; +// +////////////////////////////////////////////////////////////////////////////// diff --git a/js/src/tests/test262/language/statements/break/S12.8_A1_T2.js b/js/src/tests/test262/language/statements/break/S12.8_A1_T2.js new file mode 100644 index 0000000000..700980d937 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A1_T2.js @@ -0,0 +1,24 @@ +// |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: Appearing of break without an IterationStatement leads to syntax error +es5id: 12.8_A1_T2 +description: Checking if break Identifier with no loop fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +LABEL : x=3.14; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +var x=1; +break LABEL; +var y=2; +// +////////////////////////////////////////////////////////////////////////////// diff --git a/js/src/tests/test262/language/statements/break/S12.8_A1_T3.js b/js/src/tests/test262/language/statements/break/S12.8_A1_T3.js new file mode 100644 index 0000000000..eba60f66d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A1_T3.js @@ -0,0 +1,26 @@ +// |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: Appearing of break without an IterationStatement leads to syntax error +es5id: 12.8_A1_T3 +description: > + Checking if break statement with no loop, placed into a block, + fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +{ + var x=1; + break; + var y=2; +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/js/src/tests/test262/language/statements/break/S12.8_A1_T4.js b/js/src/tests/test262/language/statements/break/S12.8_A1_T4.js new file mode 100644 index 0000000000..985686fb73 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A1_T4.js @@ -0,0 +1,28 @@ +// |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: Appearing of break without an IterationStatement leads to syntax error +es5id: 12.8_A1_T4 +description: > + Checking if break Identifier with no loop, placed into a block, + fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +LABEL : x=3.14; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +{ + var x=1; + break LABEL; + var y=2; +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/js/src/tests/test262/language/statements/break/S12.8_A3.js b/js/src/tests/test262/language/statements/break/S12.8_A3.js new file mode 100644 index 0000000000..c2bc51fc33 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/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. + +/*--- +info: When "break" is evaluated, (break, empty, empty) is returned +es5id: 12.8_A3 +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)) { + throw new Test262Error('#1: x === 2 and y === 0. Actual: x ==='+x+' and y ==='+y); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/break/S12.8_A4_T1.js b/js/src/tests/test262/language/statements/break/S12.8_A4_T1.js new file mode 100644 index 0000000000..80c6752a70 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A4_T1.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "break Identifier" is evaluated, (break, empty, Identifier) is + returned +es5id: 12.8_A4_T1 +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)) { + throw new Test262Error('#1: x === 1 and y === 0. Actual: x === '+x+' and y ==='+ y ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/break/S12.8_A4_T2.js b/js/src/tests/test262/language/statements/break/S12.8_A4_T2.js new file mode 100644 index 0000000000..799cd22e53 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A4_T2.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "break Identifier" is evaluated, (break, empty, Identifier) is + returned +es5id: 12.8_A4_T2 +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)) { + throw new Test262Error('#1: x === 1 and y === 1 and xx === 1 and yy === 0. Actual: x==='+x+' and y==='+y+' and xx==='+xx+' and yy==='+yy ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/break/S12.8_A4_T3.js b/js/src/tests/test262/language/statements/break/S12.8_A4_T3.js new file mode 100644 index 0000000000..9f92491fe2 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A4_T3.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "break Identifier" is evaluated, (break, empty, Identifier) is + returned +es5id: 12.8_A4_T3 +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)) { + throw new Test262Error('#1: x === 1 and y === 0 and xx === 1 and yy === 0. Actual: x==='+x+' and y==='+y+' and xx==='+xx+' and yy==='+yy ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/break/S12.8_A5_T1.js b/js/src/tests/test262/language/statements/break/S12.8_A5_T1.js new file mode 100644 index 0000000000..35d7877706 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A5_T1.js @@ -0,0 +1,34 @@ +// |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: | + Identifier must be label in the label set of an enclosing (but not + crossing function boundaries) IterationStatement +es5id: 12.8_A5_T1 +description: Checking if breaking another labeled loop fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +(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/language/statements/break/S12.8_A5_T2.js b/js/src/tests/test262/language/statements/break/S12.8_A5_T2.js new file mode 100644 index 0000000000..17e645b4ee --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A5_T2.js @@ -0,0 +1,36 @@ +// |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: | + Identifier must be label in the label set of an enclosing (but not + crossing function boundaries) IterationStatement +es5id: 12.8_A5_T2 +description: > + Checking if using function name as an Identifier appears to be + invalid +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +(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/language/statements/break/S12.8_A5_T3.js b/js/src/tests/test262/language/statements/break/S12.8_A5_T3.js new file mode 100644 index 0000000000..13f0e3d64a --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A5_T3.js @@ -0,0 +1,39 @@ +// |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: | + Identifier must be label in the label set of an enclosing (but not + crossing function boundaries) IterationStatement +es5id: 12.8_A5_T3 +description: > + Checking if using internal loop label as an Identifier appears to + be invalid +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +(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/language/statements/break/S12.8_A6.js b/js/src/tests/test262/language/statements/break/S12.8_A6.js new file mode 100644 index 0000000000..aad6dc14a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A6.js @@ -0,0 +1,26 @@ +// |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: | + Appearing of "break" within a function call that is nested in a + IterationStatement yields SyntaxError +es5id: 12.8_A6 +description: > + Checking if using "break Identifier" within a function body + appears to be invalid +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var x=0,y=0; + +LABEL1 : do { + x++; + (function(){break LABEL1;})(); + y++; +} while(0); diff --git a/js/src/tests/test262/language/statements/break/S12.8_A7.js b/js/src/tests/test262/language/statements/break/S12.8_A7.js new file mode 100644 index 0000000000..6cc93e7ae5 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A7.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: | + Appearing of "break" within eval statement that is nested in an + IterationStatement yields SyntaxError +es5id: 12.8_A7 +description: Using eval "eval("break LABEL1")" +---*/ + +var x=0,y=0; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + LABEL1 : do { + x++; + eval("break LABEL1"); + y++; + } while(0); + throw new Test262Error('#1: eval("break LABEL1") does not lead to throwing exception'); +} catch(e){ + if(!(e instanceof SyntaxError)){ + throw new Test262Error("1.1: Appearing of break within eval statement inside of IterationStatement yields SyntaxError"); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/break/S12.8_A8_T1.js b/js/src/tests/test262/language/statements/break/S12.8_A8_T1.js new file mode 100644 index 0000000000..e43cde8525 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A8_T1.js @@ -0,0 +1,23 @@ +// |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: Appearing of "break" within "try/catch" Block yields SyntaxError +es5id: 12.8_A8_T1 +description: > + Checking if using "break Identifier" from within catch Block + appears to be invalid +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +try{ +} catch(e){ + break LABEL2; + LABEL2 : do { + } while(0); +} diff --git a/js/src/tests/test262/language/statements/break/S12.8_A8_T2.js b/js/src/tests/test262/language/statements/break/S12.8_A8_T2.js new file mode 100644 index 0000000000..a45c3f122e --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A8_T2.js @@ -0,0 +1,23 @@ +// |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: Appearing of "break" within "try/catch" Block yields SyntaxError +es5id: 12.8_A8_T2 +description: > + Checking if using "break Identifier" from within catch Block + appears to be invalid +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +try{ +} catch(e){ + break; + LABEL2 : do { + } while(0); +} diff --git a/js/src/tests/test262/language/statements/break/S12.8_A9_T1.js b/js/src/tests/test262/language/statements/break/S12.8_A9_T1.js new file mode 100644 index 0000000000..d4de2e4845 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A9_T1.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. + +/*--- +info: | + Using "break" within "try/catch" statement that is nested in a loop is + allowed +es5id: 12.8_A9_T1 +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) { + throw new Test262Error('#1: break inside of try-catch nested in loop is allowed'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/break/S12.8_A9_T2.js b/js/src/tests/test262/language/statements/break/S12.8_A9_T2.js new file mode 100644 index 0000000000..3fab376942 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/S12.8_A9_T2.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. + +/*--- +info: | + Using "break" within "try/catch" statement that is nested in a loop is + allowed +es5id: 12.8_A9_T2 +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) { + throw new Test262Error('#1: break inside of try-catch nested in loop is allowed'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/break/browser.js b/js/src/tests/test262/language/statements/break/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/browser.js diff --git a/js/src/tests/test262/language/statements/break/line-terminators.js b/js/src/tests/test262/language/statements/break/line-terminators.js new file mode 100644 index 0000000000..8384b5e389 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/line-terminators.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Since LineTerminator between "break" and Identifier is not allowed, + "break" is evaluated without label +es5id: 12.8_A2 +description: > + Checking by using eval, inserting LineTerminator between break and + Identifier +---*/ + +FOR1 : for(var i=1;i<2;i++){ + LABEL1 : do { + break +FOR1; + } while(0); +} + +assert.sameValue(i, 2, '#1: Since LineTerminator(U-000A) between break and Identifier not allowed break evaluates without label'); + +FOR2 : for(var i=1;i<2;i++){ + LABEL2 : do { + break
FOR2; + } while(0); +} + +assert.sameValue(i, 2, '#2: Since LineTerminator(U-000D) between break and Identifier not allowed break evaluates without label'); + +FOR3 : for(var i=1;i<2;i++){ + LABEL3 : do { + break
FOR3; + } while(0); +} + +assert.sameValue(i, 2, '#3: Since LineTerminator(U-2028) between break and Identifier not allowed break evaluates without label'); + +FOR4 : for(var i=1;i<2;i++){ + LABEL4 : do { + break
FOR4; + } while(0); +} + +assert.sameValue(i, 2, '#4: Since LineTerminator(U-2029) between break and Identifier not allowed break evaluates without label'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/break/shell.js b/js/src/tests/test262/language/statements/break/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/break/shell.js diff --git a/js/src/tests/test262/language/statements/break/static-init-without-label.js b/js/src/tests/test262/language/statements/break/static-init-without-label.js new file mode 100644 index 0000000000..1ac535755c --- /dev/null +++ b/js/src/tests/test262/language/statements/break/static-init-without-label.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-break-statement +description: IterationStatement search does not traverse static initialization block boundaries (no label specified) +info: | + 4.2.1 Static Semantics: Early Errors + BreakStatement : break ; + + - It is a Syntax Error if this BreakStatement is not nested, directly or + indirectly (but not crossing function or static initialization block + boundaries), within an IterationStatement or a SwitchStatement. +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +label: while(false) { + class C { + static { + break; + } + } +} |