diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/test262/ch12/12.14 | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/test262/ch12/12.14')
84 files changed, 4424 insertions, 0 deletions
diff --git a/js/src/tests/test262/ch12/12.14/12.14-1.js b/js/src/tests/test262/ch12/12.14/12.14-1.js new file mode 100644 index 000000000..47bff810b --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-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.14/12.14-1.js
+ * @description catch doesn't change declaration scope - var initializer in catch with same name as catch parameter changes parameter
+ */
+
+
+function testcase() {
+ foo = "prior to throw";
+ try {
+ throw new Error();
+ }
+ catch (foo) {
+ var foo = "initializer in catch";
+ }
+ return foo === "prior to throw";
+
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-10.js b/js/src/tests/test262/ch12/12.14/12.14-10.js new file mode 100644 index 000000000..1bdf8273d --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-10.js @@ -0,0 +1,31 @@ +/// 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.14/12.14-10.js
+ * @description catch introduces scope - name lookup finds function parameter
+ */
+
+
+function testcase() {
+ function f(o) {
+
+ function innerf(o, x) {
+ try {
+ throw o;
+ }
+ catch (e) {
+ return x;
+ }
+ }
+
+ return innerf(o, 42);
+ }
+
+ if (f({}) === 42) {
+ return true;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-11.js b/js/src/tests/test262/ch12/12.14/12.14-11.js new file mode 100644 index 000000000..6fded5bee --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-11.js @@ -0,0 +1,33 @@ +/// 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.14/12.14-11.js
+ * @description catch introduces scope - name lookup finds inner variable
+ */
+
+
+function testcase() {
+ function f(o) {
+
+ function innerf(o) {
+ var x = 42;
+
+ try {
+ throw o;
+ }
+ catch (e) {
+ return x;
+ }
+ }
+
+ return innerf(o);
+ }
+
+ if (f({}) === 42) {
+ return true;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-12.js b/js/src/tests/test262/ch12/12.14/12.14-12.js new file mode 100644 index 000000000..c92580cfe --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-12.js @@ -0,0 +1,31 @@ +/// 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.14/12.14-12.js
+ * @description catch introduces scope - name lookup finds property
+ */
+
+
+function testcase() {
+ function f(o) {
+
+ function innerf(o) {
+ try {
+ throw o;
+ }
+ catch (e) {
+ return e.x;
+ }
+ }
+
+ return innerf(o);
+ }
+
+ if (f({x:42}) === 42) {
+ return true;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-13.js b/js/src/tests/test262/ch12/12.14/12.14-13.js new file mode 100644 index 000000000..3efb98913 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-13.js @@ -0,0 +1,42 @@ +/// 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.14/12.14-13.js
+ * @description catch introduces scope - updates are based on scope
+ */
+
+
+function testcase() {
+ var res1 = false;
+ var res2 = false;
+ var res3 = false;
+
+ var x_12_14_13 = 'local';
+ try {
+ function foo() {
+ this.x_12_14_13 = 'instance';
+ }
+
+ try {
+ throw foo;
+ }
+ catch (e) {
+ res1 = (x_12_14_13 === 'local');
+ e();
+ res2 = (x_12_14_13 === 'local');
+ }
+ res3 = (x_12_14_13 === 'local');
+
+ if (res1 === true &&
+ res2 === true &&
+ res3 === true) {
+ return true;
+ }
+ } finally {
+ delete this.x_12_14_13;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-14.js b/js/src/tests/test262/ch12/12.14/12.14-14.js new file mode 100644 index 000000000..40b2c82c8 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-14.js @@ -0,0 +1,26 @@ +/// 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.14/12.14-14.js
+ * @description Exception object is a function, when an exception parameter is called as a function in catch block, global object is passed as the this value
+ */
+
+
+function testcase() {
+ try {
+ throw function () {
+ this._12_14_14_foo = "test";
+ };
+ return false;
+ } catch (e) {
+ e();
+ return fnGlobalObject()._12_14_14_foo === "test";
+ }
+ finally {
+ delete fnGlobalObject()._12_14_14_foo;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-15.js b/js/src/tests/test262/ch12/12.14/12.14-15.js new file mode 100644 index 000000000..e4397c17c --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-15.js @@ -0,0 +1,28 @@ +/// 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.14/12.14-15.js
+ * @description Exception object is a function which is a property of an object, when an exception parameter is called as a function in catch block, global object is passed as the this value
+ */
+
+
+function testcase() {
+ var obj = {};
+ obj.test = function () {
+ this._12_14_15_foo = "test";
+ };
+ try {
+ throw obj.test;
+ return false;
+ } catch (e) {
+ e();
+ return fnGlobalObject()._12_14_15_foo === "test";
+ }
+ finally {
+ delete fnGlobalObject()._12_14_15_foo;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-16.js b/js/src/tests/test262/ch12/12.14/12.14-16.js new file mode 100644 index 000000000..e160e3d37 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-16.js @@ -0,0 +1,32 @@ +/// 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.14/12.14-16.js
+ * @description Exception object is a function which update in catch block, when an exception parameter is called as a function in catch block, global object is passed as the this value
+ */
+
+
+function testcase() {
+ try {
+ throw function () {
+ this._12_14_16_foo = "test";
+ };
+ return false;
+ } catch (e) {
+ var obj = {};
+ obj.test = function () {
+ this._12_14_16_foo = "test1";
+ };
+ e = obj.test;
+ e();
+ return fnGlobalObject()._12_14_16_foo === "test1";
+ }
+ finally {
+ delete fnGlobalObject()._12_14_16_foo;
+ }
+
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-2.js b/js/src/tests/test262/ch12/12.14/12.14-2.js new file mode 100644 index 000000000..16d08d34c --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-2.js @@ -0,0 +1,24 @@ +/// 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.14/12.14-2.js
+ * @description catch doesn't change declaration scope - var initializer in catch with same name as catch parameter changes parameter
+ */
+
+
+function testcase() {
+ function capturedFoo() {return foo};
+ foo = "prior to throw";
+ try {
+ throw new Error();
+ }
+ catch (foo) {
+ var foo = "initializer in catch";
+ return capturedFoo() !== "initializer in catch";
+ }
+
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-3.js b/js/src/tests/test262/ch12/12.14/12.14-3.js new file mode 100644 index 000000000..6cd541061 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-3.js @@ -0,0 +1,30 @@ +/// 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.
+/**
+ * local vars must not be visible outside with block
+ * local functions must not be visible outside with block
+ * local function expresssions should not be visible outside with block
+ * local vars must shadow outer vars
+ * local functions must shadow outer functions
+ * local function expresssions must shadow outer function expressions
+ * eval should use the appended object to the scope chain
+ *
+ * @path ch12/12.14/12.14-3.js
+ * @description catch doesn't change declaration scope - var declaration are visible outside when name different from catch parameter
+ */
+
+
+function testcase() {
+ try {
+ throw new Error();
+ }
+ catch (e) {
+ var foo = "declaration in catch";
+ }
+
+ return foo === "declaration in catch";
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-4.js b/js/src/tests/test262/ch12/12.14/12.14-4.js new file mode 100644 index 000000000..1d3cb1b16 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-4.js @@ -0,0 +1,34 @@ +/// 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.
+/**
+ * local vars must not be visible outside with block
+ * local functions must not be visible outside with block
+ * local function expresssions should not be visible outside with block
+ * local vars must shadow outer vars
+ * local functions must shadow outer functions
+ * local function expresssions must shadow outer function expressions
+ * eval should use the appended object to the scope chain
+ *
+ * @path ch12/12.14/12.14-4.js
+ * @description catch introduces scope - block-local vars must shadow outer vars
+ */
+
+
+function testcase() {
+ var o = { foo : 42};
+
+ try {
+ throw o;
+ }
+ catch (e) {
+ var foo;
+
+ if (foo === undefined) {
+ return true;
+ }
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-6.js b/js/src/tests/test262/ch12/12.14/12.14-6.js new file mode 100644 index 000000000..ae31f846e --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-6.js @@ -0,0 +1,33 @@ +/// 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.
+/**
+ * local vars must not be visible outside with block
+ * local functions must not be visible outside with block
+ * local function expresssions should not be visible outside with block
+ * local vars must shadow outer vars
+ * local functions must shadow outer functions
+ * local function expresssions must shadow outer function expressions
+ * eval should use the appended object to the scope chain
+ *
+ * @path ch12/12.14/12.14-6.js
+ * @description catch introduces scope - block-local function expression must shadow outer function expression
+ */
+
+
+function testcase() {
+ var o = {foo : function () { return 42;}};
+
+ try {
+ throw o;
+ }
+ catch (e) {
+ var foo = function () {};
+ if (foo() === undefined) {
+ return true;
+ }
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-7.js b/js/src/tests/test262/ch12/12.14/12.14-7.js new file mode 100644 index 000000000..b7f8dbc36 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-7.js @@ -0,0 +1,39 @@ +/// 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.
+/**
+ * local vars must not be visible outside with block
+ * local functions must not be visible outside with block
+ * local function expresssions should not be visible outside with block
+ * local vars must shadow outer vars
+ * local functions must shadow outer functions
+ * local function expresssions must shadow outer function expressions
+ * eval should use the appended object to the scope chain
+ *
+ * @path ch12/12.14/12.14-7.js
+ * @description catch introduces scope - scope removed when exiting catch block
+ */
+
+
+function testcase() {
+ var o = {foo: 1};
+ var catchAccessed = false;
+
+ try {
+ throw o;
+ }
+ catch (expObj) {
+ catchAccessed = (expObj.foo == 1);
+ }
+
+ try {
+ expObj;
+ }
+ catch (e) {
+ return catchAccessed && e instanceof ReferenceError
+ }
+ return false;
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-8.js b/js/src/tests/test262/ch12/12.14/12.14-8.js new file mode 100644 index 000000000..d2e059cd9 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-8.js @@ -0,0 +1,34 @@ +/// 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.
+/**
+ * local vars must not be visible outside with block
+ * local functions must not be visible outside with block
+ * local function expresssions should not be visible outside with block
+ * local vars must shadow outer vars
+ * local functions must shadow outer functions
+ * local function expresssions must shadow outer function expressions
+ * eval should use the appended object to the scope chain
+ *
+ * @path ch12/12.14/12.14-8.js
+ * @description catch introduces scope - scope removed when exiting catch block (properties)
+ */
+
+
+function testcase() {
+ var o = {foo: 42};
+
+ try {
+ throw o;
+ }
+ catch (e) {
+ var foo = 1;
+ }
+
+ if (o.foo === 42) {
+ return true;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14-9.js b/js/src/tests/test262/ch12/12.14/12.14-9.js new file mode 100644 index 000000000..2236dd169 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14-9.js @@ -0,0 +1,32 @@ +/// 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.14/12.14-9.js
+ * @description catch introduces scope - name lookup finds outer variable
+ */
+
+
+function testcase() {
+ function f(o) {
+ var x = 42;
+
+ function innerf(o) {
+ try {
+ throw o;
+ }
+ catch (e) {
+ return x;
+ }
+ }
+
+ return innerf(o);
+ }
+
+ if (f({}) === 42) {
+ return true;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-1-s.js b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-1-s.js new file mode 100644 index 000000000..894a13501 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-1-s.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.14/12.14.1/12.14.1-1-s.js
+ * @description Strict Mode - SyntaxError is thrown if a TryStatement with a Catch occurs within strict code and the Identifier of the Catch production is eval
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ "use strict";
+
+ try {
+ eval("\
+ try {} catch (eval) { }\
+ ");
+ return false;
+ } catch (e) {
+ return e instanceof SyntaxError;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-1gs.js b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-1gs.js new file mode 100644 index 000000000..04708c31e --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-1gs.js @@ -0,0 +1,16 @@ +/// 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.14/12.14.1/12.14.1-1gs.js
+ * @description Strict Mode - SyntaxError is thrown if a TryStatement with a Catch occurs within strict code and the Identifier of the Catch production is eval
+ * @onlyStrict
+ * @negative ^((?!NotEarlyError).)*$
+ */
+
+"use strict";
+throw NotEarlyError;
+try { } catch (eval) { }
diff --git a/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-2-s.js b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-2-s.js new file mode 100644 index 000000000..b0e660bd0 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-2-s.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.14/12.14.1/12.14.1-2-s.js
+ * @description Strict Mode - SyntaxError is thrown if a TryStatement with a Catch occurs within strict code and the Identifier of the Catch production is arguments
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ "use strict";
+
+ try {
+ eval("\
+ try {} catch (arguments) { }\
+ ");
+ return false;
+ } catch (e) {
+ return e instanceof SyntaxError;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-3-s.js b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-3-s.js new file mode 100644 index 000000000..3c477785b --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-3-s.js @@ -0,0 +1,33 @@ +/// 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.14/12.14.1/12.14.1-3-s.js
+ * @description Strict Mode - SyntaxError isn't thrown if a TryStatement with a Catch occurs within strict code and the Identifier of the Catch production is EVAL but throws SyntaxError if it is eval
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ "use strict";
+
+ try{ eval(" try { \
+ throw new Error(\"...\");\
+ return false;\
+ } catch (EVAL) {\
+ try\
+ {\
+ throw new Error(\"...\");\
+ }catch(eval)\
+ {\
+ return EVAL instanceof Error;\
+ }\
+ }");
+ return false;
+ } catch(e) {
+ return e instanceof SyntaxError;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-4-s.js b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-4-s.js new file mode 100644 index 000000000..58f372cba --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-4-s.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.14/12.14.1/12.14.1-4-s.js
+ * @description Strict Mode - SyntaxError isn't thrown if a TryStatement with a Catch occurs within strict code and the Identifier of the Catch production is EVAL
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ "use strict";
+
+ try {
+ throw new Error("...");
+ return false;
+ } catch (EVAL) {
+ return EVAL instanceof Error;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-5-s.js b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-5-s.js new file mode 100644 index 000000000..84e85593a --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-5-s.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.14/12.14.1/12.14.1-5-s.js
+ * @description Strict Mode - SyntaxError isn't thrown if a TryStatement with a Catch occurs within strict code and the Identifier of the Catch production is Arguments
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ "use strict";
+
+ try {
+ throw new Error("...");
+ return false;
+ } catch (Arguments) {
+ return Arguments instanceof Error;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-6-s.js b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-6-s.js new file mode 100644 index 000000000..edd8bb558 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14.1/12.14.1-6-s.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.14/12.14.1/12.14.1-6-s.js
+ * @description Strict Mode - SyntaxError isn't thrown if a TryStatement with a Catch occurs within strict code and the Identifier of the Catch production is ARGUMENTS
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ "use strict";
+
+ try {
+ throw new Error("...");
+ return false;
+ } catch (ARGUMENTS) {
+ return ARGUMENTS instanceof Error;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch12/12.14/12.14.1/browser.js b/js/src/tests/test262/ch12/12.14/12.14.1/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14.1/browser.js diff --git a/js/src/tests/test262/ch12/12.14/12.14.1/shell.js b/js/src/tests/test262/ch12/12.14/12.14.1/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/12.14.1/shell.js diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A1.js b/js/src/tests/test262/ch12/12.14/S12.14_A1.js new file mode 100644 index 000000000..894376009 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A1.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * The production TryStatement : try Block Catch is evaluated as follows: 2. If Result(1).type is not throw, return Result(1) + * + * @path ch12/12.14/S12.14_A1.js + * @description Executing TryStatement : try Block Catch. The statements doesn't cause actual exceptions + */ + +// CHECK#1 +try { + var x=0; +} +catch (e) { + $ERROR('#1: If Result(1).type is not throw, return Result(1). Actual: 4 Return(Result(3))'); +} + +// CHECK#2 +var c1=0; +try{ + var x1=1; +} +finally +{ + c1=1; +} +if(x1!==1){ + $ERROR('#2.1: "try" block must be evaluated. Actual: try Block has not been evaluated'); +} +if (c1!==1){ + $ERROR('#2.2: "finally" block must be evaluated. Actual: finally Block has not been evaluated'); +} + +// CHECK#3 +var c2=0; +try{ + var x2=1; +} +catch(e){ + $ERROR('#3.1: If Result(1).type is not throw, return Result(1). Actual: 4 Return(Result(3))'); +} +finally{ + c2=1; +} +if(x2!==1){ + $ERROR('#3.2: "try" block must be evaluated. Actual: try Block has not been evaluated'); +} +if (c2!==1){ + $ERROR('#3.3: "finally" block must be evaluated. Actual: finally Block has not been evaluated'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A10_T1.js b/js/src/tests/test262/ch12/12.14/S12.14_A10_T1.js new file mode 100644 index 000000000..c7a7c4651 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A10_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "while" statement + * + * @path ch12/12.14/S12.14_A10_T1.js + * @description Throwing exception while executing iteration statement placed into try Block + */ + +// CHECK#1 +var i=0; +try{ +while(i<10){ + if(i===5) throw i; + i++; +} +} +catch(e){ + if(e!==5)$ERROR('#1: Exception === 5. Actual: Exception ==='+ e ); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A10_T2.js b/js/src/tests/test262/ch12/12.14/S12.14_A10_T2.js new file mode 100644 index 000000000..1826b48a8 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A10_T2.js @@ -0,0 +1,116 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "while" statement + * + * @path ch12/12.14/S12.14_A10_T2.js + * @description Try statement inside loop, where use continue loop + */ + +// CHECK#1 +var c1=0,fin=0; +while(c1<2){ + try{ + c1+=1; + continue; + } + catch(er1){} + finally{ + fin=1; + } + fin=-1; +}; +if(fin!==1){ + $ERROR('#1: "finally" block must be evaluated at "try{continue} catch finally" construction'); +} + +// CHECK#2 +var c2=0,fin2=0; +while(c2<2){ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + continue; + } + finally{ + fin2=1; + } + fin2=-1; +} +if(fin2!==1){ + $ERROR('#2: "finally" block must be evaluated at "try catch{continue} finally" construction'); +} + +// CHECK#3 +var c3=0,fin3=0; +while(c3<2){ + try{ + throw "ex1"; + } + catch(er1){ + c3+=1; + } + finally{ + fin3=1; + continue; + } + fin3=0; +} +if(fin3!==1){ + $ERROR('#3: "finally" block must be evaluated at "try catch finally{continue}" construction'); +} + +// CHECK#4 +var c4=0,fin4=0; +while(c4<2){ + try{ + c4+=1; + continue; + } + finally{ + fin4=1; + } + fin4=-1; +}; +if(fin4!==1){ + $ERROR('#4: "finally" block must be evaluated at "try{continue} finally" construction'); +} + +// CHECK#5 +var c5=0; +while(c5<2){ + try{ + throw "ex1"; + } + catch(er1){ + c5+=1; + continue; + } +} +if(c5!==2){ + $ERROR('#5: "try catch{continue}" must work correctly'); +} + +// CHECK#6 +var c6=0,fin6=0; +while(c6<2){ + try{ + c6+=1; + throw "ex1" + } + finally{ + fin6=1; + continue; + } + fin6=-1; +} +if(fin6!==1){ + $ERROR('#6.1: "finally" block must be evaluated'); +} +if(c6!==2){ + $ERROR('#6.2: "try finally{continue}" must work correctly'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A10_T3.js b/js/src/tests/test262/ch12/12.14/S12.14_A10_T3.js new file mode 100644 index 000000000..88e56168a --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A10_T3.js @@ -0,0 +1,151 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "while" statement + * + * @path ch12/12.14/S12.14_A10_T3.js + * @description Try statement inside loop, where use break + */ + +// CHECK#1 +var c1=0,fin=0; +while(c1<2){ + try{ + c1+=1; + break; + } + catch(er1){} + finally{ + fin=1; + } + fin=-1; + c1+=2; +} +if(fin!==1){ + $ERROR('#1.1: "finally" block must be evaluated'); +} +if(c1!==1){ + $ERROR('#1.2: "try{break}catch finally" must work correctly'); +} + +// CHECK#2 +var c2=0,fin2=0; +while(c2<2){ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + break; + } + finally{ + fin2=1; + } + c2+=2; + fin2=-1; +} +if(fin2!==1){ + $ERROR('#2.1: "finally" block must be evaluated'); +} +if(c2!==1){ + $ERROR('#2.2: "try catch{break} finally" must work correctly'); +} + +// CHECK#3 +var c3=0,fin3=0; +while(c3<2){ + try{ + throw "ex1"; + } + catch(er1){ + c3+=1; + } + finally{ + fin3=1; + break; + } + c3+=2; + fin3=0; +} +if(fin3!==1){ + $ERROR('#3.1: "finally" block must be evaluated'); +} +if(c3!==1){ + $ERROR('#3.2: "try catch finally{break}" must work correctly'); +} + +// CHECK#4 +var c4=0,fin4=0; +while(c4<2){ + try{ + c4+=1; + break; + } + finally{ + fin4=1; + } + fin4=-1; + c4+=2; +} +if(fin4!==1){ + $ERROR('#4.1: "finally" block must be evaluated'); +} +if(c4!==1){ + $ERROR('#4.2: "try{break} finally" must work correctly'); +} + +// CHECK#5 +var c5=0; +while(c5<2){ + try{ + throw "ex1"; + } + catch(er1){ + break; + } +} +if(c5!==0){ + $ERROR('#5: "try catch{break}" must work correctly'); +} + +// CHECK#6 +var c6=0; +while(c6<2){ + try{ + c6+=1; + break; + } + catch(er1){} + c6+=2; +} +if(c6!==1){ + $ERROR('#6: "try{break} catch" must work correctly'); +} + +// CHECK#7 +var c7=0,fin7=0; +try{ + while(c7<2){ + try{ + c7+=1; + throw "ex1"; + } + finally{ + fin7=1; + break; + } + fin7=-1; + c7+=2; + } +} +catch(ex1){ + c7=10; +} +if(fin7!==1){ + $ERROR('#7.1: "finally" block must be evaluated'); +} +if(c7!==1){ + $ERROR('#7.2: "try finally{break}" must work correctly'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A10_T4.js b/js/src/tests/test262/ch12/12.14/S12.14_A10_T4.js new file mode 100644 index 000000000..926e564d3 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A10_T4.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "while" statement + * + * @path ch12/12.14/S12.14_A10_T4.js + * @description Try statement inside loop, where combinate using break and continue + */ + +// CHECK#1 +var c1=0,fin=0; +while(c1<2){ + try{ + c1+=1; + break; + } + catch(er1){} + finally{ + fin=1; + continue; + } + fin=-1; + c1+=2; +} +if(fin!==1){ + $ERROR('#1.1: "finally" block must be evaluated'); +} +if(c1!==2){ + $ERROR('#1.2: "try{break} catch finally{continue}" must work correctly'); +} + +// CHECK#2 +var c2=0,fin2=0; +while(c2<2){ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + break; + } + finally{ + fin2=1; + continue; + } + c2+=2; + fin2=-1; +} +if(fin2!==1){ + $ERROR('#2.1: "finally" block must be evaluated'); +} +if(c2!==2){ + $ERROR('#2.2: "try catch{break} finally{continue} must work correctly'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A10_T5.js b/js/src/tests/test262/ch12/12.14/S12.14_A10_T5.js new file mode 100644 index 000000000..e840e9395 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A10_T5.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "while" statement + * + * @path ch12/12.14/S12.14_A10_T5.js + * @description Throw some exceptions from different place of loop body + */ + +// CHECK#1 +var c=0, i=0; +var fin=0; +while(i<10){ + i+=1; + try{ + if(c===0){ + throw "ex1"; + $ERROR('#1.1: throw "ex1" lead to throwing exception'); + } + c+=2; + if(c===1){ + throw "ex2"; + $ERROR('#1.2: throw "ex2" lead to throwing exception'); + } + } + catch(er1){ + c-=1; + continue; + $ERROR('#1.3: "try catch{continue} finally" must work correctly'); + } + finally{ + fin+=1; + } +} +if(fin!==10){ + $ERROR('#1.4: "finally" block must be evaluated'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A11_T1.js b/js/src/tests/test262/ch12/12.14/S12.14_A11_T1.js new file mode 100644 index 000000000..41cfdb0a5 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A11_T1.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. + +/** + * Using "try" with "catch" or "finally" statement within/without a "for" statement + * + * @path ch12/12.14/S12.14_A11_T1.js + * @description Loop inside try Block, where throw exception + */ + +// CHECK#1 +try{ + for(var i=0;i<10;i++){ + if(i===5) throw i; + } +} +catch(e){ + if(e!==5)$ERROR('#1: Exception === 5. Actual: Exception ==='+ e ); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A11_T2.js b/js/src/tests/test262/ch12/12.14/S12.14_A11_T2.js new file mode 100644 index 000000000..7453936fd --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A11_T2.js @@ -0,0 +1,123 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "for" statement + * + * @path ch12/12.14/S12.14_A11_T2.js + * @description Try statement inside loop, where use continue loop + */ + +// CHECK#1 +var fin=0; +for(var i=0;i<5;i++){ + try{ + i+=1; + continue; + } + catch(er1){} + finally{ + fin=1; + } + fin=-1; +} +if(fin!==1){ + $ERROR('#1: "finally" block must be evaluated at "try{continue} catch finally" construction'); +} + +// CHECK#2 +var c2=0,fin2=0; +for(var i=0;i<5;i++){ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + continue; + } + finally{ + fin2=1; + } + fin2=-1; +} +if(fin2!==1){ + $ERROR('#2.1: "finally" block must be evaluated'); +} +if(c2!==5){ + $ERROR('#2.1: "try catch{continue} finally" must work correctly'); +} + +// CHECK#3 +var c3=0,fin3=0; +for(var i=0;i<5;i++){ + try{ + throw "ex1"; + } + catch(er1){ + c3+=1; + } + finally{ + fin3=1; + continue; + } + fin3=0; +} +if(fin3!==1){ + $ERROR('#3.1: "finally" block must be evaluated'); +} +if(c3!==5){ + $ERROR('#3.2: "try catch finally{continue}" must work correctly'); +} + +// CHECK#4 +var fin=0; +for(var i=0;i<5;i++){ + try{ + i+=1; + continue; + } + finally{ + fin=1; + } + fin=-1; +}; +if(fin!==1){ + $ERROR('#4: "finally" block must be evaluated at "try{continue} finally" construction'); +} + +// CHECK#5 +var c5=0; +for(var c5=0;c5<10;){ + try{ + throw "ex1"; + } + catch(er1){ + c5+=1; + continue; + } + c5+=12; +}; +if(c5!==10){ + $ERROR('#5: "try catch{continue} must work correctly'); +} + +// CHECK#6 +var c6=0,fin6=0; +for(var c6=0;c6<10;){ + try{ + c6+=1; + throw "ex1" + } + finally{ + fin6=1; + continue; + } + fin6=-1; +}; +if(fin6!==1){ + $ERROR('#6.1: "finally" block must be evaluated'); +} +if(c6!==10){ + $ERROR('#6.2: "try finally{continue}" must work correctly'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A11_T3.js b/js/src/tests/test262/ch12/12.14/S12.14_A11_T3.js new file mode 100644 index 000000000..af9976a2d --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A11_T3.js @@ -0,0 +1,150 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "for" statement + * + * @path ch12/12.14/S12.14_A11_T3.js + * @description Try statement inside loop, where use break + */ + +// CHECK#1 +var c1=0,fin=0; +for(var i=0;i<5;i++){ + try{ + c1+=1; + break; + } + catch(er1){} + finally{ + fin=1; + } + fin=-1; + c1+=2; +}; +if(fin!==1){ + $ERROR('#1.1: "finally" block must be evaluated'); +} +if(c1!==1){ + $ERROR('#1.2: "try{break}catch finally" must work correctly'); +} + +// CHECK#2 +var c2=0,fin2=0; +for(var i=0;i<5;i++){ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + break; + } + finally{ + fin2=1; + } + c2+=2; + fin2=-1; +}; +if(fin2!==1){ + $ERROR('#2.1: "finally" block must be evaluated'); +} +if(c2!==1){ + $ERROR('#2.2: "try catch{break} finally" must work correctly'); +} + +// CHECK#3 +var c3=0,fin3=0; +for(var i=0;i<5;i++){ + try{ + throw "ex1"; + } + catch(er1){ + c3+=1; + } + finally{ + fin3=1; + break; + } + c3+=2; + fin3=0; +}; +if(fin3!==1){ + $ERROR('#3.1: "finally" block must be evaluated'); +} +if(c3!==1){ + $ERROR('#3.2: "try catch finally{break}" must work correctly'); +} + +// CHECK#4 +var c4=0,fin4=0; +for(var i=0;i<5;i++){ + try{ + c4+=1; + break; + } + finally{ + fin4=1; + } + fin4=-1; + c4+=2; +}; +if(fin4!==1){ + $ERROR('#4.1: "finally" block must be evaluated'); +} +if(c4!==1){ + $ERROR('#4.2: "try{break} finally" must work correctly'); +} + +// CHECK#5 +for(var i=0;i<5;i++){ + try{ + throw "ex1"; + } + catch(er1){ + break; + } +}; +if(i!==0){ + $ERROR('#5: "try catch{break}" must work correctly'); +} + +// CHECK#6 +var c6=0; +for(var c6=0;c6<5;){ + try{ + c6+=1; + break; + } + catch(er1){} + c6+=2; +}; +if(c6!==1){ + $ERROR('#6: "try{break} catch" must work correctly'); +} + +// CHECK#7 +var c7=0,fin7=0; +try{ + for(var c7=0;c7<5;){ + try{ + c7+=1; + throw "ex1"; + } + finally{ + fin7=1; + break; + } + fin7=-1; + c7+=2; + } +} +catch(ex1){ + c7=10; +} +if(fin7!==1){ + $ERROR('#7.1: "finally" block must be evaluated'); +} +if(c7!==1){ + $ERROR('#7.2: "try finally{break}" must work correctly'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A11_T4.js b/js/src/tests/test262/ch12/12.14/S12.14_A11_T4.js new file mode 100644 index 000000000..6f4762beb --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A11_T4.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "for" statement + * + * @path ch12/12.14/S12.14_A11_T4.js + * @description Try statement inside loop, where combinate using break and continue + */ + +// CHECK#1 +var c1=0,fin=0; +for(var i=0;i<5;i++){ + try{ + c1+=1; + break; + } + catch(er1){} + finally{ + fin=1; + continue; + } + fin=-1; + c1+=2; +} +if(fin!==1){ + $ERROR('#1.1: "finally" block must be evaluated'); +} +if(c1!==5){ + $ERROR('#1.2: "try{break} catch finally{continue}" must work correctly'); +} + +// CHECK#2 +var c2=0,fin2=0; +for(var i=0;i<5;i++){ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + break; + } + finally{ + fin2=1; + continue; + } + c2+=2; + fin2=-1; +} +if(fin2!==1){ + $ERROR('#2.1: "finally" block must be evaluated'); +} +if(c2!==5){ + $ERROR('#2.2: "try catch{break} finally{continue}" must work correctly'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A12_T1.js b/js/src/tests/test262/ch12/12.14/S12.14_A12_T1.js new file mode 100644 index 000000000..b6906b1b8 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A12_T1.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. + +/** + * Using "try" with "catch" or "finally" statement within/without a "for-in" statement + * + * @path ch12/12.14/S12.14_A12_T1.js + * @description Loop inside try Block, where throw exception + */ + +var x; +var mycars = new Array(); +mycars[0] = "Saab"; +mycars[1] = "Volvo"; +mycars[2] = "BMW"; + +// CHECK#1 +try{ + for (x in mycars){ + if (mycars[x]==="BMW") throw "ex"; + } +} +catch(e){ + if(e!=="ex")$ERROR('#1: Exception ==="ex". Actual: Exception ==='+ e ); +} + + + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A12_T2.js b/js/src/tests/test262/ch12/12.14/S12.14_A12_T2.js new file mode 100644 index 000000000..6a6729962 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A12_T2.js @@ -0,0 +1,132 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "for-in" statement + * + * @path ch12/12.14/S12.14_A12_T2.js + * @description Try statement inside loop, where use continue loop + */ + +var x; +var mycars = new Array(); +mycars[0] = "Saab"; +mycars[1] = "Volvo"; +mycars[2] = "BMW"; + +// CHECK#1 +var fin=0; +var i=0; +for (x in mycars){ + try{ + i+=1; + continue; + } + catch(er1){} + finally{ + fin=1; + } + fin=-1; +} +if(fin!==1){ + $ERROR('#1.1: "finally" block must be evaluated'); +} +if(i!==3){ + $ERROR('#1.2: "try{continue} catch finally" must work correctly'); +} + +// CHECK#2 +var c2=0,fin2=0; +for (x in mycars){ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + continue; + } + finally{ + fin2=1; + } + fin2=-1; +} +if(fin2!==1){ + $ERROR('#2.1: "finally" block must be evaluated'); +} +if(c2!==3){ + $ERROR('#2.1: "try catch{continue} finally" must work correctly'); +} + +// CHECK#3 +var c3=0,fin3=0; +for (x in mycars){ + try{ + throw "ex1"; + } + catch(er1){ + c3+=1; + } + finally{ + fin3=1; + continue; + } + fin3=0; +} +if(c3!==3){ + $ERROR('#3.1: "finally" block must be evaluated'); +} +if(fin3!==1){ + $ERROR('#3.2: "try catch finally{continue}" must work correctly'); +} + +// CHECK#4 +var fin=0; +for (x in mycars){ + try{ + continue; + } + finally{ + fin=1; + } + fin=-1; +} +if(fin!==1){ + $ERROR('#4: "finally" block must be evaluated at "try{continue} finally" construction'); +} + +// CHECK#5 +var c5=0; +for (x in mycars){ + try{ + throw "ex1"; + } + catch(er1){ + c5+=1; + continue; + } + c5+=12; +} +if(c5!==3){ + $ERROR('#5: "try catch{continue}" must work correctly'); +} + +// CHECK#6 +var c6=0,fin6=0; +for (x in mycars){ + try{ + c6+=1; + throw "ex1"; + } + finally{ + fin6=1; + continue; + } + fin6=-1; +} +if(fin6!==1){ + $ERROR('#6.1: "finally" block must be evaluated'); +} +if(c6!==3){ + $ERROR('#6.2: "try finally{continue}" must work correctly'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A12_T3.js b/js/src/tests/test262/ch12/12.14/S12.14_A12_T3.js new file mode 100644 index 000000000..d3b4cea0c --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A12_T3.js @@ -0,0 +1,162 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "for-in" statement + * + * @path ch12/12.14/S12.14_A12_T3.js + * @description Try statement inside loop, where use break + */ + +var x; +var mycars = new Array(); +mycars[0] = "Saab"; +mycars[1] = "Volvo"; +mycars[2] = "BMW"; + +// CHECK#1 +var c1=0,fin=0; +for (x in mycars){ + try{ + c1+=1; + break; + } + catch(er1){ + c1+=1; + } + finally{ + fin=1; + } + fin=-1; + c1+=2; +}; +if(fin!==1){ + $ERROR('#1.1: "finally" block must be evaluated'); +} +if(c1!==1){ + $ERROR('#1.2: "try{break}catch finally" must work correctly'); +} + +// CHECK#2 +var c2=0,fin2=0; +for (x in mycars){ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + break; + } + finally{ + fin2=1; + } + c2+=2; + fin2=-1; +} +if(fin2!==1){ + $ERROR('#2.1: "finally" block must be evaluated'); +} +if(c2!==1){ + $ERROR('#2.2: "try catch{break} finally" must work correctly'); +} + +// CHECK#3 +var c3=0,fin3=0; +for (x in mycars){ + try{ + throw "ex1"; + } + catch(er1){ + c3+=1; + } + finally{ + fin3=1; + break; + } + c3+=2; + fin3=0; +} +if(fin3!==1){ + $ERROR('#3.1: "finally" block must be evaluated'); +} +if(c3!==1){ + $ERROR('#3.2: "try catch finally{break}" must work correctly'); +} + +// CHECK#4 +var c4=0,fin4=0; +for (x in mycars){ + try{ + c4+=1; + break; + } + finally{ + fin4=1; + } + fin4=-1; + c4+=2; +} +if(fin4!==1){ + $ERROR('#4.1: "finally" block must be evaluated'); +} +if(c4!==1){ + $ERROR('#4.2: "try{break} finally" must work correctly'); +} + +// CHECK#5 +var c5=0; +for (x in mycars){ + try{ + throw "ex1"; + c5++; + } + catch(er1){ + break; + c5++; + } + c5++; +} +if(c5!==0){ + $ERROR('#5: "try catch{break}" must work correctly'); +} + +// CHECK#6 +var c6=0; +for (x in mycars){ + try{ + c6+=1; + break; + } + catch(er1){} + c6+=2; +} +if(c6!==1){ + $ERROR('#6: "try{break} catch" must work correctly'); +} + +// CHECK#7 +var c7=0,fin7=0; +try{ + for (x in mycars){ + try{ + c7+=1; + throw "ex1"; + } + finally{ + fin7=1; + break; + } + fin7=-1; + c7+=2; + } +} +catch(ex1){ + c7=10; +} +if(fin7!==1){ + $ERROR('#7.1: "finally" block must be evaluated'); +} +if(c7!==1){ + $ERROR('#7.2: "try finally{break}" must work correctly'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A12_T4.js b/js/src/tests/test262/ch12/12.14/S12.14_A12_T4.js new file mode 100644 index 000000000..c09b4e2e7 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A12_T4.js @@ -0,0 +1,62 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "for-in" statement + * + * @path ch12/12.14/S12.14_A12_T4.js + * @description Try statement inside loop, where combinate using break and continue + */ + +var x; +var mycars = new Array(); +mycars[0] = "Saab"; +mycars[1] = "Volvo"; +mycars[2] = "BMW"; + +// CHECK#1 +var c1=0,fin=0; +for (x in mycars){ + try{ + c1+=1; + break; + } + catch(er1){} + finally{ + fin=1; + continue; + } + fin=-1; + c1+=2; +} +if(fin!==1){ + $ERROR('#1.1: "finally" block must be evaluated'); +} +if(c1!==3){ + $ERROR('#1.2: "try{break} catch finally{continue}" must work correctly'); +} + +// CHECK#2 +var c2=0,fin2=0; +for (x in mycars){ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + break; + } + finally{ + fin2=1; + continue; + } + c2+=2; + fin2=-1; +} +if(fin2!==1){ + $ERROR('#2.1: "finally" block must be evaluated'); +} +if(c2!==3){ + $ERROR('#2.2: "try catch{break} finally{continue}" must work correctly'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A13_T1.js b/js/src/tests/test262/ch12/12.14/S12.14_A13_T1.js new file mode 100644 index 000000000..ab3b79d4d --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A13_T1.js @@ -0,0 +1,79 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement with a "return" statement + * + * @path ch12/12.14/S12.14_A13_T1.js + * @description Using try/catch syntax construction + */ + +// CHECK#1 +function myFunction1(){ + try{ + return 1; + } + catch(err){ + $ERROR('#1.1: "return 1" inside function does not lead to throwing exception'); + return 0; + } + return 2; +} +var x1=myFunction1(); +if(x1!==1){ + $ERROR('#1.2: x1===1. Actual: x1==='+x1); +} + +// CHECK#2 +function myFunction2(){ + try{ + throw "exc"; + return 1; + }catch(err){ + return 2; + } + return 3; +} +var x2=myFunction2(); +if (x2!==2){ + $ERROR('#2: x2===2. Actual: x2==='+x2); +} + +// CHECK#3 +function myFunction3(){ + try{ + return someValue; + }catch(err){ + return 1; + } + return 2; +} +var x3=myFunction3(); +if (x3!==1){ + $ERROR('#3: x3===1. Actual: x3==='+x3); +} + +// CHECK#4 +function myFunction4(){ + try{ + throw "ex1"; + return 1; + }catch(err){ + throw "ex2" + return 0; + } + return 2; +} +try{ + var x4=myFunction4(); + $ERROR('#4.1: Throwing exception inside function lead to throwing exception outside this function'); +} +catch(e){ + if(e==="ex1"){ + $ERROR('#4.2: Exception !=="ex1". Actual: catch previous exception'); + } + if(e!=="ex2"){ + $ERROR('#4.3: Exception ==="ex2". Actual: Exception ==='+ e ); + } +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A13_T2.js b/js/src/tests/test262/ch12/12.14/S12.14_A13_T2.js new file mode 100644 index 000000000..947926476 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A13_T2.js @@ -0,0 +1,182 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement with a "return" statement + * + * @path ch12/12.14/S12.14_A13_T2.js + * @description Using try/finally syntax construction + */ + +// CHECK#1 +var c1=0; +function myFunction1(){ + try{ + return 1; + }finally{ + c1=1; + } + return 2; +} +var x1=myFunction1(); +if(x1!==1){ + $ERROR('#1.1: x1===1. Actual: x1==='+x1); +} +if (c1!==1){ + $ERROR('#1.2: "finally" block must be evaluated'); +} + +// CHECK#2 +var c2=0; +function myFunction2(){ + try{ + throw "exc"; + return 1; + }finally{ + c2=1; + } + return 2; +} +try{ + var x2=myFunction2(); + $ERROR('#2.1: Throwing exception inside function lead to throwing exception outside this function'); +} +catch(e){ + if (c2!==1){ + $ERROR('#2.2: "finally" block must be evaluated'); + } +} + +// CHECK#3 +var c3=0; +function myFunction3(){ + try{ + return someValue; + }finally{ + c3=1; + } + return 2; +} +try{ + var x3=myFunction3(); + $ERROR('#3.1: Throwing exception inside function lead to throwing exception outside this function'); +} +catch(e){ + if (c3!==1){ + $ERROR('#3.2: "finally" block must be evaluated'); + } +} + +// CHECK#4 +var c4=0; +function myFunction4(){ + try{ + return 1; + }finally{ + c4=1; + throw "exc"; + return 0; + } + return 2; +} +try{ + var x4=myFunction4(); + $ERROR('#4.2: Throwing exception inside function lead to throwing exception outside this function'); +} +catch(e){ + if (c4!==1){ + $ERROR('#4.3: "finally" block must be evaluated'); + } +} + +// CHECK#5 +var c5=0; +function myFunction5(){ + try{ + return 1; + }finally{ + c5=1; + return someValue; + return 0; + } + return 2; +} +try{ + var x5=myFunction5(); + $ERROR('#5.2: Throwing exception inside function lead to throwing exception outside this function'); +} +catch(e){ + if (c5!==1){ + $ERROR('#5.3: "finally" block must be evaluated'); + } +} + +// CHECK#6 +var c6=0; +function myFunction6(){ + try{ + throw "ex1"; + return 1; + }finally{ + c6=1; + throw "ex2"; + return 2; + } + return 3; +} +try{ + var x6=myFunction6(); + $ERROR('#6.1: Throwing exception inside function lead to throwing exception outside this function'); +} +catch(e){ + if(e==="ex1"){ + $ERROR('#6.2: Exception !=="ex1". Actual: catch previous exception'); + } + if(e!=="ex2"){ + $ERROR('#6.3: Exception !=="ex1". Actual: '+e); + } + if (c6!==1){ + $ERROR('#6.4: "finally" block must be evaluated'); + } +} + +// CHECK#7 +var c7=0; +function myFunction7(){ + try{ + return 1; + }finally{ + c7=1; + return 2; + } + return 3; +} +var x7=myFunction7(); +if(x7!==2){ + $ERROR('#7.1: "catch" block must be evaluated'); +} +if (c7!==1){ + $ERROR('#7.2: "finally" block must be evaluated'); +} + +// CHECK#8 +var c8=0; +function myFunction8(){ + try{ + throw "ex1"; + }finally{ + c8=1; + return 2; + } + return 3; +} +try{ + var x8=myFunction8(); +} +catch(ex1){ + c8=10; +} +if (c8!==1){ + $ERROR('#8: "finally" block must be evaluated'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A13_T3.js b/js/src/tests/test262/ch12/12.14/S12.14_A13_T3.js new file mode 100644 index 000000000..9b3e4a3e9 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A13_T3.js @@ -0,0 +1,186 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement with a "return" statement + * + * @path ch12/12.14/S12.14_A13_T3.js + * @description Using try/catch/finally syntax construction + */ + +// CHECK#1 +var c1=0; +function myFunction1(){ + try{ + return 1; + }catch(err){ + $ERROR('#1.1: "return 1" inside function does not lead to throwing exception'); + return 0; + }finally{ + c1=1; + } + return 2; +} +var x1=myFunction1(); +if(x1!==1){ + $ERROR('#1.3: x1===1. Actual: x1==='+x1); +} +if (c1!==1){ + $ERROR('#1.4: "finally" block must be evaluated'); +} + +// CHECK#2 +var c2=0; +function myFunction2(){ + try{ + throw "exc"; + return 1; + }catch(err){ + return 0; + }finally{ + c2=1; + } + return 2; +} +var x2=myFunction2(); +if (c2!==1){ + $ERROR('#2.1: "finally" block must be evaluated'); +} +if (x2!==0){ + $ERROR('#2.2: x2===0. Actual: x2==='+x2); +} + +// CHECK#3 +var c3=0; +function myFunction3(){ + try{ + return someValue; + }catch(err){ + return 1; + }finally{ + c3=1; + } + return 2; +} +var x3=myFunction3(); +if (c3!==1){ + $ERROR('#3.1: "finally" block must be evaluated'); +} +if (x3!==1){ + $ERROR('#3.2: x3===1. Actual: x3==='+x3); +} + +// CHECK#4 +var c4=0; +function myFunction4(){ + try{ + throw "ex1"; + return 1; + }catch(err){ + throw "ex2" + return 0; + }finally{ + c4=1; + } + return 2; +} +try{ + var x4=myFunction4(); + $ERROR('#4.1: Throwing exception inside function lead to throwing exception outside this function'); +} +catch(e){ + if(e==="ex1"){ + $ERROR('#4.2: Exception !== "ex1". Actual: catch previous exception'); + } + if(e!=="ex2"){ + $ERROR('#4.3: Exception === "ex2". Actual: Exception ==='+ e ); + } + if (c4!==1){ + $ERROR('#4.4: "finally" block must be evaluated'); + } +} + +// CHECK#5 +var c5=0; +function myFunction5(){ + try{ + throw "ex1"; + return 1; + }catch(err){ + return 0; + }finally{ + c5=1; + throw "ex2"; + } + return 2; +} +try{ + var x5=myFunction5(); + $ERROR('#5.1: Throwing exception inside function lead to throwing exception outside this function'); +} +catch(e){ + if(e==="ex1"){ + $ERROR('#5.2: Exception !== "ex1". Actual: catch previous exception'); + } + if(e!=="ex2"){ + $ERROR('#5.3: Exception === "ex2". Actual: Exception ==='+ e ); + } + if (c5!==1){ + $ERROR('#5.4: "finally" block must be evaluated'); + } +} + +// CHECK#6 +var c6=0; +function myFunction6(){ + try{ + throw "ex1"; + return 1; + }catch(err){ + throw "ex2"; + return 0; + }finally{ + c6=1; + throw "ex3"; + } + return 2; +} +try{ + var x6=myFunction6(); + $ERROR('#6.1: Throwing exception inside function lead to throwing exception outside this function'); +} +catch(e){ + if(e==="ex1"){ + $ERROR('#6.2: Exception !== "ex1". Actual: catch previous exception'); + } + if(e==="ex2"){ + $ERROR('#6.3: Exception !== "ex2". Actual: catch previous exception'); + } + if(e!=="ex3"){ + $ERROR('#6.4: Exception === "ex3". Actual: Exception ==='+ e ); + } + if(c6!==1) $ERROR('#6.5: "finally" block must be evaluated'); +} + +// CHECK#7 +var c7=0; +function myFunction7(){ + try{ + throw "ex1"; + return 1; + }catch(err){ + throw "ex2"; + return 0; + }finally{ + c7=1; + return 2; + } + return 3; +} +try{ + var x7=myFunction7(); + if(x7!==2) $ERROR('#7.1: x7===2. Actual: x7==='+x7); +} +catch(e){} +if(c7!==1) $ERROR('#7.2: "finally" block must be evaluated'); + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A14.js b/js/src/tests/test262/ch12/12.14/S12.14_A14.js new file mode 100644 index 000000000..af2177a05 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A14.js @@ -0,0 +1,79 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "with" statement + * + * @path ch12/12.14/S12.14_A14.js + * @description Using try/catch/finally in With and With in try/catch/finally + * @noStrict + */ + +var myObj = {p1: 'a', + p2: 'b', + p3: 'c', + value: 'myObj_value', + valueOf : function(){return 'obj_valueOf';}, + parseInt : function(){return 'obj_parseInt';}, + NaN : 'obj_NaN', + Infinity : 'obj_Infinity', + eval : function(){return 'obj_eval';}, + parseFloat : function(){return 'obj_parseFloat';}, + isNaN : function(){return 'obj_isNaN';}, + isFinite : function(){return 'obj_isFinite';} +} + +// CHECK#1 +try{ + with(myObj){ + throw "ex"; + } +} +catch(e){ + if (e!=="ex") $ERROR('#1: Exception ==="ex". Actual: Exception ==='+ e ); +} + +// CHECK#2 +with(myObj){ + try{ + throw p1; + } + catch(e){ + if (e!=="a") $ERROR('#2.1: Exception ==="a". Actual: Exception ==='+ e ); + p1='pass'; + } +} +if(myObj.p1!=='pass') $ERROR('#2.2: "throw p1" lead to throwing exception'); + +// CHECK#3 +with(myObj){ + try{ + p1='fail'; + throw p2; + } + catch(e){ + if (e!=="b") $ERROR('#3.1: Exception ==="b". Actual: Exception ==='+ e ); + p1='pass'; + } + finally{ + p2='pass'; + } +} +if(myObj.p1!=='pass') $ERROR('#3.2: "throw p2" lead to throwing exception'); +if(myObj.p2!=='pass') $ERROR('#3.3: "finally" block must be evaluated'); + +// CHECK#4 +myObj.p1='fail'; +try{ + with(myObj){ + try{ + throw p3; + } + finally{ + p1='pass'; + } + } +} +catch(e){} +if(myObj.p1!=='pass') $ERROR('#4: "finally" block must be evaluated'); + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A15.js b/js/src/tests/test262/ch12/12.14/S12.14_A15.js new file mode 100644 index 000000000..abd6a63a7 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A15.js @@ -0,0 +1,92 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement within/without a "switch" statement + * + * @path ch12/12.14/S12.14_A15.js + * @description Insert try/catch/finally to switch statement + */ + +// CHECK#1 +function SwitchTest1(value){ + var result = 0; + try{ + switch(value) { + case 1: + result += 4; + throw result; + break; + default: + result += 32; + break; + case 4: + result += 64; + throw "ex"; + } + return result; + } + catch(e){ + if ((value===1)&&(e!==4)) $ERROR('#1.1: Exception ===4. Actual: Exception ==='+ e ); + if ((value===4)&&(e!=="ex")) $ERROR('#1.2: Exception ==="ex". Actual: Exception ==='+ e ); + } + finally{ + return result; + } +} +if (SwitchTest1(1)!==4) $ERROR('#1.3: SwitchTest1(1)===4. Actual: SwitchTest1(1)==='+ SwitchTest1(1) ); +if (SwitchTest1(4)!==64) $ERROR('#1.4: SwitchTest1(4)===64. Actual: SwitchTest1(4)==='+ SwitchTest1(4) ); + +// CHECK#2 +var c2=0; +function SwitchTest2(value){ + var result = 0; + switch(value) { + case 0: + try{ + result += 2; + break; + } + finally{ + c2=1; + } + case 1: + result += 4; + break; + default: + result += 32; + break; + } + return result; +} +if (SwitchTest2(1)!==4) $ERROR('#2.1: SwitchTest1(1)===4. Actual: SwitchTest1(1)==='+ SwitchTest1(1) ); +if (c2===1) $ERROR('#2.2: Evaluate finally block'); +if (SwitchTest2(0)!==2) $ERROR('#2.3: SwitchTest1(0)===2. Actual: SwitchTest1(0)==='+ SwitchTest1(0) ); +if (c2!==1) $ERROR('#2.4: "finally" block must be evaluated'); + +// CHECK#3 +function SwitchTest3(value){ + var result = 0; + switch(value) { + case 0: + try{ + result += 2; + throw "ex"; + } + finally{ + break; + } + default: + result += 32; + break; + } + return result; +} +try{ + var x3=SwitchTest3(0); + if (x3!==2) $ERROR('#3.1: x3===2. Actual: x3==='+x3); +} +catch(e){ + $ERROR('#3.2: Catching exception inside function does not lead to throwing exception outside this function'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T1.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T1.js new file mode 100644 index 000000000..b6e39191b --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T1.js + * @description Checking if pure "try" syntax construction passes + * @negative + */ + +// CHECK#1 +try + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T10.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T10.js new file mode 100644 index 000000000..2baef30d0 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T10.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T10.js + * @description Catch: "catch (Identifier ) Block" + * @negative + */ + +// CHECK#1 +try{} +catch(){} +finally{} + + + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T11.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T11.js new file mode 100644 index 000000000..8d8699e6b --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T11.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. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T11.js + * @description Catch and Finally are placed into the Block of "try" (whitle expected outside) + * @negative + */ + +// CHECK#1 +try{ + { + } + catch(e){} + finally{} +} + + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T12.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T12.js new file mode 100644 index 000000000..dacc1a6a6 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T12.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. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T12.js + * @description Embedded "try" statements followed by two "catch" statements + * @negative + */ + +// CHECK#1 +try +{ + try + { + } +} +catch(e1){} +catch(e2){} + + + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T13.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T13.js new file mode 100644 index 000000000..20b475499 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T13.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T13.js + * @description Catch: "catch (Identifier ) Block". Checking if execution of "22" passes at the place of Identifier of "catch" + * @negative + */ + +// CHECK#1 +try +{ +} +catch("22") +{ +} + + + + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T14.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T14.js new file mode 100644 index 000000000..dfcbc2c65 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T14.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. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T14.js + * @description Checking if passing argument to "try" statement fails + * @negative + */ + +// CHECK#1 +try(e1){ +} +catch(e){} + + + + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T15.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T15.js new file mode 100644 index 000000000..720bf61dd --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T15.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. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T15.js + * @description Finally: "finally Block". Checking if passing argument to "try" statement fails + * @negative + */ + +// CHECK#1 +try{ +} +finally(e){} + + + + + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T2.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T2.js new file mode 100644 index 000000000..a3e9421d5 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T2.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T2.js + * @description Checking if execution of "catch" with no "try" fails + * @negative + */ + +// CHECK#1 +catch + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T3.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T3.js new file mode 100644 index 000000000..237580b02 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T3.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T3.js + * @description Checking if execution of "finally" with no "try" fails + * @negative + */ + +// CHECK#1 +finally + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T4.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T4.js new file mode 100644 index 000000000..ae3e45bba --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T4.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T4.js + * @description Catch: "catch (Identifier ) Block". Checking if execution of "catch" that takes no arguments fails + * @negative + */ + +// CHECK#1 +try{} +catch{} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T5.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T5.js new file mode 100644 index 000000000..a825e889a --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T5.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T5.js + * @description Catch: "catch (Identifier ) Block". Checking if execution of "catch" with no Block fails + * @negative + */ + +// CHECK#1 +try{} +catch() + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T6.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T6.js new file mode 100644 index 000000000..8210671c4 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T6.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T6.js + * @description Block: "{ StatementList }". Checking if execution of "try{ catch{}{}" fails + * @negative + */ + +// CHECK#1 +try{ +catch(){} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T7.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T7.js new file mode 100644 index 000000000..76990243d --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T7.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T7.js + * @description Block: "{ StatementList }". Checking if execution of "try{} catch(){" fails + * @negative + */ + +// CHECK#1 +try{} +catch(){ + + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T8.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T8.js new file mode 100644 index 000000000..93774a7b6 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T8.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T8.js + * @description Block: "{ StatementList }". Catch: "catch (Identifier ) Block". Checking if execution of "try{} catch(){finally{}" fails + * @negative + */ + +// CHECK#1 +try{} +catch(){ +finally{} + + + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A16_T9.js b/js/src/tests/test262/ch12/12.14/S12.14_A16_T9.js new file mode 100644 index 000000000..d7fb3308e --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A16_T9.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. + +/** + * TryStatement: "try Block Catch" or "try Block Finally" or "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A16_T9.js + * @description Checking if execution of "catch(){} finally{}" fails + * @negative + */ + +// CHECK#1 +catch(){} +finally{} + + + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A17.js b/js/src/tests/test262/ch12/12.14/S12.14_A17.js new file mode 100644 index 000000000..6878502e6 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A17.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using "try" with "catch" or "finally" statement in a constructor + * + * @path ch12/12.14/S12.14_A17.js + * @description Creating exceptions within constructor + */ + +var i=1; +function Integer( value, exception ) { + try{ + this.value = checkValue( value ); + if(exception) $ERROR('#'+i+'.1: Must be exception'); + } + catch(e){ + this.value = e.toString(); + if(!exception) $ERROR('#'+i+'.2: Don`t must be exception'); + } + i++; +} + +function checkValue(value){ + if(Math.floor(value)!=value||isNaN(value)){ + throw (INVALID_INTEGER_VALUE +": " + value); + } + else{ + return value; + } +} + +// CHECK#1 +new Integer(13, false); +// CHECK#2 +new Integer(NaN, true); +// CHECK#3 +new Integer(0, false); +// CHECK#4 +new Integer(Infinity, false); +// CHECK#5 +new Integer(-1.23, true); +// CHECK#6 +new Integer(Math.LN2, true); + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A18_T1.js b/js/src/tests/test262/ch12/12.14/S12.14_A18_T1.js new file mode 100644 index 000000000..635c235d0 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A18_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Catching objects with try/catch/finally statement + * + * @path ch12/12.14/S12.14_A18_T1.js + * @description Catching undefined + */ + +// CHECK#1 +try{ + throw undefined; +} +catch(e){ + if (e!==undefined) $ERROR('#1: Exception === undefined. Actual: '+e); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A18_T2.js b/js/src/tests/test262/ch12/12.14/S12.14_A18_T2.js new file mode 100644 index 000000000..f6499be27 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A18_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Catching objects with try/catch/finally statement + * + * @path ch12/12.14/S12.14_A18_T2.js + * @description Catching null + */ + +// CHECK#1 +try{ + throw null; +} +catch(e){ + if (e!==null) $ERROR('#1: Exception ===null. Actual: '+e); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A18_T3.js b/js/src/tests/test262/ch12/12.14/S12.14_A18_T3.js new file mode 100644 index 000000000..1ee0644d1 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A18_T3.js @@ -0,0 +1,62 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Catching objects with try/catch/finally statement + * + * @path ch12/12.14/S12.14_A18_T3.js + * @description Catching boolean + */ + +// CHECK#1 +try{ + throw true; +} +catch(e){ + if (e!==true) $ERROR('#1: Exception ===true. Actual: Exception ==='+ e ); +} + +// CHECK#2 +try{ + throw false; +} +catch(e){ + if (e!==false) $ERROR('#2: Exception ===false. Actual: Exception ==='+ e ); +} + +// CHECK#3 +var b=false; +try{ + throw b; +} +catch(e){ + if (e!==false) $ERROR('#3: Exception ===false. Actual: Exception ==='+ e ); +} + +// CHECK#4 +var b=true; +try{ + throw b; +} +catch(e){ + if (e!==true) $ERROR('#4: Exception ===true. Actual: Exception ==='+ e ); +} + +// CHECK#5 +var b=true; +try{ + throw b&&false; +} +catch(e){ + if (e!==false) $ERROR('#5: Exception ===false. Actual: Exception ==='+ e ); +} + +// CHECK#5 +var b=true; +try{ + throw b||false; +} +catch(e){ + if (e!==true) $ERROR('#6: Exception ===true. Actual: Exception ==='+ e ); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A18_T4.js b/js/src/tests/test262/ch12/12.14/S12.14_A18_T4.js new file mode 100644 index 000000000..3cd7d9064 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A18_T4.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Catching objects with try/catch/finally statement + * + * @path ch12/12.14/S12.14_A18_T4.js + * @description Catching string + */ + +// CHECK#1 +try{ + throw "exception #1"; +} +catch(e){ + if (e!=="exception #1") $ERROR('#1: Exception ==="exception #1". Actual: Exception ==='+ e ); +} + +// CHECK#2 +try{ + throw "exception"+" #1"; +} +catch(e){ + if (e!=="exception #1") $ERROR('#2: Exception ==="exception #1". Actual: Exception ==='+ e ); +} + +// CHECK#3 +var b="exception #1"; +try{ + throw b; +} +catch(e){ + if (e!=="exception #1") $ERROR('#3: Exception ==="exception #1". Actual: Exception ==='+ e ); +} + +// CHECK#4 +var a="exception"; +var b=" #1"; +try{ + throw a+b; +} +catch(e){ + if (e!=="exception #1") $ERROR('#4: Exception ==="exception #1". Actual: Exception ==='+ e ); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A18_T5.js b/js/src/tests/test262/ch12/12.14/S12.14_A18_T5.js new file mode 100644 index 000000000..c46c421be --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A18_T5.js @@ -0,0 +1,102 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Catching objects with try/catch/finally statement + * + * @path ch12/12.14/S12.14_A18_T5.js + * @description Catching Number + */ + +// CHECK#1 +try{ + throw 13; +} +catch(e){ + if (e!==13) $ERROR('#1: Exception ===13. Actual: Exception ==='+ e ); +} + +// CHECK#2 +try{ + throw 10+3; +} +catch(e){ + if (e!==13) $ERROR('#2: Exception ===13. Actual: Exception ==='+ e ); +} + +// CHECK#3 +var b=13; +try{ + throw b; +} +catch(e){ + if (e!==13) $ERROR('#3: Exception ===13. Actual: Exception ==='+ e ); +} + +// CHECK#4 +var a=3; +var b=10; +try{ + throw a+b; +} +catch(e){ + if (e!==13) $ERROR('#4: Exception ===13. Actual: Exception ==='+ e ); +} + +// CHECK#5 +try{ + throw 2.13; +} +catch(e){ + if (e!==2.13) $ERROR('#5: Exception ===2.13. Actual: Exception ==='+ e ); +} + +// CHECK#6 +var ex=2/3; +try{ + throw 2/3; +} +catch(e){ + if (e!==ex) $ERROR('#6: Exception ===2/3. Actual: Exception ==='+ e ); +} + +// CHECK#7 +try{ + throw NaN; +} +catch(e){ + if (!isNaN(e)) $ERROR('#7: Exception is NaN'); +} + +// CHECK#8 +try{ + throw +Infinity; +} +catch(e){ + if (e!==+Infinity) $ERROR('#8: Exception ===+Infinity. Actual: Exception ==='+ e ); +} + +// CHECK#9 +try{ + throw -Infinity; +} +catch(e){ + if (e!==-Infinity) $ERROR('#9: Exception ===-Infinity. Actual: Exception ==='+ e ); +} + +// CHECK#10 +try{ + throw +0; +} +catch(e){ + if (e!==+0) $ERROR('#10: Exception ===+0. Actual: Exception ==='+ e ); +} + +// CHECK#11 +try{ + throw -0; +} +catch(e){ + if (e!==-0) $ERROR('#11: Exception ===-0. Actual: Exception ==='+ e ); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A18_T6.js b/js/src/tests/test262/ch12/12.14/S12.14_A18_T6.js new file mode 100644 index 000000000..ca17450b3 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A18_T6.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. + +/** + * Catching objects with try/catch/finally statement + * + * @path ch12/12.14/S12.14_A18_T6.js + * @description Catching Object + */ + +var myObj = {p1: 'a', + p2: 'b', + p3: 'c', + value: 'myObj_value', + valueOf : function(){return 'obj_valueOf';}, + parseInt : function(){return 'obj_parseInt';}, + NaN : 'obj_NaN', + Infinity : 'obj_Infinity', + eval : function(){return 'obj_eval';}, + parseFloat : function(){return 'obj_parseFloat';}, + isNaN : function(){return 'obj_isNaN';}, + isFinite : function(){return 'obj_isFinite';}, + i:7, +} + +try{ + throw myObj; +} +catch(e){ +// CHECK#1 + if (e.p1!=="a") $ERROR('#1: e.p1==="a". Actual: e.p1==='+ e.p1 ); +// CHECK#2 + if (e.value!=='myObj_value') $ERROR('#2: e.value===\'myObj_value\'. Actual: e.value==='+ e.value ); +// CHECK#3 + if (e.eval()!=='obj_eval') $ERROR('#3: e.eval()===\'obj_eval\'. Actual: e.eval()==='+ e.eval() ); +} + +// CHECK#4 +myObj.i=6; +try{ + throw myObj; +} +catch(e){} +if (myObj.i!==6) $ERROR('#4: Handling of catch must be correct'); + +// CHECK#5 +myObj.i=6; +try{ + throw myObj; +} +catch(e){ + e.i=10; +} +if (myObj.i!==10) $ERROR('#5: Handling of catch must be correct'); + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A18_T7.js b/js/src/tests/test262/ch12/12.14/S12.14_A18_T7.js new file mode 100644 index 000000000..905cfa0bc --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A18_T7.js @@ -0,0 +1,66 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Catching objects with try/catch/finally statement + * + * @path ch12/12.14/S12.14_A18_T7.js + * @description Catching Array + */ + +var mycars = new Array(); +mycars[0] = "Saab"; +mycars[1] = "Volvo"; +mycars[2] = "BMW"; + +var mycars2 = new Array(); +mycars2[0] = "Mercedes"; +mycars2[1] = "Jeep"; +mycars2[2] = "Suzuki"; + +// CHECK#1 +try{ + throw mycars; +} +catch(e){ + for (var i=0;i<3;i++){ + if (e[i]!==mycars[i]) $ERROR('#1.'+i+': Exception['+i+']===mycars['+i+']. Actual: Exception['+i+']==='+ e[i] ); + } +} + +// CHECK#2 +try{ + throw mycars.concat(mycars2); +} +catch(e){ + for (var i=0;i<3;i++){ + if (e[i]!==mycars[i]) $ERROR('#2.'+i+': Exception['+i+']===mycars['+i+']. Actual: Exception['+i+']==='+ e[i] ); + } + for (var i=3;i<6;i++){ + if (e[i]!==mycars2[i-3]) $ERROR('#2.'+i+': Exception['+i+']===mycars2['+i+']. Actual: Exception['+i+']==='+ e[i] ); + } +} + +// CHECK#3 +try{ + throw new Array("Mercedes","Jeep","Suzuki"); +} +catch(e){ + for (var i=0;i<3;i++){ + if (e[i]!==mycars2[i]) $ERROR('#3.'+i+': Exception['+i+']===mycars2['+i+']. Actual: Exception['+i+']==='+ e[i]); + } +} + +// CHECK#4 +try{ + throw mycars.concat(new Array("Mercedes","Jeep","Suzuki")); +} +catch(e){ + for (var i=0;i<3;i++){ + if (e[i]!==mycars[i]) $ERROR('#4.'+i+': Exception['+i+']===mycars['+i+']. Actual: Exception['+i+']==='+ e[i] ); + } + for (var i=3;i<6;i++){ + if (e[i]!==mycars2[i-3]) $ERROR('#4.'+i+': Exception['+i+']===mycars2['+(i-3)+']. Actual: Exception['+i+']==='+ e[i]); + } +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A19_T1.js b/js/src/tests/test262/ch12/12.14/S12.14_A19_T1.js new file mode 100644 index 000000000..c2e8d27a4 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A19_T1.js @@ -0,0 +1,68 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Catching system exceptions of different types with try statement + * + * @path ch12/12.14/S12.14_A19_T1.js + * @description Testing try/catch syntax construction + */ + +// CHECK#1 +try{ + throw (Error("hello")); +} +catch(e){ + if (e.toString()!=="Error: hello") $ERROR('#1: Exception.toString()==="Error: hello". Actual: Exception is '+e); +} + +// CHECK#2 +try{ + throw (new Error("hello")); +} +catch(e){ + if (e.toString()!=="Error: hello") $ERROR('#2: Exception.toString()==="Error: hello". Actual: Exception is '+e); +} + +// CHECK#3 +var c3=0; +try{ + throw EvalError(1); +} +catch(e){ + if (e.toString()!=="EvalError: 1") $ERROR('#3: Exception.toString()==="EvalError: 1". Actual: Exception is '+e); +} + +// CHECK#4 +try{ + throw RangeError(1); +} +catch(e){ + if (e.toString()!=="RangeError: 1") $ERROR('#4: Exception.toString()==="RangeError: 1". Actual: Exception is '+e); +} + +// CHECK#5 +try{ + throw ReferenceError(1); +} +catch(e){ + if (e.toString()!=="ReferenceError: 1") $ERROR('#5: Exception.toString()==="ReferenceError: 1". Actual: Exception is '+e); +} + +// CHECK#6 +var c6=0; +try{ + throw TypeError(1); +} +catch(e){ + if (e.toString()!=="TypeError: 1") $ERROR('#6: Exception.toString()==="TypeError: 1". Actual: Exception is '+e); +} + +// CHECK#7 +try{ + throw URIError("message", "fileName", "1"); +} +catch(e){ + if (e.toString()!=="URIError: message") $ERROR('#7: Exception.toString()==="URIError: message". Actual: Exception is '+e); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A19_T2.js b/js/src/tests/test262/ch12/12.14/S12.14_A19_T2.js new file mode 100644 index 000000000..acc465ea1 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A19_T2.js @@ -0,0 +1,102 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Catching system exceptions of different types with try statement + * + * @path ch12/12.14/S12.14_A19_T2.js + * @description Testing try/catch/finally syntax construction + */ + +var fin=0; +// CHECK#1 +try{ + throw (Error("hello")); +} +catch(e){ + if (e.toString()!=="Error: hello") $ERROR('#1.1: Exception.toString()==="Error: hello". Actual: Exception is '+e); +} +finally{ + fin=1; +} +if (fin!==1) $ERROR('#1.2: "finally" block must be evaluated'); + +// CHECK#2 +fin=0; +try{ + throw (new Error("hello")); +} +catch(e){ + if (e.toString()!=="Error: hello") $ERROR('#2.1: Exception.toString()==="Error: hello". Actual: Exception is '+e); +} +finally{ + fin=1; +} +if (fin!==1) $ERROR('#2.2: "finally" block must be evaluated'); + +// CHECK#3 +fin=0; +var c3=0; +try{ + throw EvalError(1); +} +catch(e){ + if (e.toString()!=="EvalError: 1") $ERROR('#3.1: Exception.toString()==="EvalError: 1". Actual: Exception is '+e); +} +finally{ + fin=1; +} +if (fin!==1) $ERROR('#3.2: "finally" block must be evaluated'); + +// CHECK#4 +fin=0; +try{ + throw RangeError(1); +} +catch(e){ + if (e.toString()!=="RangeError: 1") $ERROR('#4.1: Exception.toString()==="RangeError: 1". Actual: Exception is '+e); +} +finally{ + fin=1; +} +if (fin!==1) $ERROR('#4.2: "finally" block must be evaluated'); + +// CHECK#5 +fin=0; +try{ + throw ReferenceError(1); +} +catch(e){ + if (e.toString()!=="ReferenceError: 1") $ERROR('#5.1: Exception.toString()==="ReferenceError: 1". Actual: Exception is '+e); +} +finally{ + fin=1; +} +if (fin!==1) $ERROR('#5.2: "finally" block must be evaluated'); + +// CHECK#6 +fin=0; +try{ + throw TypeError(1); +} +catch(e){ + if (e.toString()!=="TypeError: 1") $ERROR('#6.1: Exception.toString()==="TypeError: 1". Actual: Exception is '+e); +} +finally{ + fin=1; +} +if (fin!==1) $ERROR('#6.2: "finally" block must be evaluated'); + +// CHECK#7 +fin=0; +try{ + throw URIError("message", "fileName", "1"); +} +catch(e){ + if (e.toString()!=="URIError: message") $ERROR('#7.1: Exception.toString()==="URIError: message". Actual: Exception is '+e); +} +finally{ + fin=1; +} +if (fin!==1) $ERROR('#7.2: "finally" block must be evaluated'); + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A2.js b/js/src/tests/test262/ch12/12.14/S12.14_A2.js new file mode 100644 index 000000000..4185b346f --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A2.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Throwing exception with "throw" and catching it with "try" statement + * + * @path ch12/12.14/S12.14_A2.js + * @description Checking if execution of "catch" catches an exception thrown with "throw" + */ + +// CHECK#1 +try { + throw "catchme"; + $ERROR('#1: throw "catchme" lead to throwing exception'); +} +catch(e){} + +// CHECK#2 +var c2=0; +try{ + try{ + throw "exc"; + $ERROR('#2.1: throw "exc" lead to throwing exception'); + }finally{ + c2=1; + } +} +catch(e){ + if (c2!==1){ + $ERROR('#2.2: "finally" block must be evaluated'); + } +} + +// CHECK#3 +var c3=0; +try{ + throw "exc"; + $ERROR('#3.1: throw "exc" lead to throwing exception'); +} +catch(err){ + var x3=1; +} +finally{ + c3=1; +} +if (x3!==1){ + $ERROR('#3.2: "catch" block must be evaluated'); +} +if (c3!==1){ + $ERROR('#3.3: "finally" block must be evaluated'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A3.js b/js/src/tests/test262/ch12/12.14/S12.14_A3.js new file mode 100644 index 000000000..b87f6d57c --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A3.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Catching system exception with "try" statement + * + * @path ch12/12.14/S12.14_A3.js + * @description Checking if execution of "catch" catches system exceptions + */ + +// CHECK#1 +try{ + y; + $ERROR('#1: "y" lead to throwing exception'); +} +catch(e){} + +// CHECK#2 +var c2=0; +try{ + try{ + someValue; + $ERROR('#3.1: "someValues" lead to throwing exception'); + } + finally{ + c2=1; + } +} +catch(e){ + if (c2!==1){ + $ERROR('#3.2: "finally" block must be evaluated'); + } +} + +// CHECK#3 +var c3=0,x3=0; +try{ + x3=someValue; + $ERROR('#3.1: "x3=someValues" lead to throwing exception'); +} +catch(err){ + x3=1; +} +finally{ + c3=1; +} +if (x3!==1){ + $ERROR('#3.2: "catch" block must be evaluated'); +} +if (c3!==1){ + $ERROR('#3.3: "finally" block must be evaluated'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A4.js b/js/src/tests/test262/ch12/12.14/S12.14_A4.js new file mode 100644 index 000000000..e904f5c9e --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A4.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. + +/** + * Sanity test for "catch(Indetifier) statement" + * + * @path ch12/12.14/S12.14_A4.js + * @description Checking if deleting an exception fails + * @noStrict + */ + +// CHECK#1 +try { + throw "catchme"; + $ERROR('#1.1: throw "catchme" lead to throwing exception'); +} +catch (e) { + if (delete e){ + $ERROR('#1.2: Exception has DontDelete property'); + } + if (e!=="catchme") { + $ERROR('#1.3: Exception === "catchme". Actual: Exception ==='+ e ); + } +} + +// CHECK#2 +try { + throw "catchme"; + $ERROR('#2.1: throw "catchme" lead to throwing exception'); +} +catch(e){} +try{ + e; + $ERROR('#2.2: Deleting catching exception after ending "catch" block'); +} +catch(err){} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A5.js b/js/src/tests/test262/ch12/12.14/S12.14_A5.js new file mode 100644 index 000000000..f7620908b --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A5.js @@ -0,0 +1,51 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * The production TryStatement: "try Block Finally" and the production TryStatement: "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A5.js + * @description Checking "catch" catches the Identifier in appropriate way + */ + +// CHECK#1 +try { + throw "catchme"; + throw "dontcatchme"; + $ERROR('#1.1: throw "catchme" lead to throwing exception'); +} +catch (e) { + if(e==="dontcatchme"){ + $ERROR('#1.2: Exception !== "dontcatchme"'); + } + if (e!=="catchme") { + $ERROR('#1.3: Exception === "catchme". Actual: Exception ==='+ e ); + } +} + +// CHECK#2 +function SwitchTest1(value){ + var result = 0; + try{ + switch(value) { + case 1: + result += 4; + throw result; + break; + case 4: + result += 64; + throw "ex"; + } + return result; + } + catch(e){ + if ((value===1)&&(e!==4)) $ERROR('#2.1: Exception === 4. Actual: '+e); + if ((value===4)&&(e!=="ex"))$ERROR('#2.2: Exception === "ex". Actual: '+e); + } + finally{ + return result; + } +} +if (SwitchTest1(1)!==4) $ERROR('#2.3: "finally" block must be evaluated'); +if (SwitchTest1(4)!==64)$ERROR('#2.4: "finally" block must be evaluated'); + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A6.js b/js/src/tests/test262/ch12/12.14/S12.14_A6.js new file mode 100644 index 000000000..96b30dbc0 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A6.js @@ -0,0 +1,67 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * The production TryStatement: "try Block Catch Finally" + * + * @path ch12/12.14/S12.14_A6.js + * @description Executing sequence of "try" statements, using counters with varying values within + */ + +// CHECK#1 +var c1=0; +try { + c1+=1; + y; + $ERROR('#1.1: "y" lead to throwing exception'); +} +catch (e) { + c1*=2; +} +if (c1!==2){ + $ERROR('#1.2: Sequence evaluation of commands try/catch is 1. try, 2. catch'); +} + +// CHECK#2 +var c2=0; +try{ + c2+=1; +} +finally{ + c2*=2; +} +if (c2!==2){ + $ERROR('#2: Sequence evaluation of commands try/finally is 1. try, 2. finally'); +} + +// CHECK#3 +var c3=0; +try{ + c3=1; + z; +} +catch(err){ + c3*=2; +} +finally{ + c3+=1; +} +if (c3!==3){ + $ERROR('#3: Sequence evaluation of commands try/catch/finally(with exception) is 1. try, 2. catch, 3. finally'); +} + +// CHECK#4 +var c4=0; +try{ + c4=1; +} +catch(err){ + c4*=3; +} +finally{ + c4+=1; +} +if (c4!==2){ + $ERROR('#4: Sequence evaluation of commands try/catch/finally(without exception) is 1. try, 2. finally'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A7_T1.js b/js/src/tests/test262/ch12/12.14/S12.14_A7_T1.js new file mode 100644 index 000000000..86efa4fad --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A7_T1.js @@ -0,0 +1,138 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Evaluating the nested productions TryStatement + * + * @path ch12/12.14/S12.14_A7_T1.js + * @description Checking if the production of nested TryStatement statements evaluates correct + */ + +// CHECK#1 +try{ + try{ + throw "ex2"; + } + catch(er2){ + if (er2!=="ex2") + $ERROR('#1.1: Exception === "ex2". Actual: Exception ==='+ e ); + throw "ex1"; + } + } + catch(er1){ + if (er1!=="ex1") $ERROR('#1.2: Exception === "ex1". Actual: '+er1); + if (er1==="ex2") $ERROR('#1.3: Exception !== "ex2". Actual: catch previous embedded exception'); +} + +// CHECK#2 +try{ + throw "ex1"; +} +catch(er1){ + try{ + throw "ex2"; + } + catch(er1){ + if (er1==="ex1") $ERROR('#2.1: Exception !== "ex1". Actual: catch previous catching exception'); + if (er1!=="ex2") $ERROR('#2.2: Exception === "ex2". Actual: Exception ==='+ er1 ); + } + if (er1!=="ex1") $ERROR('#2.3: Exception === "ex1". Actual: Exception ==='+ er1 ); + if (er1==="ex2") $ERROR('#2.4: Exception !== "ex2". Actual: catch previous catching exception'); +} + +// CHECK#3 +try{ + throw "ex1"; +} +catch(er1){ + if (er1!=="ex1") $ERROR('#3.1: Exception ==="ex1". Actual: Exception ==='+ er1 ); +} +finally{ + try{ + throw "ex2"; + } + catch(er1){ + if (er1==="ex1") $ERROR('#3.2: Exception !=="ex1". Actual: catch previous embedded exception'); + if (er1!=="ex2") $ERROR('#3.3: Exception ==="ex2". Actual: Exception ==='+ er1 ); + } +} + +// CHECK#4 +var c4=0; +try{ + throw "ex1"; +} +catch(er1){ + try{ + throw "ex2"; + } + catch(er1){ + if (er1==="ex1") $ERROR('#4.1: Exception !=="ex1". Actual: catch previous catching exception'); + if (er1!=="ex2") $ERROR('#4.2: Exception ==="ex2". Actual: Exception ==='+ er1 ); + } + if (er1!=="ex1") $ERROR('#4.3: Exception ==="ex1". Actual: Exception ==='+ er1 ); + if (er1==="ex2") $ERROR('#4.4: Exception !=="ex2". Actual: Catch previous embedded exception'); +} +finally{ + c4=1; +} +if (c4!==1) $ERROR('#4.5: "finally" block must be evaluated'); + +// CHECK#5 +var c5=0; +try{ + try{ + throw "ex2"; + } + catch(er1){ + if (er1!=="ex2") $ERROR('#5.1: Exception ==="ex2". Actual: Exception ==='+ er1 ); + } + throw "ex1"; +} +catch(er1){ + if (er1!=="ex1") $ERROR('#5.2: Exception ==="ex1". Actual: Exception ==='+ er1 ); + if (er1==="ex2") $ERROR('#5.3: Exception !=="ex2". Actual: catch previous embedded exception'); +} +finally{ + c5=1; +} +if (c5!==1) $ERROR('#5.4: "finally" block must be evaluated'); + +// CHECK#6 +var c6=0; +try{ + try{ + throw "ex1"; + } + catch(er1){ + if (er1!=="ex1") $ERROR('#6.1: Exception ==="ex1". Actual: Exception ==='+ er1 ); + } +} +finally{ + c6=1; +} +if (c6!==1) $ERROR('#6.2: "finally" block must be evaluated'); + +// CHECK#7 +var c7=0; +try{ + try{ + throw "ex1"; + } + finally{ + try{ + c7=1; + throw "ex2"; + } + catch(er1){ + if (er1!=="ex2") $ERROR('#7.1: Exception ==="ex2". Actual: Exception ==='+ er1 ); + if (er1==="ex1") $ERROR('#7.2: Exception !=="ex1". Actual: catch previous embedded exception'); + c7++; + } + } +} +catch(er1){ + if (er1!=="ex1") $ERROR('#7.3: Exception ==="ex1". Actual: Exception ==='+ er1 ); +} +if (c7!==2) $ERROR('#7.4: "finally" block must be evaluated'); + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A7_T2.js b/js/src/tests/test262/ch12/12.14/S12.14_A7_T2.js new file mode 100644 index 000000000..94a8c343d --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A7_T2.js @@ -0,0 +1,152 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Evaluating the nested productions TryStatement + * + * @path ch12/12.14/S12.14_A7_T2.js + * @description Checking if the production of nested TryStatement statements evaluates correct + */ + +// CHECK#1 +try{ + try{ + throw "ex2"; + } + finally{ + throw "ex1"; + } +} +catch(er1){ + if (er1!=="ex1") $ERROR('#1.2: Exception === "ex1". Actual: Exception ==='+er1 ); + if (er1==="ex2") $ERROR('#1.3: Exception !== "ex2". Actual: catch previous embedded exception'); +} + +// CHECK#2 +try{ + try{ + throw "ex1"; + } + catch(er1){ + if (er1!=="ex1") $ERROR('#2.1: Exception === "ex1". Actual: Exception ==='+er1 ); + try{ + throw "ex2"; + } + finally{ + throw "ex3"; + } + $ERROR('#2.2: throw "ex1" lead to throwing exception'); + } +} +catch(er1){ + if (er1!=="ex3") $ERROR('#2.3: Exception === "ex3". Actual: Exception ==='+er1 ); +} + +// CHECK#3 +try{ + try{ + throw "ex1"; + } + catch(er1){ + if (er1!=="ex1") $ERROR('#3.1: Exception === "ex1". Actual: Exception ==='+er1 ); + } + finally{ + try{ + throw "ex2"; + } + finally{ + throw "ex3"; + } + } +} +catch(er1){ + if (er1!=="ex3") $ERROR('#3.2: Exception === "ex3". Actual: Exception ==='+er1 ); +} + +// CHECK#4 +var c4=0; +try{ + try{ + throw "ex1"; + } + catch(er1){ + if (er1!=="ex1") $ERROR('#4.1: Exception === "ex1". Actual: Exception ==='+er1 ); + try{ + throw "ex2"; + } + finally{ + throw "ex3"; + } + } + finally{ + c4=1; + } +} +catch(er1){ + if (er1!=="ex3") $ERROR('#4.2: Exception === "ex3". Actual: Exception ==='+er1 ); +} +if (c4!==1) $ERROR('#4.3: "finally" block must be evaluated'); + +// CHECK#5 +var c5=0; +try{ + try{ + throw "ex2"; + } + finally{ + throw "ex3"; + } + throw "ex1"; +} +catch(er1){ + if (er1!=="ex3") $ERROR('#5.1: Exception === "ex3". Actual: Exception ==='+er1 ); + if (er1==="ex2") $ERROR('#5.2: Exception !== "ex2". Actual: catch previous embedded exception'); + if (er1==="ex1") $ERROR('#5.3: Exception !=="ex1". Actual: catch previous embedded exception'); +} +finally{ + c5=1; +} +if (c5!==1) $ERROR('#5.4: "finally" block must be evaluated'); + +// CHECK#6 +var c6=0; +try{ + try{ + try{ + throw "ex1"; + } + finally{ + throw "ex2"; + } + } + finally{ + c6=1; + } +} +catch(er1){ + if (er1!=="ex2") $ERROR('#6.1: Exception === "ex2". Actual: Exception ==='+er1 ); +} +if (c6!==1) $ERROR('#6.2: "finally" block must be evaluated'); + +// CHECK#7 +var c7=0; +try{ + try{ + throw "ex1"; + } + finally{ + try{ + c7=1; + throw "ex2"; + } + finally{ + c7++; + throw "ex3"; + } + } +} +catch(er1){ + if (er1!=="ex3") $ERROR('#7.1: Exception === "ex3". Actual: Exception ==='+er1 ); +} +if (c7!==2) $ERROR('#7.2: Embedded "try/finally" blocks must be evaluated'); + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A7_T3.js b/js/src/tests/test262/ch12/12.14/S12.14_A7_T3.js new file mode 100644 index 000000000..183ab7d22 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A7_T3.js @@ -0,0 +1,169 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Evaluating the nested productions TryStatement + * + * @path ch12/12.14/S12.14_A7_T3.js + * @description Checking if the production of nested TryStatement statements evaluates correct + */ + +// CHECK#1 +try{ + try{ + throw "ex2"; + } + catch(er2){ + if (er2!=="ex2") $ERROR('#1.1: Exception === "ex2". Actual: Exception ==='+er2); + throw "ex1"; + } + finally{ + throw "ex3"; + } +} +catch(er1){ + if (er1!=="ex3") $ERROR('#1.2: Exception === "ex3". Actual: Exception ==='+er1); + if (er1==="ex2") $ERROR('#1.3: Exception !=="ex2". Actual: catch previous catched exception'); + if (er1==="ex1") $ERROR('#1.4: Exception !=="ex1". Actual: catch previous embedded exception'); +} + +// CHECK#2 +var c2=0; +try{ + throw "ex1"; +} +catch(er1){ + try{ + throw "ex2"; + } + catch(er1){ + if (er1==="ex1") $ERROR('#2.1: Exception !=="ex1". Actual: catch previous catched exception'); + if (er1!=="ex2") $ERROR('#2.2: Exception === "ex2". Actual: Exception ==='+er1); + } + finally{ + c2=1; + } + if (er1!=="ex1") $ERROR('#2.3: Exception === "ex1". Actual: Exception ==='+er1); + if (er1==="ex2") $ERROR('#2.4: Exception !== "ex2". Actual: catch previous embedded exception'); +} +if (c2!==1) $ERROR('#2.5: "finally" block must be evaluated'); + +// CHECK#3 +var c3=0; +try{ + throw "ex1"; +} +catch(er1){ + if (er1!=="ex1") $ERROR('#3.1: Exception === "ex1". Actual: Exception ==='+er1); +} +finally{ + try{ + throw "ex2"; + } + catch(er1){ + if (er1==="ex1") $ERROR('#3.2: Exception !=="ex1". Actual: catch previous catched exception'); + if (er1!=="ex2") $ERROR('#3.3: Exception === "ex2". Actual: Exception ==='+er1); + } + finally{ + c3=1; + } +} +if (c3!==1) $ERROR('#3.4: "finally" block must be evaluated'); + +// CHECK#4 +var c4=0; +try{ + try{ + throw "ex1"; + } + catch(er1){ + try{ + throw "ex2"; + } + catch(er1){ + if (er1==="ex1") $ERROR('#4.1: Exception !=="ex2". Actual: catch previous catched exception'); + if (er1!=="ex2") $ERROR('#4.2: Exception === "ex2". Actual: Exception ==='+er1); + } + finally{ + c4=2; + throw "ex3"; + } + if (er1!=="ex1") $ERROR('#4.3: Exception === "ex2". Actual: Exception ==='+er1); + if (er1==="ex2") $ERROR('#4.4: Exception !=="ex2". Actual: catch previous catched exception'); + if (er1==="ex3") $ERROR('#4.5: Exception !=="ex3". Actual: Catch previous embedded exception'); + } + finally{ + c4*=2; + } +} +catch(er1){} +if (c4!==4) $ERROR('#4.6: "finally" block must be evaluated'); + +// CHECK#5 +var c5=0; +try{ + try{ + throw "ex2"; + } + catch(er1){ + if (er1!=="ex2") $ERROR('#5.1: Exception === "ex2". Actual: Exception ==='+er1); + } + finally{ + throw "ex3"; + } + throw "ex1"; +} +catch(er1){ + if (er1!=="ex3") $ERROR('#5.2: Exception === "ex3". Actual: Exception ==='+er1); + if (er1==="ex2") $ERROR('#5.3: Exception !=="ex2". Actual: catch previous catched exception'); + if (er1==="ex1") $ERROR('#5.4: Exception !=="ex1". Actual: catch previous embedded exception'); +} +finally{ + c5=1; +} +if (c5!==1) $ERROR('#5.5: "finally" block must be evaluated'); + +// CHECK#6 +var c6=0; +try{ + try{ + throw "ex1"; + } + catch(er1){ + if (er1!=="ex1") $ERROR('#6.1: Exception === "ex1". Actual: Exception ==='+er1); + } + finally{ + c6=2; + } +} +finally{ + c6*=2; +} +if (c6!==4) $ERROR('#6.2: "finally" block must be evaluated'); + +// CHECK#7 +var c7=0; +try{ + try{ + throw "ex1"; + } + finally{ + try{ + c7=1; + throw "ex2"; + } + catch(er1){ + if (er1!=="ex2") $ERROR('#7.1: Exception === "ex2". Actual: Exception ==='+er1); + if (er1==="ex1") $ERROR('#7.2: Exception !=="ex2". Actual: catch previous catched exception'); + c7++; + } + finally{ + c7*=2; + } + } +} +catch(er1){ + if (er1!=="ex1") $ERROR('#7.3: Exception === "ex1". Actual: Exception ==='+er1); +} +if (c7!==4) $ERROR('#7.4: "finally" block must be evaluated'); + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A8.js b/js/src/tests/test262/ch12/12.14/S12.14_A8.js new file mode 100644 index 000000000..4ac0574a2 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A8.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. + +/** + * "try" with "catch" or "finally" statement within/without an "if" statement + * + * @path ch12/12.14/S12.14_A8.js + * @description Throwing exception within an "if" statement + */ + +// CHECK#1 +var c1=1; +try{ + if(c1===1){ + throw "ex1"; + $ERROR('#1.1: throw "ex1" lead to throwing exception'); + } + $ERROR('#1.2: throw "ex1" inside the "if" statement lead to throwing exception'); +} +catch(er1){ + if (er1!=="ex1") $ERROR('#1.3: Exception ==="ex1". Actual: Exception ==='+er1); +} + +// CHECK#2 +var c2=1; +if(c2===1){ + try{ + throw "ex1"; + $ERROR('#2.1: throw "ex1" lead to throwing exception'); + } + catch(er1){ + if(er1!="ex1") $ERROR('#2.2: Exception ==="ex1". Actual: Exception ==='+er1); + } +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A9_T1.js b/js/src/tests/test262/ch12/12.14/S12.14_A9_T1.js new file mode 100644 index 000000000..974b9e725 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A9_T1.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. + +/** + * "try" with "catch" or "finally" statement within/without an "do while" statement + * + * @path ch12/12.14/S12.14_A9_T1.js + * @description Loop within a "try" Block, from where exception is thrown + */ + +// CHECK#1 +var i=0; +try{ + do{ + if(i===5) throw i; + i++; + } + while(i<10); +} +catch(e){ + if(e!==5)$ERROR('#1: Exception ===5. Actual: Exception ==='+ e ); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A9_T2.js b/js/src/tests/test262/ch12/12.14/S12.14_A9_T2.js new file mode 100644 index 000000000..9b36f31fb --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A9_T2.js @@ -0,0 +1,122 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * "try" with "catch" or "finally" statement within/without an "do while" statement + * + * @path ch12/12.14/S12.14_A9_T2.js + * @description "try" statement within a loop, the statement contains "continue" statement + */ + +// CHECK#1 +var c1=0,fin=0; +do{ + try{ + c1+=1; + continue; + } + catch(er1){} + finally{ + fin=1; + } + fin=-1; +} +while(c1<2); +if(fin!==1){ + $ERROR('#1: "finally" block must be evaluated at "try{continue} catch finally" construction'); +} + +// CHECK#2 +var c2=0,fin2=0; +do{ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + continue; + } + finally{ + fin2=1; + } + fin2=-1; +} +while(c2<2); +if(fin2!==1){ + $ERROR('#2: "finally" block must be evaluated at "try catch{continue} finally" construction'); +} + +// CHECK#3 +var c3=0,fin3=0; +do{ + try{ + throw "ex1"; + } + catch(er1){ + c3+=1; + } + finally{ + fin3=1; + continue; + } + fin3=0; +} +while(c3<2); +if(fin3!==1){ + $ERROR('#3: "finally" block must be evaluated at "try catch finally{continue}" construction'); +} + +// CHECK#4 +var c4=0,fin4=0; +do{ + try{ + c4+=1; + continue; + } + finally{ + fin4=1; + } + fin4=-1; +} +while(c4<2); +if(fin4!==1){ + $ERROR('#4: "finally" block must be evaluated at "try{continue} finally" construction'); +} + +// CHECK#5 +var c5=0; +do{ + try{ + throw "ex1"; + } + catch(er1){ + c5+=1; + continue; + } +} +while(c5<2); +if(c5!==2){ + $ERROR('#5: "try catch{continue}" must work correctly'); +} + +// CHECK#6 +var c6=0,fin6=0; +do{ + try{ + c6+=1; + throw "ex1" + } + finally{ + fin6=1; + continue; + } + fin6=-1; +} +while(c6<2); +if(fin6!==1){ + $ERROR('#6.1: "finally" block must be evaluated'); +} +if(c6!==2){ + $ERROR('#6.2: "try finally{continue}" must work correctly'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A9_T3.js b/js/src/tests/test262/ch12/12.14/S12.14_A9_T3.js new file mode 100644 index 000000000..60bdd4b30 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A9_T3.js @@ -0,0 +1,158 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * "try" with "catch" or "finally" statement within/without an "do while" statement + * + * @path ch12/12.14/S12.14_A9_T3.js + * @description "try" statement within a loop, the statement contains "break" statement + */ + +// CHECK#1 +var c1=0,fin=0; +do{ + try{ + c1+=1; + break; + } + catch(er1){} + finally{ + fin=1; + } + fin=-1; + c1+=2; +} +while(c1<2); +if(fin!==1){ + $ERROR('#1.1: "finally" block must be evaluated'); +} +if(c1!==1){ + $ERROR('#1.2: "try{break}catch finally" must work correctly'); +} + +// CHECK#2 +var c2=0,fin2=0; +do{ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + break; + } + finally{ + fin2=1; + } + c2+=2; + fin2=-1; +} +while(c2<2); +if(fin2!==1){ + $ERROR('#2.1: "finally" block must be evaluated'); +} +if(c2!==1){ + $ERROR('#2.2: "try catch{break} finally" must work correctly'); +} + +// CHECK#3 +var c3=0,fin3=0; +do{ + try{ + throw "ex1"; + } + catch(er1){ + c3+=1; + } + finally{ + fin3=1; + break; + } + c3+=2; + fin3=0; +} +while(c3<2); +if(fin3!==1){ + $ERROR('#3.1: "finally" block must be evaluated'); +} +if(c3!==1){ + $ERROR('#3.2: "try catch finally{break}" must work correctly'); +} + +// CHECK#4 +var c4=0,fin4=0; +do{ + try{ + c4+=1; + break; + } + finally{ + fin4=1; + } + fin4=-1; + c4+=2; +} +while(c4<2); +if(fin4!==1){ + $ERROR('#4.1: "finally" block must be evaluated'); +} +if(c4!==1){ + $ERROR('#4.2: "try{break} finally" must work correctly'); +} + +// CHECK#5 +var c5=0; +do{ + try{ + throw "ex1"; + } + catch(er1){ + break; + } +} +while(c5<2); +if(c5!==0){ + $ERROR('#5: "try catch{break}" must work correctly'); +} + +// CHECK#6 +var c6=0; +do{ + try{ + c6+=1; + break; + } + catch(er1){} + c6+=2; +} +while(c6<2); +if(c6!==1){ + $ERROR('#6: "try{break} catch" must work correctly'); +} + +// CHECK#7 +var c7=0,fin7=0; +try{ + do{ + try{ + c7+=1; + throw "ex1"; + } + finally{ + fin7=1; + break; + } + fin7=-1; + c7+=2; + } + while(c7<2); +} +catch(ex1){ + c7=10; +} +if(fin7!==1){ + $ERROR('#7.1: "finally" block must be evaluated'); +} +if(c7!==1){ + $ERROR('#7.2: try finally{break} error'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A9_T4.js b/js/src/tests/test262/ch12/12.14/S12.14_A9_T4.js new file mode 100644 index 000000000..06542b1d1 --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A9_T4.js @@ -0,0 +1,58 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * "try" with "catch" or "finally" statement within/without an "do while" statement + * + * @path ch12/12.14/S12.14_A9_T4.js + * @description "try" statement within a loop, the statement contains "continue" and "break" statements + */ + +// CHECK#1 +var c1=0,fin=0; +do{ + try{ + c1+=1; + break; + } + catch(er1){} + finally{ + fin=1; + continue; + } + fin=-1; + c1+=2; +} +while(c1<2); +if(fin!==1){ + $ERROR('#1.1: "finally" block must be evaluated'); +} +if(c1!==2){ + $ERROR('#1.2: "try{break} catch finally{continue}" must work correctly'); +} + +// CHECK#2 +var c2=0,fin2=0; +do{ + try{ + throw "ex1"; + } + catch(er1){ + c2+=1; + break; + } + finally{ + fin2=1; + continue; + } + c2+=2; + fin2=-1; +} +while(c2<2); +if(fin2!==1){ + $ERROR('#2.1: "finally" block must be evaluated'); +} +if(c2!==2){ + $ERROR('#2.2: "try catch{break} finally{continue}" must work correctly'); +} + diff --git a/js/src/tests/test262/ch12/12.14/S12.14_A9_T5.js b/js/src/tests/test262/ch12/12.14/S12.14_A9_T5.js new file mode 100644 index 000000000..dd16dfe2d --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/S12.14_A9_T5.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. + +/** + * "try" with "catch" or "finally" statement within/without an "do while" statement + * + * @path ch12/12.14/S12.14_A9_T5.js + * @description Checking if exceptions are thrown correctly from wherever of loop body + */ + +// CHECK#1 +var c=0, i=0; +var fin=0; +do{ + i+=1; + try{ + if(c===0){ + throw "ex1"; + $ERROR('#1.1: throw "ex1" lead to throwing exception'); + } + c+=2; + if(c===1){ + throw "ex2"; + $ERROR('#1.2: throw "ex2" lead to throwing exception'); + } + } + catch(er1){ + c-=1; + continue; + $ERROR('#1.3: "try catch{continue} finally" must work correctly'); + } + finally{ + fin+=1; + } +} +while(i<10); +if(fin!==10){ + $ERROR('#1.4: "finally" block must be evaluated'); +} + + diff --git a/js/src/tests/test262/ch12/12.14/browser.js b/js/src/tests/test262/ch12/12.14/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/browser.js diff --git a/js/src/tests/test262/ch12/12.14/shell.js b/js/src/tests/test262/ch12/12.14/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch12/12.14/shell.js |