diff options
Diffstat (limited to 'js/src/tests/test262/ch12/12.9')
-rw-r--r-- | js/src/tests/test262/ch12/12.9/12.9-1.js | 25 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A1_T1.js | 17 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A1_T10.js | 17 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A1_T2.js | 19 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A1_T3.js | 21 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A1_T4.js | 17 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A1_T5.js | 21 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A1_T6.js | 21 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A1_T7.js | 21 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A1_T8.js | 21 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A1_T9.js | 21 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A2.js | 55 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A3.js | 20 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A4.js | 28 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/S12.9_A5.js | 40 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/test262/ch12/12.9/shell.js | 0 |
17 files changed, 364 insertions, 0 deletions
diff --git a/js/src/tests/test262/ch12/12.9/12.9-1.js b/js/src/tests/test262/ch12/12.9/12.9-1.js new file mode 100644 index 000000000..098042e93 --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/12.9-1.js @@ -0,0 +1,25 @@ +/// 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.9/12.9-1.js
+ * @description The return Statement - a return statement without an expression may have a LineTerminator before the semi-colon
+ */
+
+
+function testcase() {
+ var sum = 0;
+ (function innerTest() {
+ for (var i = 1; i <= 10; i++) {
+ if (i === 6) {
+ return
+ ;
+ }
+ sum += i;
+ }
+ })();
+ return sum === 15;
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A1_T1.js b/js/src/tests/test262/ch12/12.9/S12.9_A1_T1.js new file mode 100644 index 000000000..a4115f7ec --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A1_T1.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Appearing of "return" without a function body leads to syntax error + * + * @path ch12/12.9/S12.9_A1_T1.js + * @description Checking if execution of "return" with no function fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +var x=1; +return; +var y=2; + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A1_T10.js b/js/src/tests/test262/ch12/12.9/S12.9_A1_T10.js new file mode 100644 index 000000000..63bcd816c --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A1_T10.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Appearing of "return" without a function body leads to syntax error + * + * @path ch12/12.9/S12.9_A1_T10.js + * @description Checking if execution of "return (0)" with no function fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +return (0); +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A1_T2.js b/js/src/tests/test262/ch12/12.9/S12.9_A1_T2.js new file mode 100644 index 000000000..74f657b60 --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A1_T2.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 "return" without a function body leads to syntax error + * + * @path ch12/12.9/S12.9_A1_T2.js + * @description Checking if execution of "return x" with no function fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +var x=1; +return x; +var y=2; +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A1_T3.js b/js/src/tests/test262/ch12/12.9/S12.9_A1_T3.js new file mode 100644 index 000000000..8f22b8859 --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_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 "return" without a function body leads to syntax error + * + * @path ch12/12.9/S12.9_A1_T3.js + * @description Checking if execution of "return" within "try" statement fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + return 1; +} catch(e){ + return 1; +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A1_T4.js b/js/src/tests/test262/ch12/12.9/S12.9_A1_T4.js new file mode 100644 index 000000000..3add975cb --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A1_T4.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Appearing of "return" without a function body leads to syntax error + * + * @path ch12/12.9/S12.9_A1_T4.js + * @description Checking if execution of "return" with no function fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +return; +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A1_T5.js b/js/src/tests/test262/ch12/12.9/S12.9_A1_T5.js new file mode 100644 index 000000000..a53d7c764 --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A1_T5.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 "return" without a function body leads to syntax error + * + * @path ch12/12.9/S12.9_A1_T5.js + * @description Checking if execution of "return" with no function, placed into a Block, fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +{ + var x=1; + return; + var y=2; +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A1_T6.js b/js/src/tests/test262/ch12/12.9/S12.9_A1_T6.js new file mode 100644 index 000000000..aea6ec977 --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A1_T6.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 "return" without a function body leads to syntax error + * + * @path ch12/12.9/S12.9_A1_T6.js + * @description Checking if execution of "return" with no function, placed into a loop, fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +do { + var x=1; + return; + var y=2; +} while(0); +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A1_T7.js b/js/src/tests/test262/ch12/12.9/S12.9_A1_T7.js new file mode 100644 index 000000000..ad863d473 --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A1_T7.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 "return" without a function body leads to syntax error + * + * @path ch12/12.9/S12.9_A1_T7.js + * @description Checking if execution of "return x" with no function, placed inside Block, fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +{ + var x=1; + return x; + var y=2; +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A1_T8.js b/js/src/tests/test262/ch12/12.9/S12.9_A1_T8.js new file mode 100644 index 000000000..edfbd1660 --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A1_T8.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 "return" without a function body leads to syntax error + * + * @path ch12/12.9/S12.9_A1_T8.js + * @description Checking if execution of "return x" with no function, placed into a loop, fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +do { + var x=1; + return x; + var y=2; +} while(0); +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A1_T9.js b/js/src/tests/test262/ch12/12.9/S12.9_A1_T9.js new file mode 100644 index 000000000..57e39aee7 --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A1_T9.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 "return" without a function body leads to syntax error + * + * @path ch12/12.9/S12.9_A1_T9.js + * @description Checking if execution of "return", placed into a catch Block, fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + throw 1; +} catch(e){ + return e; +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A2.js b/js/src/tests/test262/ch12/12.9/S12.9_A2.js new file mode 100644 index 000000000..177205dbb --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A2.js @@ -0,0 +1,55 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * LineTerminator between return and Identifier_opt yields return without Identifier_opt + * + * @path ch12/12.9/S12.9_A2.js + * @description Checking by using eval, inserting LineTerminator between return and Variable + */ + +//CHECK#1 +try{ + if (eval("(function(){var x = 1;return\u000Ax;var y=2;})()") !== undefined) { + $ERROR("#1: LineTerminator(U-000A) between return and Identifier_opt yields return without Identifier_opt"); + } +} catch(e){ + $ERROR('#1: eval("(function(){var x = 1;return\\u000Ax;var y=2;})()") does not lead to throwing exception'); +} + + + + +//CHECK#2 +try{ + if (eval("(function(){var x = 1;return\u000Dx;var y=2;})()") !== undefined) { + $ERROR("#1: LineTerminator(U-000D) between return and Identifier_opt yields return without Identifier_opt"); + } +} catch(e){ + $ERROR('#2: eval("(function(){var x = 1;return\\u000Dx;var y=2;})()") does not lead to throwing exception'); +} + + + + +//CHECK#3 +try{ + if (eval("(function(){var x = 1;return\u2028x;var y=2;})()") !== undefined) { + $ERROR("#1: LineTerminator(U-2028) between return and Identifier_opt yields return without Identifier_opt"); + } +} catch(e){ + $ERROR('#3: eval("(function(){var x = 1;return\\u2028x;var y=2;})()") does not lead to throwing exception'); +} + + + + +//CHECK#4 +try{ + if (eval("(function(){var x =1;return\u2029x;var y=2;})()") !== undefined) { + $ERROR("#1: LineTerminator(U-2029) between return and Identifier_opt yields return without Identifier_opt"); + } +} catch(e){ + $ERROR('#4: eval("(function(){var x =1;return\\u2029x;var y=2;})()") does not lead to throwing exception'); +} + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A3.js b/js/src/tests/test262/ch12/12.9/S12.9_A3.js new file mode 100644 index 000000000..95b87c363 --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * If Expression is omitted, the return value is undefined + * + * @path ch12/12.9/S12.9_A3.js + * @description Return without Expression + */ + +__evaluated = (function (){return;})(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__evaluated !== undefined) { + $ERROR('#1: If Expression is omitted, the return value is undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A4.js b/js/src/tests/test262/ch12/12.9/S12.9_A4.js new file mode 100644 index 000000000..97c923979 --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_A4.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * The production ReturnStatement : return Expression; is evaluated as: + * i) Evaluate Expression. + * ii) Call GetValue(Result(2)). + * iii) Return (return, Result(3), empty) + * + * @path ch12/12.9/S12.9_A4.js + * @description Return very sophisticated expression and function + */ + +// second derivative +function DD_operator(f, delta){return function(x){return (f(x+delta)-2*f(x)+f(x-delta))/(delta*delta)};} + +DDsin = DD_operator(Math.sin, 0.00001); + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +// ((sin(x))')' = -sin(x) +if (DDsin( Math.PI/2 ) + Math.sin( Math.PI/2 ) > 0.00001) { + $ERROR('#1: return Expression yields to Return (return, GetValue(Evaluate Expression), empty)'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.9/S12.9_A5.js b/js/src/tests/test262/ch12/12.9/S12.9_A5.js new file mode 100644 index 000000000..3b0b98e43 --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/S12.9_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. + +/** + * Code after ReturnStatement is not evaluated + * + * @path ch12/12.9/S12.9_A5.js + * @description Using code after Return statement + */ + +//CHECK#1 +var x1=1; +function myfunc1(){ + x1++; + return; + x1*=2; +} +myfunc1(); +if (x1!==2) $ERROR('#1: x1 === 2. Actual: x1 ==='+ x1 ); + +//CHECK#2 +var x2=1; +function myfunc2(){ + x2++; + return x2; + x2*=2; +} +myfunc2(); +if (x2!==2) $ERROR('#2: x2 === 2. Actual: x2 ==='+ x2 ); + +//CHECK#3 +var x3=1; +function myfunc3(){ + x3++; + return; + return x3; + x3*=2; +} +if (myfunc3()!==undefined) $ERROR('#3: myfunc3() === undefined. Actual: myfunc3() ==='+ myfunc3() ); + diff --git a/js/src/tests/test262/ch12/12.9/browser.js b/js/src/tests/test262/ch12/12.9/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/browser.js diff --git a/js/src/tests/test262/ch12/12.9/shell.js b/js/src/tests/test262/ch12/12.9/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch12/12.9/shell.js |