diff options
Diffstat (limited to 'js/src/tests/test262/ch13/13.2')
117 files changed, 3869 insertions, 0 deletions
diff --git a/js/src/tests/test262/ch13/13.2/13.2-1-s.js b/js/src/tests/test262/ch13/13.2/13.2-1-s.js new file mode 100644 index 000000000..9b3b7e1d7 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-1-s.js @@ -0,0 +1,22 @@ +/// 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 ch13/13.2/13.2-1-s.js
+ * @description StrictMode - Writing or reading from a property named 'caller' of function objects is allowed under both strict and normal modes.
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ "use strict";
+
+ var foo = function () {
+ this.caller = 12;
+ }
+ var obj = new foo();
+ return obj.caller === 12;
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-10-s.js b/js/src/tests/test262/ch13/13.2/13.2-10-s.js new file mode 100644 index 000000000..9ab52ea93 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-10-s.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 ch13/13.2/13.2-10-s.js
+ * @description StrictMode - writing a property named 'caller' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = Function("'use strict';");
+ try {
+ foo.caller = 41;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-11-s.js b/js/src/tests/test262/ch13/13.2/13.2-11-s.js new file mode 100644 index 000000000..f08680ceb --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-11-s.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 ch13/13.2/13.2-11-s.js
+ * @description StrictMode - enumerating over a function object looking for 'caller' fails outside of the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = Function("'use strict';");
+
+ for (var tempIndex in foo) {
+ if (tempIndex === "caller") {
+ return false;
+ }
+ }
+ return true;
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-12-s.js b/js/src/tests/test262/ch13/13.2/13.2-12-s.js new file mode 100644 index 000000000..ecb9ae413 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-12-s.js @@ -0,0 +1,18 @@ +/// 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 ch13/13.2/13.2-12-s.js
+ * @description StrictMode - enumerating over a function object looking for 'caller' fails inside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = Function("'use strict'; for (var tempIndex in this) {if (tempIndex===\"caller\") {return false;}}; return true;");
+ return foo();
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-13-s.js b/js/src/tests/test262/ch13/13.2/13.2-13-s.js new file mode 100644 index 000000000..2a087ddad --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-13-s.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 ch13/13.2/13.2-13-s.js
+ * @description StrictMode - reading a property named 'arguments' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = new Function("'use strict';");
+ try {
+ var temp = foo.arguments;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-14-s.js b/js/src/tests/test262/ch13/13.2/13.2-14-s.js new file mode 100644 index 000000000..53b9bf021 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-14-s.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 ch13/13.2/13.2-14-s.js
+ * @description StrictMode - writing a property named 'arguments' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = new Function("'use strict';");
+ try {
+ foo.arguments = 41;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-15-1.js b/js/src/tests/test262/ch13/13.2/13.2-15-1.js new file mode 100644 index 000000000..7575c6037 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-15-1.js @@ -0,0 +1,35 @@ +/// 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 ch13/13.2/13.2-15-1.js
+ * @description Function Object has length as its own property and does not invoke the setter defined on Function.prototype.length (Step 15)
+ */
+
+
+function testcase() {
+ var fun = function (x, y) { };
+
+ var verifyValue = false;
+ verifyValue = (fun.hasOwnProperty("length") && fun.length === 2);
+
+ var verifyWritable = false;
+ fun.length = 1001;
+ verifyWritable = (fun.length === 1001);
+
+ var verifyEnumerable = false;
+ for (var p in fun) {
+ if (p === "length") {
+ verifyEnumerable = true;
+ }
+ }
+
+ var verifyConfigurable = false;
+ delete fun.length;
+ verifyConfigurable = fun.hasOwnProperty("length");
+
+ return verifyValue && !verifyWritable && !verifyEnumerable && verifyConfigurable;
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-15-s.js b/js/src/tests/test262/ch13/13.2/13.2-15-s.js new file mode 100644 index 000000000..b14dd3cad --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-15-s.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 ch13/13.2/13.2-15-s.js
+ * @description StrictMode - enumerating over a function object looking for 'arguments' fails outside of the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = new Function("'use strict';");
+
+ for (var tempIndex in foo) {
+ if (tempIndex === "arguments") {
+ return false;
+ }
+ }
+ return true;
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-16-s.js b/js/src/tests/test262/ch13/13.2/13.2-16-s.js new file mode 100644 index 000000000..154887e9a --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-16-s.js @@ -0,0 +1,18 @@ +/// 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 ch13/13.2/13.2-16-s.js
+ * @description StrictMode - enumerating over a function object looking for 'arguments' fails inside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = new Function("'use strict'; for (var tempIndex in this) {if (tempIndex===\"arguments\") {return false;}}; return true;");
+ return foo();
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-17-1.js b/js/src/tests/test262/ch13/13.2/13.2-17-1.js new file mode 100644 index 000000000..654f2b5dd --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-17-1.js @@ -0,0 +1,55 @@ +/// 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 ch13/13.2/13.2-17-1.js
+ * @description Function Object has 'constructor' as its own property, it is not enumerable and does not invoke the setter defined on Function.prototype.constructor (Step 17)
+ */
+
+
+function testcase() {
+ var desc = Object.getOwnPropertyDescriptor(Object.prototype, "constructor");
+ try {
+ var getFunc = function () {
+ return 100;
+ };
+
+ var data = "data";
+ var setFunc = function (value) {
+ data = value;
+ };
+
+ Object.defineProperty(Object.prototype, "constructor", {
+ get: getFunc,
+ set: setFunc,
+ configurable: true
+ });
+
+ var fun = function () {};
+
+ var verifyValue = false;
+ verifyValue = typeof fun.prototype.constructor === "function";
+
+ var verifyEnumerable = false;
+ for (var p in fun.prototype) {
+ if (p === "constructor" && fun.prototype.hasOwnProperty("constructor")) {
+ verifyEnumerable = true;
+ }
+ }
+
+ var verifyWritable = false;
+ fun.prototype.constructor = 12;
+ verifyWritable = (fun.prototype.constructor === 12);
+
+ var verifyConfigurable = false;
+ delete fun.prototype.constructor;
+ verifyConfigurable = fun.hasOwnProperty("constructor");
+
+ return verifyValue && verifyWritable && !verifyEnumerable && !verifyConfigurable && data === "data";
+ } finally {
+ Object.defineProperty(Object.prototype, "constructor", desc);
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-17-s.js b/js/src/tests/test262/ch13/13.2/13.2-17-s.js new file mode 100644 index 000000000..6ff1776b6 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-17-s.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 ch13/13.2/13.2-17-s.js
+ * @description StrictMode - reading a property named 'arguments' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = Function("'use strict';");
+ try {
+ var temp = foo.arguments;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-18-1.js b/js/src/tests/test262/ch13/13.2/13.2-18-1.js new file mode 100644 index 000000000..d3614872c --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-18-1.js @@ -0,0 +1,53 @@ +/// 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 ch13/13.2/13.2-18-1.js
+ * @description Function Object has 'prototype' as its own property, it is not enumerable and does not invoke the setter defined on Function.prototype (Step 18)
+ */
+
+
+function testcase() {
+ try {
+ var getFunc = function () {
+ return 100;
+ };
+
+ var data = "data";
+ var setFunc = function (value) {
+ data = value;
+ };
+ Object.defineProperty(Function.prototype, "prototype", {
+ get: getFunc,
+ set: setFunc,
+ configurable: true
+ });
+
+ var fun = function () { };
+
+ var verifyValue = false;
+ verifyValue = (fun.prototype !== 100 && fun.prototype.toString() === "[object Object]");
+
+ var verifyEnumerable = false;
+ for (var p in fun) {
+ if (p === "prototype" && fun.hasOwnProperty("prototype")) {
+ verifyEnumerable = true;
+ }
+ }
+
+ var verifyConfigurable = false;
+ delete fun.prototype;
+ verifyConfigurable = fun.hasOwnProperty("prototype");
+
+ var verifyWritable = false;
+ fun.prototype = 12
+ verifyWritable = (fun.prototype === 12);
+
+ return verifyValue && verifyWritable && !verifyEnumerable && verifyConfigurable && data === "data";
+ } finally {
+ delete Function.prototype.prototype;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-18-s.js b/js/src/tests/test262/ch13/13.2/13.2-18-s.js new file mode 100644 index 000000000..c0ac07cc9 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-18-s.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 ch13/13.2/13.2-18-s.js
+ * @description StrictMode - writing a property named 'arguments' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = Function("'use strict';");
+ try {
+ foo.arguments = 41;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-19-b-3gs.js b/js/src/tests/test262/ch13/13.2/13.2-19-b-3gs.js new file mode 100644 index 000000000..cd356070d --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-19-b-3gs.js @@ -0,0 +1,15 @@ +/// 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 ch13/13.2/13.2-19-b-3gs.js
+ * @description StrictMode - error is thrown when assign a value to the 'caller' property of a function object
+ * @onlyStrict
+ * @negative NotEarlyError
+ */
+"use strict";
+throw NotEarlyError;
+function _13_2_19_b_3_gs() {}
+_13_2_19_b_3_gs.caller = 1;
diff --git a/js/src/tests/test262/ch13/13.2/13.2-19-s.js b/js/src/tests/test262/ch13/13.2/13.2-19-s.js new file mode 100644 index 000000000..5e8b67e6a --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-19-s.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 ch13/13.2/13.2-19-s.js
+ * @description StrictMode - enumerating over a function object looking for 'arguments' fails outside of the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = Function("'use strict';");
+
+ for (var tempIndex in foo) {
+ if (tempIndex === "arguments") {
+ return false;
+ }
+ }
+ return true;
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-2-s.js b/js/src/tests/test262/ch13/13.2/13.2-2-s.js new file mode 100644 index 000000000..f2bdf6898 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-2-s.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 ch13/13.2/13.2-2-s.js
+ * @description StrictMode - A TypeError is thrown when a strict mode code writes to properties named 'caller' of function instances.
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ "use strict";
+ try {
+ var foo = function () {
+ }
+ foo.caller = 20;
+ return false;
+ } catch (ex) {
+ return ex instanceof TypeError;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-20-s.js b/js/src/tests/test262/ch13/13.2/13.2-20-s.js new file mode 100644 index 000000000..5eee4a321 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-20-s.js @@ -0,0 +1,18 @@ +/// 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 ch13/13.2/13.2-20-s.js
+ * @description StrictMode - enumerating over a function object looking for 'arguments' fails inside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = Function("'use strict'; for (var tempIndex in this) {if (tempIndex===\"arguments\") {return false;}}; return true;");
+ return foo();
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-21-s.js b/js/src/tests/test262/ch13/13.2/13.2-21-s.js new file mode 100644 index 000000000..42ad83815 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-21-s.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 ch13/13.2/13.2-21-s.js
+ * @description StrictMode - reading a property named 'caller' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ function foo () {"use strict";}
+ try {
+ var temp = foo.caller;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-22-s.js b/js/src/tests/test262/ch13/13.2/13.2-22-s.js new file mode 100644 index 000000000..ab901903c --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-22-s.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 ch13/13.2/13.2-22-s.js
+ * @description StrictMode - writing a property named 'caller' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ function foo () {"use strict";}
+ try {
+ foo.caller = 41;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-23-s.js b/js/src/tests/test262/ch13/13.2/13.2-23-s.js new file mode 100644 index 000000000..0e89b66ae --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-23-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 ch13/13.2/13.2-23-s.js
+ * @description StrictMode - enumerating over a function object looking for 'caller' fails outside of the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ function foo () {"use strict";}
+ for (var tempIndex in foo) {
+ if (tempIndex === "caller") {
+ return false;
+ }
+ }
+ return true;
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-24-s.js b/js/src/tests/test262/ch13/13.2/13.2-24-s.js new file mode 100644 index 000000000..f9008fc56 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-24-s.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 ch13/13.2/13.2-24-s.js
+ * @description StrictMode - enumerating over a function object looking for 'caller' fails inside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ function foo () {
+ "use strict";
+ for (var tempIndex in this) {
+ if (tempIndex==="caller") {
+ return false;
+ }
+ }
+ return true;
+ }
+ return foo();
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-25-s.js b/js/src/tests/test262/ch13/13.2/13.2-25-s.js new file mode 100644 index 000000000..b4c650897 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-25-s.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 ch13/13.2/13.2-25-s.js
+ * @description StrictMode - reading a property named 'arguments' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ function foo () {"use strict";}
+ try {
+ var temp = foo.arguments;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-26-s.js b/js/src/tests/test262/ch13/13.2/13.2-26-s.js new file mode 100644 index 000000000..68682ce31 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-26-s.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 ch13/13.2/13.2-26-s.js
+ * @description StrictMode - writing a property named 'arguments' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ function foo () {"use strict";}
+ try {
+ foo.arguments = 41;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-27-s.js b/js/src/tests/test262/ch13/13.2/13.2-27-s.js new file mode 100644 index 000000000..d6177986a --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-27-s.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 ch13/13.2/13.2-27-s.js
+ * @description StrictMode - enumerating over a function object looking for 'arguments' fails outside of the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ function foo () {"use strict";}
+
+ for (var tempIndex in foo) {
+ if (tempIndex === "arguments") {
+ return false;
+ }
+ }
+ return true;
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-28-s.js b/js/src/tests/test262/ch13/13.2/13.2-28-s.js new file mode 100644 index 000000000..dd9dad3ee --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-28-s.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 ch13/13.2/13.2-28-s.js
+ * @description StrictMode - enumerating over a function object looking for 'arguments' fails inside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ function foo() {
+ "use strict";
+ for (var tempIndex in this) {
+ if (tempIndex==="arguments") {
+ return false;
+ }
+ }
+ return true;
+ }
+ return foo();
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-29-s.js b/js/src/tests/test262/ch13/13.2/13.2-29-s.js new file mode 100644 index 000000000..c84a8b2e6 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-29-s.js @@ -0,0 +1,19 @@ +/// 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 ch13/13.2/13.2-29-s.js
+ * @description StrictMode - property named 'caller' of function objects is not configurable
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ function foo() {"use strict";}
+ return Object.getOwnPropertyDescriptor(foo,
+ "caller") === undefined;
+}
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-3-s.js b/js/src/tests/test262/ch13/13.2/13.2-3-s.js new file mode 100644 index 000000000..642f417c7 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-3-s.js @@ -0,0 +1,22 @@ +/// 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 ch13/13.2/13.2-3-s.js
+ * @description StrictMode - Writing or reading from a property named 'arguments' of function objects is allowed under both strict and normal modes.
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ "use strict";
+
+ var foo = function () {
+ this.arguments = 12;
+ }
+ var obj = new foo();
+ return obj.arguments === 12;
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-30-s.js b/js/src/tests/test262/ch13/13.2/13.2-30-s.js new file mode 100644 index 000000000..8fed90947 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-30-s.js @@ -0,0 +1,18 @@ +/// 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 ch13/13.2/13.2-30-s.js
+ * @description StrictMode - property named 'caller' of function objects is not configurable
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ return Object.getOwnPropertyDescriptor(Function("'use strict';"),
+ "caller") === undefined;
+}
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-31-s.js b/js/src/tests/test262/ch13/13.2/13.2-31-s.js new file mode 100644 index 000000000..41a438483 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-31-s.js @@ -0,0 +1,18 @@ +/// 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 ch13/13.2/13.2-31-s.js
+ * @description StrictMode - property named 'caller' of function objects is not configurable
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ return Object.getOwnPropertyDescriptor(new Function("'use strict';"),
+ "caller") === undefined;
+}
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-32-s.js b/js/src/tests/test262/ch13/13.2/13.2-32-s.js new file mode 100644 index 000000000..9c9bdb7f9 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-32-s.js @@ -0,0 +1,19 @@ +/// 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 ch13/13.2/13.2-32-s.js
+ * @description StrictMode - property named 'caller' of function objects is not configurable
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var funcExpr = function () { "use strict";};
+ return Object.getOwnPropertyDescriptor(funcExpr,
+ "caller") === undefined;
+}
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-33-s.js b/js/src/tests/test262/ch13/13.2/13.2-33-s.js new file mode 100644 index 000000000..1db245cb5 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-33-s.js @@ -0,0 +1,19 @@ +/// 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 ch13/13.2/13.2-33-s.js
+ * @description StrictMode - property named 'arguments' of function objects is not configurable
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ function foo() {"use strict";}
+ return Object.getOwnPropertyDescriptor(foo,
+ "arguments") === undefined;
+}
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-34-s.js b/js/src/tests/test262/ch13/13.2/13.2-34-s.js new file mode 100644 index 000000000..6d3a18078 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-34-s.js @@ -0,0 +1,18 @@ +/// 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 ch13/13.2/13.2-34-s.js
+ * @description StrictMode - property named 'arguments' of function objects is not configurable
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ return Object.getOwnPropertyDescriptor(Function("'use strict';"),
+ "arguments") === undefined;
+}
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-35-s.js b/js/src/tests/test262/ch13/13.2/13.2-35-s.js new file mode 100644 index 000000000..bdb65cb0b --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-35-s.js @@ -0,0 +1,18 @@ +/// 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 ch13/13.2/13.2-35-s.js
+ * @description StrictMode - property named 'arguments' of function objects is not configurable
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ return Object.getOwnPropertyDescriptor(new Function("'use strict';"),
+ "arguments") === undefined;
+}
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-36-s.js b/js/src/tests/test262/ch13/13.2/13.2-36-s.js new file mode 100644 index 000000000..be55e7689 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-36-s.js @@ -0,0 +1,19 @@ +/// 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 ch13/13.2/13.2-36-s.js
+ * @description StrictMode - property named 'arguments' of function objects is not configurable
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var funcExpr = function () { "use strict";};
+ return Object.getOwnPropertyDescriptor(funcExpr,
+ "arguments") === undefined;
+}
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-4-s.js b/js/src/tests/test262/ch13/13.2/13.2-4-s.js new file mode 100644 index 000000000..82981f467 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-4-s.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 ch13/13.2/13.2-4-s.js
+ * @description StrictMode - A TypeError is thrown when a code in strict mode tries to write to 'arguments' of function instances.
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ "use strict";
+ try {
+ var foo = function () {
+ }
+ foo.arguments = 20;
+ return false;
+ } catch (ex) {
+ return ex instanceof TypeError;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-5-s.js b/js/src/tests/test262/ch13/13.2/13.2-5-s.js new file mode 100644 index 000000000..2512e5ef0 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-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 ch13/13.2/13.2-5-s.js
+ * @description StrictMode - reading a property named 'caller' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ var foo = new Function("'use strict';");
+ try {
+ var temp = foo.caller;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-6-s.js b/js/src/tests/test262/ch13/13.2/13.2-6-s.js new file mode 100644 index 000000000..5b6de1de9 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-6-s.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 ch13/13.2/13.2-6-s.js
+ * @description StrictMode - writing a property named 'caller' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = new Function("'use strict';");
+ try {
+ foo.caller = 41;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/13.2-7-s.js b/js/src/tests/test262/ch13/13.2/13.2-7-s.js new file mode 100644 index 000000000..2b5fbb185 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-7-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 ch13/13.2/13.2-7-s.js
+ * @description StrictMode - enumerating over a function object looking for 'caller' fails outside of the function
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ var foo = new Function("'use strict';");
+
+ for (var tempIndex in foo) {
+ if (tempIndex === "caller") {
+ return false;
+ }
+ }
+ return true;
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-8-s.js b/js/src/tests/test262/ch13/13.2/13.2-8-s.js new file mode 100644 index 000000000..42bcc07d9 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-8-s.js @@ -0,0 +1,17 @@ +/// 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 ch13/13.2/13.2-8-s.js
+ * @description StrictMode - enumerating over a function object looking for 'caller' fails inside the function
+ * @onlyStrict
+ */
+
+
+function testcase() {
+ var foo = new Function("'use strict'; for (var tempIndex in this) {if (tempIndex===\"caller\") {return false;}}; return true;");
+ return foo();
+ }
+runTestCase(testcase);
diff --git a/js/src/tests/test262/ch13/13.2/13.2-9-s.js b/js/src/tests/test262/ch13/13.2/13.2-9-s.js new file mode 100644 index 000000000..fac6285e6 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/13.2-9-s.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 ch13/13.2/13.2-9-s.js
+ * @description StrictMode - reading a property named 'caller' of function objects is not allowed outside the function
+ * @onlyStrict
+ */
+
+
+
+function testcase() {
+ var foo = Function("'use strict';");
+ try {
+ var temp = foo.caller;
+ return false;
+ }
+ catch (e) {
+ return e instanceof TypeError;
+ }
+}
+runTestCase(testcase);
\ No newline at end of file diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A1_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A1_T1.js new file mode 100644 index 000000000..1295b6a48 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A1_T1.js @@ -0,0 +1,74 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * The depth of nested function calls reaches 32 + * + * @path ch13/13.2/S13.2.1_A1_T1.js + * @description Creating function calls 32 elements depth + */ + +(function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){ + (function(){})() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() + })() +})() + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T1.js new file mode 100644 index 000000000..a2bce3580 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T1.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Objects as arguments are passed by reference + * + * @path ch13/13.2/S13.2.1_A4_T1.js + * @description Adding new number property to a function argument within the function body, + * where explicit argument is an object defined with "var __obj={}" + */ + +function __func(__arg){ + __arg.foo=7; +} + +var __obj={}; + +__func(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.foo !== 7) { + $ERROR('#1: __obj.foo === 7. Actual: __obj.foo ==='+__obj.foo); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T2.js new file mode 100644 index 000000000..682f57d08 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T2.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Objects as arguments are passed by reference + * + * @path ch13/13.2/S13.2.1_A4_T2.js + * @description Adding new string property to a function argument within the function body, + * where explicit argument is an object defined with "__obj={}" + */ + +function __func(__arg){ + __arg.foo="whiskey gogo"; +} + +var __obj={}; + + __func(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.foo !== "whiskey gogo") { + $ERROR('#1: __obj.foo === "whiskey gogo". Actual: __obj.foo ==='+__obj.foo); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T3.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T3.js new file mode 100644 index 000000000..00ee68b10 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T3.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Objects as arguments are passed by reference + * + * @path ch13/13.2/S13.2.1_A4_T3.js + * @description Adding new number property to a function argument within the function body, + * where array element "arguments[0]" is an object defined with "__obj={}" + */ + +function __func(){ + arguments[0]["PI"]=3.14; +} + +var __obj={}; + +__func(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.PI !== 3.14) { + $ERROR('#1: __obj.PI === 3.14. Actual: __obj.PI ==='+__obj.PI); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T4.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T4.js new file mode 100644 index 000000000..a9a026121 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A4_T4.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Objects as arguments are passed by reference + * + * @path ch13/13.2/S13.2.1_A4_T4.js + * @description Adding new number property to a function argument within the function body, + * where array element "arguments[0]" is an object defined with "var __obj={}" + */ + +function __func(){ + arguments[0]["E"]=2.74; +} + +var __obj={}; + +__func(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.E !== 2.74) { + $ERROR('#1: __obj.E === 2.74. Actual: __obj.E ==='+__obj.E); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A5_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A5_T1.js new file mode 100644 index 000000000..81909da90 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A5_T1.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Closures are admitted + * + * @path ch13/13.2/S13.2.1_A5_T1.js + * @description Sorting with closure + */ + +var __arr = [4,3,2,1,4,3,2,1,4,3,2,1]; +//Sort uses closure +// +__arr.sort( + function(x,y) { + if (x>y){return -1;} + if (x<y){return 1;} + if (x==y){return 0;} + } +); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__arr.toString() !== [4,4,4,3,3,3,2,2,2,1,1,1].toString()) { + $ERROR('#1: __arr.toString() === [4,4,4,3,3,3,2,2,2,1,1,1].toString(). Actual: __arr.toString() ==='+__arr.toString()); +} + +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A5_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A5_T2.js new file mode 100644 index 000000000..e48402cd6 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A5_T2.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Closures are admitted + * + * @path ch13/13.2/S13.2.1_A5_T2.js + * @description Returning a function that approximates the derivative of f + * using an interval of dx, which should be appropriately small + */ + +// Return a function that approximates the derivative of f +// using an interval of dx, which should be appropriately small. +function derivative(f, dx) { + return function(x) { + return (f(x + dx) - f(x)) / dx; + }; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (Math.abs(derivative(Math.sin, 0.0001)(0) - derivative(Math.sin, 0.0001)(2*Math.PI)) >= 1/65536.0) { + $ERROR('#1: Math.abs(derivative(Math.sin, 0.0001)(0) - derivative(Math.sin, 0.0001)(2*Math.PI)) <= 1/65536.0'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A6_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A6_T1.js new file mode 100644 index 000000000..a1d360b34 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A6_T1.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Primitive types are passed by value + * + * @path ch13/13.2/S13.2.1_A6_T1.js + * @description Declaring a function with "function __func(arg1, arg2)" + */ + +function __func(arg1, arg2){ + arg1++; + arg2+="BA"; +}; + +var x=1; +y=2; +var a="AB" +b="SAM"; + +__func(x,a); +__func(y,b); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x!==1 || y!==2 || a!=="AB" || b!=="SAM") { + $ERROR('#1: x === 1 and y === 2 and a === "AB" and b === "SAM". Actual: x ==='+x+' and y ==='+y+' and a ==='+a+' and b ==='+b); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A6_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A6_T2.js new file mode 100644 index 000000000..f92bafaf2 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A6_T2.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Primitive types are passed by value + * + * @path ch13/13.2/S13.2.1_A6_T2.js + * @description Declaring a function with "__func = function(arg1, arg2)" + */ + +__func = function(arg1, arg2){ + arg1++; + arg2+="BA"; +}; + +var x=1; +y=2; +var a="AB" +b="SAM"; + +__func(x,a); +__func(y,b); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x!==1 || y!==2 || a!=="AB" || b!=="SAM") { + $ERROR('#1: x === 1 and y === 2 and a === "AB" and b === "SAM". Actual: x ==='+x+' and y ==='+y+' and a ==='+a+' and b ==='+b); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A7_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A7_T1.js new file mode 100644 index 000000000..4e46fcafe --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A7_T1.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Call]] property for a Function object F is called, the following steps are taken: + * 2. Evaluate F's FunctionBody; + * if Result.type is returned then Result.value is returned too + * + * @path ch13/13.2/S13.2.1_A7_T1.js + * @description Returning null. Declaring a function with "function __func()" + */ + +function __func(){ + var x = null; + return x; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var x=__func(); +} catch(e){ + $ERROR('#1: var x=__func() does not lead to throwing exception. Actual: exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A7_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A7_T2.js new file mode 100644 index 000000000..ae4fbb406 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A7_T2.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Call]] property for a Function object F is called, the following steps are taken: + * 2. Evaluate F's FunctionBody; + * if Result.type is returned then Result.value is returned too + * + * @path ch13/13.2/S13.2.1_A7_T2.js + * @description Returning null. Declaring a function with "var __func = function ()" + */ + +var __func = function (){ + var x = null; + return x; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var x=__func(); +} catch(e){ + $ERROR('#1: var x=__func() does not lead to throwing exception. Actual: exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A7_T3.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A7_T3.js new file mode 100644 index 000000000..efbb8a04d --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A7_T3.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. + +/** + * When the [[Call]] property for a Function object F is called, the following steps are taken: + * 2. Evaluate F's FunctionBody; + * if Result.type is returned then Result.value is returned too + * + * @path ch13/13.2/S13.2.1_A7_T3.js + * @description Returning number. Declaring a function with "function __func()" + */ + +function __func(){ + x = 1; + return x; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +try { + x=x; + $ERROR('#0: "x=x" lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var __x=__func(); +} catch(e){ + $ERROR('#1: var __x=__func() does not lead to throwing exception. Actual: exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__x !== 1) { + $ERROR('#2: __x === 1. Actual: __x ==='+__x); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (x !== 1) { + $ERROR('#3: x === 1. Actual: x ==='+x); +} +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A7_T4.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A7_T4.js new file mode 100644 index 000000000..7461324ed --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A7_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. + +/** + * When the [[Call]] property for a Function object F is called, the following steps are taken: + * 2. Evaluate F's FunctionBody; + * if Result.type is returned then Result.value is returned too + * + * @path ch13/13.2/S13.2.1_A7_T4.js + * @description Returning boolean. Declaring a function with "function __func()" + */ + +function __func(){ + var x = true; + return x; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +try { + x=x; + $ERROR('#0: "x=x" lead to throwing exception');
+} catch (e) {
+ if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var __x=__func() +} catch(e){ + $ERROR('#1: var __x=__func() does not lead to throwing exception. Actual: exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!(__x)) { + $ERROR('#2: __x === true. Actual: __x ==='+__x); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +try { + x=x; + $ERROR('#3: "x=x" lead to throwing exception');
+} catch (e) {
+ if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A8_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A8_T1.js new file mode 100644 index 000000000..2be9cb728 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A8_T1.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Call]] property for a Function object F is called, the following steps are taken: + * 2. Evaluate F's FunctionBody; + * if Result.type is thrown then Result.value is thrown too + * + * @path ch13/13.2/S13.2.1_A8_T1.js + * @description Throwing an exception within a function body. Declaring function with "function __func()" + */ + +function __func(){ + var x = 1; + throw ("Catch Me If You Can") + return x; +} + +try{ + var x=__func() + $ERROR('#0: var x=__func() lead to throwing exception'); +} catch(e){ + if (e !== "Catch Me If You Can") { + $ERROR('#1: Exception === "Catch Me If You Can". Actual: exception ==='+e); + } +} + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A8_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A8_T2.js new file mode 100644 index 000000000..c07582b28 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A8_T2.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Call]] property for a Function object F is called, the following steps are taken: + * 2. Evaluate F's FunctionBody; + * if Result.type is thrown then Result.value is thrown too + * + * @path ch13/13.2/S13.2.1_A8_T2.js + * @description Throwing an exception within a function body. Declaring function with "var __func = function (message)" + */ + +var CATCH_ME_IF_YOU_CAN = true; + +var __func = function (message){ + var x = 1; + throw (message) + return x; +} + +try{ + var x=__func(CATCH_ME_IF_YOU_CAN) + $ERROR('#0: var x=__func(CATCH_ME_IF_YOU_CAN) lead to throwing exception'); +} catch(e){ + if (!e) { + $ERROR('#1: Exception === true. Actual: exception ==='+e); + } +} + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A9.1_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A9.1_T1.js new file mode 100644 index 000000000..9b1dd7382 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A9.1_T1.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Call]] property for a Function object is called, + * the body is evaluated and if evaluation result has type "normal", then "undefined" is returned + * + * @path ch13/13.2/S13.2.1_A9.1_T1.js + * @description Declaring a function with "function __func()" and no "return" in the function body + */ + +var x; + +function __func(){ + x = true; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== undefined) { + $ERROR('#1: __func() === undefined. Actual: __func() ==='+__func()); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!x) { + $ERROR('#2: x === true. Actual: x === '+x); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A9.1_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A9.1_T2.js new file mode 100644 index 000000000..90057b04b --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A9.1_T2.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Call]] property for a Function object is called, + * the body is evaluated and if evaluation result has type "normal", then "undefined" is returned + * + * @path ch13/13.2/S13.2.1_A9.1_T2.js + * @description Declaring a function with "var __func = function()" and no "return" in the function body + */ + +var x; + +var __func = function(){ + x = true; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== undefined) { + $ERROR('#1: __func() === undefined. Actual: __func() ==='+__func()); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!x) { + $ERROR('#2: x === true. Actual: x === '+x); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A9_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A9_T1.js new file mode 100644 index 000000000..6332ef34e --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A9_T1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Call]] property for a Function object is called, + * the body is evaluated and if evaluation result has type "return" its value is not defined, then "undefined" is returned + * + * @path ch13/13.2/S13.2.1_A9_T1.js + * @description Using "return" with no expression. Declaring a function with "function __func()" + */ + +var x; + +function __func(){ + x = 1; + return; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== undefined) { + $ERROR('#1: __func() === undefined. Actual: __func() ==='+__func()); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (x!==1) { + $ERROR('#2: x === 1. Actual: x === '+x); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.1_A9_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.1_A9_T2.js new file mode 100644 index 000000000..75be8a19a --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.1_A9_T2.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Call]] property for a Function object is called, + * the body is evaluated and if evaluation result has type "return" its value is not defined, then "undefined" is returned + * + * @path ch13/13.2/S13.2.1_A9_T2.js + * @description Using "return" with no expression. Declaring a function with "var __func = function()" + */ + +var x; + +var __func = function(){ + x = 1; + return; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== undefined) { + $ERROR('#1: __func() === undefined. Actual: __func() ==='+__func()); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (x!==1) { + $ERROR('#2: x === 1. Actual: x === '+x); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A10.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A10.js new file mode 100644 index 000000000..25ba9d58d --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A10.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Calling a function as a constructor is possible as long as this.any_Function is declared + * + * @path ch13/13.2/S13.2.2_A10.js + * @description Calling a function as a constructor after it has been declared + */ + +function FACTORY(){ + this.id = 0; + + this.func = function (){ + return 5; + } + + this.id = this.func(); + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); +} catch (e) { + $ERROR('#1: var obj = new FACTORY() does not lead to throwing exception. Actual: Exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (obj.id !== 5) { + $ERROR('#2: obj.id === 5. Actual: obj.id ==='+obj.id); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A11.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A11.js new file mode 100644 index 000000000..13f7f4e9b --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A11.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Calling a function as a constructor is possible as long as this.any_Function is declared and called + * + * @path ch13/13.2/S13.2.2_A11.js + * @description Calling a function as a constructor after it has been declared with "function func()" + */ + +function FACTORY(){ + this.id = 0; + + this.id = this.func(); + + function func(){ + return "id_string"; + } + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); + $ERROR('#1: var obj = new FACTORY() lead to throwing exception');
+} catch (e) {
+ if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A12.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A12.js new file mode 100644 index 000000000..52d4a95b6 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A12.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Calling a function as a constructor is possible as long as this.any_Function is declared and called + * + * @path ch13/13.2/S13.2.2_A12.js + * @description Calling a function as a constructor after it has been declared with "function func()" + */ + +function FACTORY(){ + this.id = 0; + + this.id = func(); + + function func(){ + return "id_string"; + } + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); +} catch (e) { + $ERROR('#1: var obj = new FACTORY() does not lead to throwing exception. Actual: Exception is '+e); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (obj.id !== "id_string") { + $ERROR('#2: obj.id === "id_string". Actual: obj.id ==='+obj.id); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A13.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A13.js new file mode 100644 index 000000000..79801ac9e --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A13.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Calling a function as a constructor is inadmissible as long as this.any_Function is declared by eval and called + * + * @path ch13/13.2/S13.2.2_A13.js + * @description Calling a function as a constructor after it has been declared by eval + */ + +function FACTORY(){ + this.id = 0; + + this.id = func(); + + eval("function func(){return \"id_string\";}"); + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); + $ERROR('#1: var obj = new FACTORY() lead to throwing exception');
+} catch (e) {
+ if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A14.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A14.js new file mode 100644 index 000000000..2db1005bc --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A14.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Calling a function as a constructor is inadmissible as long as this.any_Function is declared by eval and called + * + * @path ch13/13.2/S13.2.2_A14.js + * @description Calling a function as a constructor after it has been declared by eval + * @noStrict + */ + +function FACTORY(){ + this.id = 0; + + eval("function func(){return \"id_string\";}"); + + this.id = func(); + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); +} catch (e) { + $ERROR('#1: var obj = new FACTORY() does not lead to throwing exception'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T1.js new file mode 100644 index 000000000..6548618eb --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T1.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. + +/** + * When the [[Construct]] property for a Function object F is called, + * and the object created in the function is returned, the object (declared with "this" within a function) will be strong and healthy + * + * @path ch13/13.2/S13.2.2_A15_T1.js + * @description Function declared at the end of the program and "obj" property is declared with "var obj = {}" + */ + +var __obj = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof obj !== "undefined") { + $ERROR('#1: typeof obj === "undefined". Actual: typeof obj ==='+typeof obj); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== "A") { + $ERROR('#2: __obj.prop === "A". Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.slot.prop !==1) { + $ERROR('#3: __obj.slot.prop ===1. Actual: __obj.slot.prop ==='+__obj.slot.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __FACTORY(){ + this.prop = 1; + var obj = {}; + obj.prop = "A"; + obj.slot = this; + return obj; +} + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T2.js new file mode 100644 index 000000000..007474b4b --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T2.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. + +/** + * When the [[Construct]] property for a Function object F is called, + * and the object created in the function is returned, the object (declared with "this" within a function) will be strong and healthy + * + * @path ch13/13.2/S13.2.2_A15_T2.js + * @description Function declared at the end of the program and "obj" property is declared with "obj = {}" + */ + +var __obj = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (obj.prop !== "A") { + $ERROR('#1: obj.prop === "A". Actual: obj.prop ==='+obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== "A") { + $ERROR('#2: __obj.prop === "A". Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.slot.prop !==1) { + $ERROR('#3: __obj.slot.prop === 1. Actual: __obj.slot.prop ==='+__obj.slot.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __FACTORY(){ + this.prop = 1; + obj = {}; + obj.prop = "A"; + obj.slot = this; + return obj; +} + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T3.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T3.js new file mode 100644 index 000000000..c448df552 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T3.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. + +/** + * When the [[Construct]] property for a Function object F is called, + * and the object created in the function is returned, the object (declared with "this" within a function) will be strong and healthy + * + * @path ch13/13.2/S13.2.2_A15_T3.js + * @description Function declared at the end of the program and "obj" property is declared with "var obj = {}" + */ + +__FACTORY = function (){ + this.prop = 1; + var obj = {}; + obj.prop = "A"; + obj.slot = this; + return obj; +} + +__obj = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof obj !== "undefined") { + $ERROR('#1: typeof obj === "undefined". Actual: typeof obj ==='+typeof obj); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== "A") { + $ERROR('#2: __obj.prop === "A". Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.slot.prop !==1) { + $ERROR('#3: __obj.slot.prop ===1. Actual: __obj.slot.prop ==='+__obj.slot.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T4.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T4.js new file mode 100644 index 000000000..5667b9b52 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A15_T4.js @@ -0,0 +1,46 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called, + * and the object created in the function is returned, the object (declared with "this" within a function) will be strong and healthy + * + * @path ch13/13.2/S13.2.2_A15_T4.js + * @description Function declared at the end of the program and "obj" property is declared with "obj = {}" + */ + +__FACTORY = function(){ + this.prop = 1; + obj = {}; + obj.prop = "A"; + obj.slot = this; + return obj; +} + +__obj = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (obj.prop !== "A") { + $ERROR('#1: obj.prop === "A". Actual: obj.prop ==='+obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== "A") { + $ERROR('#2: __obj.prop === "A". Actual: __obj.prop ==='+obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.slot.prop !==1) { + $ERROR('#3: __obj.slot.prop ===1. Actual: __obj.slot.prop ==='+obj.slot.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A16_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A16_T1.js new file mode 100644 index 000000000..ea40cfb09 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A16_T1.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * FunctionExpression within a new statement is admitted + * + * @path ch13/13.2/S13.2.2_A16_T1.js + * @description Using "is __obj = new function __func(){this.prop=1;}" as FunctionExpression + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "undefined") { + $ERROR('#1: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = new function __func(){this.prop=1;}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== 1) { + $ERROR('#2: __obj.prop === 1. Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof __func !== "undefined") { + $ERROR('#5: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A16_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A16_T2.js new file mode 100644 index 000000000..2af36ba44 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A16_T2.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * FunctionExpression within a new statement is admitted + * + * @path ch13/13.2/S13.2.2_A16_T2.js + * @description Using "var __obj = new function __func(arg){this.prop=arg;}(5)" as FunctionExpression + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "undefined") { + $ERROR('#1: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = new function __func(arg){this.prop=arg;}(5); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== 5) { + $ERROR('#2: __obj.prop === 5. Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __func !== "undefined") { + $ERROR('#3: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A16_T3.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A16_T3.js new file mode 100644 index 000000000..8cff917f6 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A16_T3.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * FunctionExpression within a new statement is admitted + * + * @path ch13/13.2/S13.2.2_A16_T3.js + * @description Using "is __obj = new function __func(arg){this.prop=arg; return {feat: ++arg}}(5)" as FunctionExpression + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "undefined") { + $ERROR('#1: typeof __func === "undefined"'); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = new function __func(arg){this.prop=arg; return {feat: ++arg}}(5); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.prop !== undefined) { + $ERROR('#2: __obj.prop === undefined. Actual: __obj.prop ==='+__obj.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.feat !== 6) { + $ERROR('#3: __obj.feat === 6. Actual: __obj.feat ==='+__obj.feat); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (typeof __func !== "undefined") { + $ERROR('#4: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A17_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A17_T2.js new file mode 100644 index 000000000..105b762d7 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A17_T2.js @@ -0,0 +1,72 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * FunctionExpression containing "with" statement is admitted + * + * @path ch13/13.2/S13.2.2_A17_T2.js + * @description Throwing an exception within "with" statement + */ + +this.p1="alert"; + +__obj={p1:1,getRight:function(){return "right";}}; + +getRight=function(){return "napravo";}; + +try { + (function(){ + with(__obj){ + p1="w1"; + getRight=function(){return false;} + throw p1; + } + })(); +} catch (e) { + resukt = p1; +} + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (p1!=="alert") { + $ERROR('#1: p1 === "alert". Actual: p1==='+p1); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (getRight()!=="napravo") { + $ERROR('#2: getRight() === "napravo". Actual: getRight() === '+getRight()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.p1!=="w1") { + $ERROR('#3: __obj.p1 === "w1". Actual: __obj.p1 ==='+__obj.p1); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__obj.getRight()!==false) { + $ERROR('#4: __obj.getRight() === false. Actual: __obj.getRight() === '+__obj.getRight()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (resukt !== "alert") { + $ERROR('#5: resukt === "alert". Actual: resukt ==='+resukt); +} +// +////////////////////////////////////////////////////////////////////////////// + +var resukt; + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A17_T3.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A17_T3.js new file mode 100644 index 000000000..8d8eba5bd --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A17_T3.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. + +/** + * FunctionExpression containing "with" statement is admitted + * + * @path ch13/13.2/S13.2.2_A17_T3.js + * @description In the check 4 we populate field getRight in __obj object since var getRight declaration adds variable to function scope + * but getRight in statement resolves within with(__obj) scope and searchs getRight in __obj first + */ + +p1="alert"; + +this.__obj={p1:1,getRight:function(){return "right";}}; + +var getRight=function(){return "napravo";}; + +resukt=(function(){ + with(__obj){ + p1="w1"; + var getRight=function(){return false;}; + return p1; + } +})(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (p1!=="alert") { + $ERROR('#1: p1 === "alert". Actual: p1==='+p1); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (getRight()!=="napravo") { + $ERROR('#2: getRight() === "napravo". Actual: getRight()==='+getRight()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__obj.p1!=="w1") { + $ERROR('#3: __obj.p1 === "w1". Actual: __obj.p1 ==='+__obj.p1); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__obj.getRight()!==false) { + $ERROR('#4: __obj.getRight() === false. Actual: __obj.getRight()==='+__obj.getRight()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (resukt !== "w1") { + $ERROR('#5: resukt === "w1". Actual: resukt ==='+resukt); +} +// +////////////////////////////////////////////////////////////////////////////// + +var resukt; + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A18_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A18_T1.js new file mode 100644 index 000000000..327f816dd --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A18_T1.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using arguments object within a "with" Expression that is nested in a function is admitted + * + * @path ch13/13.2/S13.2.2_A18_T1.js + * @description Object is declared with "var __obj={callee:"a"}" + */ + +var callee=0, b; + +var __obj={callee:"a"}; + +result=(function(){ + with (arguments){ + callee=1; + b=true; + } + return arguments; +})(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (callee !== 0) { + $ERROR('#1: callee === 0. Actual: callee ==='+callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.callee !== "a") { + $ERROR('#2: __obj.callee === "a". Actual: __obj.callee==='+__obj.callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (result.callee !== 1) { + $ERROR('#3: result.callee === 1. Actual: result.callee ==='+result.callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (!(this.b)) { + $ERROR('#4: this.b === true. Actual: this.b ==='+this.b); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A18_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A18_T2.js new file mode 100644 index 000000000..d586ca5f9 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A18_T2.js @@ -0,0 +1,57 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Using arguments object within a "with" Expression that is nested in a function is admitted + * + * @path ch13/13.2/S13.2.2_A18_T2.js + * @description Object is declared with "__obj={callee:"a"}" + */ + +this.callee = 0; +var b; + +__obj={callee:"a"}; + +function f(){ + with (arguments){ + callee=1; + b=true; + return arguments; + } +}; + +result=f(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (callee !== 0) { + $ERROR('#1: callee === 0. Actual: callee ==='+callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.callee !== "a") { + $ERROR('#2: __obj.callee === "a". Actual: __obj.callee ==='+__obj.callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (result.callee !== 1) { + $ERROR('#3: result.callee === 1. Actual: result.callee ==='+result.callee); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (!(this.b)) { + $ERROR('#4: this.b === true. Actual: this.b ==='+this.b); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T1.js new file mode 100644 index 000000000..5fdcaee5a --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T1.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Function's scope chain is started when it is declared + * + * @path ch13/13.2/S13.2.2_A19_T1.js + * @description Function is declared in the global scope + */ + +var a = 1; + +var __func= function(){return a;}; + +var __obj = {a:2}; + +with (__obj) +{ + result = __func(); +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 1) { + $ERROR('#1: result === 1. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T2.js new file mode 100644 index 000000000..b36f457b8 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T2.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Function's scope chain is started when it is declared + * + * @path ch13/13.2/S13.2.2_A19_T2.js + * @description Function is declared in the object scope. Using "with" statement + */ + +var a = 1; + +var __obj = {a:2}; + +with (__obj) +{ + result = (function(){return a;})(); +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 2) { + $ERROR('#1: result === 2. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T3.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T3.js new file mode 100644 index 000000000..3f6e11266 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T3.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. + +/** + * Function's scope chain is started when it is declared + * + * @path ch13/13.2/S13.2.2_A19_T3.js + * @description Function is declared in the object scope and then an exception is thrown + */ + +var a = 1; + +var __obj = {a:2}; + +try { + with (__obj) + { + var __func = function (){return a;}; + throw 3; + } +} catch (e) { + ; +} + +result = __func(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 2) { + $ERROR('#1: result === 2. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + + + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T4.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T4.js new file mode 100644 index 000000000..65f6e765a --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T4.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. + +/** + * Function's scope chain is started when it is declared + * + * @path ch13/13.2/S13.2.2_A19_T4.js + * @description Function is declared in the hierarchical object scope and then an exception is thrown + */ + +var a = 1; + +var __obj = {a:2,__obj:{a:3}}; + +try { + with (__obj) + { + with(__obj){ + var __func = function(){return a;}; + throw 5; + } + } +} catch (e) { + ; +} + +result = __func(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 3) { + $ERROR('#1: result === 3. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + + + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T5.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T5.js new file mode 100644 index 000000000..f0614e175 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T5.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Function's scope chain is started when it is declared + * + * @path ch13/13.2/S13.2.2_A19_T5.js + * @description Function is declared in the object scope, then an exception is thrown and the object is deleted + */ + +var a = 1; + +var __obj = {a:2}; + +with (__obj) +{ + try { + + var __func = function() + { + return a; + } + throw 3; + } catch (e) { + ; + } +} + +delete __obj; + +result = __func(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 2) { + $ERROR('#1: result === 2. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T6.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T6.js new file mode 100644 index 000000000..b9fafb1f5 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T6.js @@ -0,0 +1,46 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Function's scope chain is started when it is declared + * + * @path ch13/13.2/S13.2.2_A19_T6.js + * @description Function is declared in the "object->do-while" scope, then the object is deleted and another object with the same name is declared + */ + +var a = 1; + +var __obj = {a:2}; + +with (__obj) +{ + do { + var __func = function() + { + return a; + } + } while(0); +} + +delete __obj; + +var __obj = {a:3}; + +with (__obj) +{ + result = __func(); +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (result !== 2) { + $ERROR('#1: result === 2. Actual: result ==='+result); +} +// +////////////////////////////////////////////////////////////////////////////// + + + + + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T7.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T7.js new file mode 100644 index 000000000..c83232d66 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T7.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Function's scope chain is started when it is declared + * + * @path ch13/13.2/S13.2.2_A19_T7.js + * @description Function is declared in the object scope as a variable + */ + +var a = 1; + +var __obj = {a:2}; + +with (__obj) +{ + var __func = function() + { + return a; + } +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.hasOwnProperty('__func')) { + $ERROR('#1: __obj.hasOwnProperty(\'__func\') === false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////// ///////////////////////////////////////// +//CHECK#2 +if (!(this.hasOwnProperty('__func'))) { + $ERROR('#2: this.hasOwnProperty(\'__func\') === true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__func in __obj) { + $ERROR('#3: (__func in __obj) === false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (this.__func === undefined) { + $ERROR('#4: this.__func !== undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T8.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T8.js new file mode 100644 index 000000000..7db4affd8 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A19_T8.js @@ -0,0 +1,74 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Function's scope chain is started when it is declared + * + * @path ch13/13.2/S13.2.2_A19_T8.js + * @description Function is declared multiply times + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (typeof __func !== "undefined") { + $ERROR('#0: typeof __func === "undefined". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +var a = 1, b = "a"; + +var __obj = {a:2}; + +with (__obj) +{ + while(1){ + var __func = function() + { + return a; + }; + break; + } +} + +delete __obj; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func() !== 2) { + $ERROR('#1: __func() === 2. Actual: __func() ==='+__func()); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = {a:3,b:"b"}; + +with (__obj) +{ + var __func = function() + { + return b; + } +} + +delete __obj; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func()!=="b") { + $ERROR('#2: __func()==="b". Actual: __func()==='+__func()); +} +// +////////////////////////////////////////////////////////////////////////////// + +with ({a:99,b:"c"}) +{ + ////////////////////////////////////////////////////////////////////////////// + //CHECK#3 + if (__func() !== "b") { + $ERROR('#3: __func()==="b". Actual: __func()==='+__func()); + } + // + ////////////////////////////////////////////////////////////////////////////// +} + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A1_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A1_T1.js new file mode 100644 index 000000000..cb9a2dbd6 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A1_T1.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Since a function is an object, it might be set to [[Prototype]] property of a new created object through [[Construct]] property + * + * @path ch13/13.2/S13.2.2_A1_T1.js + * @description Declaring a function with "function __func()" + */ + +var __MONSTER="monster"; +var __PREDATOR="predator"; + +function __PROTO(){}; + +try{ + __PROTO.type=__MONSTER; +} +catch(e){ + $ERROR('#0: __PROTO.type=__MONSTER does not lead to throwing exception') +} + +function __FACTORY(){this.name=__PREDATOR}; + +__FACTORY.prototype=__PROTO; + +var __monster = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(__PROTO.isPrototypeOf(__monster))) { + $ERROR('#1: __PROTO.isPrototypeOf(__monster) must be true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__monster.type !==__MONSTER) { + $ERROR('#2: __monster.type ===__MONSTER. Actual: __monster.type ==='+__monster.type); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A1_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A1_T2.js new file mode 100644 index 000000000..dd907d790 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A1_T2.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Since a function is an object, it might be set to [[Prototype]] property of a new created object through [[Construct]] property + * + * @path ch13/13.2/S13.2.2_A1_T2.js + * @description Declaring a function with "var __PROTO = function()" + */ + +var __MONSTER="monster"; +var __PREDATOR="predator"; + +var __PROTO = function(){}; + +try{ + __PROTO.type=__MONSTER; +} +catch(e){ + $FAIL('#0: __PROTO.type=__MONSTER does not lead to throwing exception') +} + +var __FACTORY = function(){this.name=__PREDATOR}; + +__FACTORY.prototype=__PROTO; + +var __monster = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(__PROTO.isPrototypeOf(__monster))) { + $ERROR('#1: __PROTO.isPrototypeOf(__monster) must be true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__monster.type !==__MONSTER) { + $ERROR('#2: __monster.type ===__MONSTER. Actual: __monster.type ==='+__monster.type); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A2.js new file mode 100644 index 000000000..3389a36d1 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A2.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Since a function is an object, it might be set to [[Prototype]] property of a new created object through [[Construct]] property, + * but [[call]] property must fail with TypeError error + * + * @path ch13/13.2/S13.2.2_A2.js + * @description Trying to [[call]] this function + */ + +var __PLANT="flower"; +var __ROSE="rose"; + +function __PROTO(){}; + +try{ + __PROTO.type=__PLANT; +} +catch(e){ + $ERROR('#0: __PROTO.type=__PLANT does not lead to throwing exception') +} + +function __FACTORY(){this.name=__ROSE}; + +__FACTORY.prototype=__PROTO; + +var __rose = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + __rose(); + $ERROR('#1: __rose() lead to throwing exception'); +} catch(e){ + if (!(e instanceof TypeError)) { + $ERROR('#2: Exception Type is TypeError. Actual: exception ==='+e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A3_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A3_T1.js new file mode 100644 index 000000000..a04721c81 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A3_T1.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * It gets the value of the [[Prototype]] property of the F(Denote it PROTO_VAL). + * If PROTO_VAL is not an object, sets the [[Prototype]] property of native ECMAScript object just created + * to the original Object prototype object as described in 15.2.3.1 + * + * @path ch13/13.2/S13.2.2_A3_T1.js + * @description Declaring a function with "function __FACTORY()" + */ + +function __FACTORY(){}; +__FACTORY.prototype=1; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __FACTORY.prototype !== 'number') { + $ERROR('#1: typeof __FACTORY.prototype === \'number\'. Actual: typeof __FACTORY.prototype ==='+(typeof __FACTORY.prototype)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __device = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!(Object.prototype.isPrototypeOf(__device))) { + $ERROR('#2: Object.prototype.isPrototypeOf(__device) === true'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A3_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A3_T2.js new file mode 100644 index 000000000..613adbb9c --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A3_T2.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * It gets the value of the [[Prototype]] property of the F(Denote it PROTO_VAL). + * If PROTO_VAL is not an object, sets the [[Prototype]] property of native ECMAScript object just created + * to the original Object prototype object as described in 15.2.3.1 + * + * @path ch13/13.2/S13.2.2_A3_T2.js + * @description Declaring a function with "var __FACTORY = function()" + */ + +var __FACTORY = function(){}; +__FACTORY.prototype=1; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __FACTORY.prototype !== 'number') { + $ERROR('#1: typeof __FACTORY.prototype === \'number\'. Actual: typeof __FACTORY.prototype ==='+(typeof __FACTORY.prototype)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __device = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!(Object.prototype.isPrototypeOf(__device))) { + $ERROR('#2: Object.prototype.isPrototypeOf(__device) === true'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A4_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A4_T1.js new file mode 100644 index 000000000..5804b6c29 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A4_T1.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * Gets the value of the [[Prototype]] property of the F(Denote it PROTO_VAL). + * If PROTO_VAL is an object, sets the [[Prototype]] property of native ECMAScript object just created + * to the PROTO_VAL + * + * @path ch13/13.2/S13.2.2_A4_T1.js + * @description Declaring a function with "function __FACTORY()" + */ + +var __CUBE="cube"; + +function __FACTORY(){ +}; +__FACTORY.prototype={ shape:__CUBE, printShape:function(){return this.shape;} }; + +var __device = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__device.printShape === undefined) { + $ERROR('#1: __device.printShape !== undefined. Actual: __device.printShape ==='+__device.printShape); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__device.printShape() !== __CUBE) { + $ERROR('#2: __device.printShape() === __CUBE. Actual: __device.printShape() ==='+__device.printShape()); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A4_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A4_T2.js new file mode 100644 index 000000000..3560e058b --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A4_T2.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * Gets the value of the [[Prototype]] property of the F(Denote it PROTO_VAL). + * If PROTO_VAL is an object, sets the [[Prototype]] property of native ECMAScript object just created + * to the PROTO_VAL + * + * @path ch13/13.2/S13.2.2_A4_T2.js + * @description Declaring a function with "__FACTORY = function()" + */ + +__CUBE="cube"; + +__FACTORY = function(){}; + +__FACTORY.prototype={ shape:__CUBE, printShape:function(){return this.shape;} }; + +__device = new __FACTORY(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__device.printShape === undefined) { + $ERROR('#1: __device.printShape !== undefined. Actual: __device.printShape ==='+__device.printShape); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__device.printShape() !== __CUBE) { + $ERROR('#2: __device.printShape() === __CUBE. Actual: __device.printShape() ==='+__device.printShape()); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A5_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A5_T1.js new file mode 100644 index 000000000..03c552318 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A5_T1.js @@ -0,0 +1,80 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * Invoke the [[Call]] property of F, providing native ECMAScript object just created as the this value and + * providing the argument list passed into [[Construct]] as the argument values + * + * @path ch13/13.2/S13.2.2_A5_T1.js + * @description Declaring a function with "function __FACTORY(arg1, arg2)" + */ + +__VOLUME=8; +__RED="red"; +__ID=12342; +__TOP=1.1; +__BOTTOM=0.0; +__LEFT=0.0; + + +function __FACTORY(arg1, arg2){ + this.volume=__VOLUME; + color=__RED; + this.id=arg1; + top=arg2; + this.bottom=arguments[3]; + left=arguments[4]; +}; + +__device = new __FACTORY(__ID, __TOP, __BOTTOM, __LEFT); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__device.color !== undefined) { + $ERROR('#1: __device.color === undefined. Actual: __device.color ==='+__device.color); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__device.volume !== __VOLUME) { + $ERROR('#2: __device.volume === __VOLUME. Actual: __device.volume ==='+__device.volume); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__device.top !== undefined) { + $ERROR('#3: __device.top === undefined. Actual: __device.top ==='+__device.top); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__device.id !== __ID) { + $ERROR('#4: __device.id === __ID. Actual: __device.id ==='+__device.id); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (__device.left !== undefined) { + $ERROR('#5: __device.left === undefined. Actual: __device.left ==='+__device.left); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__device.bottom !== __BOTTOM) { + $ERROR('#6: __device.bottom === __BOTTOM. Actual: __device.bottom ==='+__device.bottom); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A5_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A5_T2.js new file mode 100644 index 000000000..d3cd773ab --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A5_T2.js @@ -0,0 +1,80 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * Invoke the [[Call]] property of F, providing native ECMAScript object just created as the this value and + * providing the argument list passed into [[Construct]] as the argument values + * + * @path ch13/13.2/S13.2.2_A5_T2.js + * @description Declaring a function with "__FACTORY = function(arg1, arg2)" + */ + +__VOLUME=8; +__RED="red"; +__ID=12342; +__TOP=1.1; +__BOTTOM=0.0; +__LEFT=0.0; + + +__FACTORY = function(arg1, arg2){ + this.volume=__VOLUME; + color=__RED; + this.id=arg1; + top=arg2; + this.bottom=arguments[3]; + left=arguments[4]; +}; + +__device = new __FACTORY(__ID, __TOP, __BOTTOM, __LEFT); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__device.color !== undefined) { + $ERROR('#1: __device.color === undefined. Actual: __device.color ==='+__device.color); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__device.volume !== __VOLUME) { + $ERROR('#2: __device.volume === __VOLUME. Actual: __device.volume ==='+__device.volume); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__device.top !== undefined) { + $ERROR('#3: __device.top === undefined. Actual: __device.top ==='+__device.top); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__device.id !== __ID) { + $ERROR('#4: __device.id === __ID. Actual: __device.id ==='+__device.id); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (__device.left !== undefined) { + $ERROR('#5: __device.left === undefined. Actual: __device.left ==='+__device.left); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__device.bottom !== __BOTTOM) { + $ERROR('#6: __device.bottom === __BOTTOM. Actual: __device.bottom ==='+__device.bottom); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A6_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A6_T1.js new file mode 100644 index 000000000..82ef96dce --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A6_T1.js @@ -0,0 +1,41 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + * list passed into [[Construct]] as the argument values. + * If Type( [[Call]] returned) is not Object then return passed as this into [[Call]] object + * + * @path ch13/13.2/S13.2.2_A6_T1.js + * @description Declaring a function with "__func = function(arg)" + */ + +__FOO="fooValue"; +__BAR="barValue"; + +__func = function(arg){ + this.foo=arg; + return 0; + this.bar=arguments[1]; +}; + +__obj = new __func(__FOO, __BAR); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.foo!==__FOO) { + $ERROR('#1: __obj.foo === __FOO. Actual: __obj.foo==='+__obj.foo); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.bar!==undefined) { + $ERROR('#2: __obj.bar === undefined. Actual: __obj.bar==='+__obj.bar); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A6_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A6_T2.js new file mode 100644 index 000000000..f428bcb15 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A6_T2.js @@ -0,0 +1,41 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + * list passed into [[Construct]] as the argument values. + * If Type( [[Call]] returned) is not Object then return passed as this into [[Call]] object + * + * @path ch13/13.2/S13.2.2_A6_T2.js + * @description Declaring a function with "function __func (arg)" + */ + +var __FOO="fooValue"; +var __BAR="barValue"; + +function __func (arg){ + this.foo=arg; + return true; + this.bar=arguments[1]; +}; + +var __obj = new __func(__FOO, __BAR); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.foo!==__FOO) { + $ERROR('#1: __obj.foo === __FOO. Actual: __obj.foo==='+__obj.foo); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.bar!==undefined) { + $ERROR('#2: __obj.bar === undefined. Actual: __obj.bar==='+__obj.bar); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A7_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A7_T1.js new file mode 100644 index 000000000..02734e83e --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A7_T1.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + * list passed into [[Construct]] as the argument values. + * If Type( [[Call]] returned) is an Object then return this just as obtained object + * + * @path ch13/13.2/S13.2.2_A7_T1.js + * @description Declaring a function with "as __func = function(arg)" + */ + +var __FRST="one"; +var __SCND="two"; + +function __func (arg1, arg2){ + this.first=arg1; + var __obj={second:arg2}; + return __obj; + +}; + +var __obj__ = new __func(__FRST, __SCND); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj__.first !== undefined) { + $ERROR('#1: __obj__.first === undefined. Actual: __obj__.first==='+__obj__.first); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj__.second !== __SCND) { + $ERROR('#2: __obj__.second === __SCND. Actual: __obj__.second ==='+__obj__.second); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A7_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A7_T2.js new file mode 100644 index 000000000..9fbebf72c --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A7_T2.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + * list passed into [[Construct]] as the argument values. + * If Type( [[Call]] returned) is an Object then return this just as obtained object + * + * @path ch13/13.2/S13.2.2_A7_T2.js + * @description Declaring a "function as function __func (arg)" + */ + +__FRST="one"; +__SCND="two"; + +__func = function(arg1, arg2){ + this.first=arg1; + var __obj={second:arg2}; + return __obj; + +}; + +__obj__ = new __func(__FRST, __SCND); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj__.first !== undefined) { + $ERROR('#1: __obj__.first === undefined. Actual: __obj__.first==='+__obj__.first); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj__.second !== __SCND) { + $ERROR('#2: __obj__.second === __SCND. Actual: __obj__.second ==='+__obj__.second); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A8_T1.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A8_T1.js new file mode 100644 index 000000000..640c120f8 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A8_T1.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + * list passed into [[Construct]] as the argument values. + * If Type( [[Call]] returned) is an Function then return this just as obtained function + * + * @path ch13/13.2/S13.2.2_A8_T1.js + * @description Creating a function whose prototype contains "return" followed by declaration of another function + */ + +var __FRST="one"; +var __SCND="two"; + +var __func = function(arg1, arg2){ + this.first=arg1; + + __gunc.prop=arg2; + return __gunc; + // function declaration + function __gunc(arg){return ++arg}; + +}; + +var __instance = new __func(__FRST, __SCND); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.first !== undefined) { + $ERROR('#1: __instance.first === undefined. Actual: __instance.first ==='+__instance.first); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__instance.prop!==__SCND) { + $ERROR('#2: __instance.prop === __SCND. Actual: __instance.prop ==='+__instance.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__instance(1)!== 2) { + $ERROR('#2: __instance(1)=== 2. Actual: __instance(1) ==='+__instance(1)); +} +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A8_T2.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A8_T2.js new file mode 100644 index 000000000..e7f454b8d --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A8_T2.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. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + * list passed into [[Construct]] as the argument values. + * If Type( [[Call]] returned) is an Function then return this just as obtained function + * + * @path ch13/13.2/S13.2.2_A8_T2.js + * @description Creating a function whose prototype contains declaration of another function declared as a variable + */ + +var __FRST="one"; +var __SCND="two"; + +var __func = function(arg1, arg2){ + this.first=arg1; + var __gunc = function(arg){return arg+="BA"}; + __gunc.prop=arg2; + return __gunc; + +}; + +var __instance = new __func(__FRST, __SCND); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.first !== undefined) { + $ERROR('#1: __instance.first === undefined. Actual: __instance.first ==='+__instance.first); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__instance.prop!==__SCND) { + $ERROR('#2: __instance.prop === __SCND. Actual: __instance.prop ==='+__instance.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__instance("SAM")!== "SAMBA") { + $ERROR('#2: __instance("SAM") === "SAMBA". Actual: __instance("SAM") ==='+__instance("SAM")); +} +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A8_T3.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A8_T3.js new file mode 100644 index 000000000..e5e05f4bd --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A8_T3.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. + +/** + * When the [[Construct]] property for a Function object F is called: + * A new native ECMAScript object is created. + * Invoke the [[Call]] property of F, providing just created native ECMAScript object as the this value and providing the argument + * list passed into [[Construct]] as the argument values. + * If Type( [[Call]] returned) is an Function then return this just as obtained function + * + * @path ch13/13.2/S13.2.2_A8_T3.js + * @description Creating a function whose prototype contains declaration of another function defined by using Function.call method + */ + +var __FRST="one"; +var __SCND="two"; + +var __func = function(arg1, arg2){ + this.first=arg1; + var __gunc = Function.call(this,"arg","return ++arg;"); + __gunc.prop=arg2; + return __gunc; + +}; + +var __instance = new __func(__FRST, __SCND); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.first !== undefined) { + $ERROR('#1: __instance.first === undefined. Actual: __instance.first ==='+__instance.first); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__instance.prop!==__SCND) { + $ERROR('#2: __instance.prop === __SCND. Actual: __instance.prop ==='+__instance.prop); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__instance(1)!== 2) { + $ERROR('#2: __instance(1)=== 2. Actual: __instance(1) ==='+__instance(1)); +} +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.2_A9.js b/js/src/tests/test262/ch13/13.2/S13.2.2_A9.js new file mode 100644 index 000000000..4e178109c --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A9.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Calling a function as a constructor is inadmissible as long as this.any_Function is called before it is declared + * + * @path ch13/13.2/S13.2.2_A9.js + * @description Calling a function as a constructor + */ + +function FACTORY(){ + this.id = 0; + + this.id = this.func(); + + this.func = function (){ + return 5; + } + +} +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var obj = new FACTORY(); + $ERROR('#1: var obj = new FACTORY() lead to throwing exception');
+} catch (e) {
+ if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2.3_A1.js b/js/src/tests/test262/ch13/13.2/S13.2.3_A1.js new file mode 100644 index 000000000..3cee5115b --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2.3_A1.js @@ -0,0 +1,61 @@ +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @path ch13/13.2/S13.2.3_A1.js + * @description check that strict mode functions/arguments have + * [[ThrowTypeError]]-like behavior + * function object. + * @onlyStrict + */ + +"use strict"; +var poison = Object.getOwnPropertyDescriptor(Function.prototype, 'caller').get; + +if (typeof poison !== 'function') { + $ERROR("#1: A strict function's .caller should be poisoned with a function"); +} +var threw = null; +try { + poison.call(function() {}); +} catch (err) { + threw = err; +} +if (!threw || !(threw instanceof TypeError)) { + $ERROR("#2: Poisoned property should throw TypeError"); +} + +function checkNotPresent(obj, name) { + var desc = Object.getOwnPropertyDescriptor(obj, name); + if (desc !== undefined) { + $ERROR("#3: " + name + " should not appear as a descriptor"); + } +} + +var argumentsPoison = + Object.getOwnPropertyDescriptor(function() { return arguments; }(), + "callee").get; + +function checkPoison(obj, name) { + var desc = Object.getOwnPropertyDescriptor(obj, name); + if (desc.enumerable) { + $ERROR("#3: Poisoned " + name + " should not be enumerable"); + } + if (desc.configurable) { + $ERROR("#4: Poisoned " + name + " should not be configurable"); + } + if (argumentsPoison !== desc.get) { + $ERROR("#5: " + name + "'s getter not poisoned with same poison"); + } + if (argumentsPoison !== desc.set) { + $ERROR("#6: " + name + "'s setter not poisoned with same poison"); + } +} + +checkNotPresent(function() {}, 'caller'); +checkNotPresent(function() {}, 'arguments'); +checkPoison((function() { return arguments; })(), 'caller'); +checkPoison((function() { return arguments; })(), 'callee'); +checkNotPresent((function() {}).bind(null), 'caller'); +checkNotPresent((function() {}).bind(null), 'arguments'); + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A1_T1.js b/js/src/tests/test262/ch13/13.2/S13.2_A1_T1.js new file mode 100644 index 000000000..5f7d1b15a --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A1_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. + +/** + * A "prototype" property is automatically created for every function + * + * @path ch13/13.2/S13.2_A1_T1.js + * @description Using "function __func(){}" as a FunctionDeclaration + */ + +function __func(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func.prototype === undefined) { + $ERROR('#1: __func.prototype !== undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A1_T2.js b/js/src/tests/test262/ch13/13.2/S13.2_A1_T2.js new file mode 100644 index 000000000..b9d933a6d --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A1_T2.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. + +/** + * A "prototype" property is automatically created for every function + * + * @path ch13/13.2/S13.2_A1_T2.js + * @description Using "var __func = function(){}" as a FunctionDeclaration + */ + +var __func = function(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func.prototype === undefined) { + $ERROR('#1: __func.prototype !== undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A2_T1.js b/js/src/tests/test262/ch13/13.2/S13.2_A2_T1.js new file mode 100644 index 000000000..b49ba1973 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A2_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. + +/** + * Nested function are admitted + * + * @path ch13/13.2/S13.2_A2_T1.js + * @description Nesting level is two + */ + +var __JEDI="jedi"; + +function __FUNC(){ + function __GUNC(){ + return arguments[0]; + }; + + return __GUNC; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__FUNC()(__JEDI) !== __JEDI) { + $ERROR('#1: __FUNC()(__JEDI) === __JEDI. Actual: __FUNC()(__JEDI) ==='+__FUNC()(__JEDI)); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A2_T2.js b/js/src/tests/test262/ch13/13.2/S13.2_A2_T2.js new file mode 100644 index 000000000..024a624fa --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A2_T2.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Nested function are admitted + * + * @path ch13/13.2/S13.2_A2_T2.js + * @description Nesting level is three + */ + +var __ROBOT="C3PO"; + +function __FUNC(){ + function __GUNC(){ + return arguments[0]; + }; + function __HUNC(){ + return __GUNC; + }; + return __HUNC; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__FUNC()()(__ROBOT) !== __ROBOT) { + $ERROR('#1: __FUNC()()(__ROBOT) === __ROBOT. Actual: __FUNC()()(__ROBOT) ==='+__FUNC()()(__ROBOT)); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A3.js b/js/src/tests/test262/ch13/13.2/S13.2_A3.js new file mode 100644 index 000000000..3cd3c7032 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A3.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When Function object(F) is constructed the length property of F is set to the number of formal properties specified in FormalParameterList + * + * @path ch13/13.2/S13.2_A3.js + * @description Creating functions with various FormalParameterList and checking their lengths + */ + +function __func(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func.length !== 0) { + $ERROR('#1: __func.length === 0. Actual: __func.length ==='+__func.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __gunc(a,b,c){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__gunc.length !== 3) { + $ERROR('#2: __gunc.length === 3. Actual: __gunc.length ==='+__gunc.length); +} +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A4_T1.js b/js/src/tests/test262/ch13/13.2/S13.2_A4_T1.js new file mode 100644 index 000000000..ef47b61a0 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A4_T1.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. + +/** + * When Function object(F) is constructed the following steps from 9 to 11 take place + * 9.Create a new object as would be constructed by the expression new Object(). + * 10. Set the constructor property of Result(9) to F. This property is given attributes { DontEnum }. + * 11. Set the "prototype" property of F to Result(9). + * + * @path ch13/13.2/S13.2_A4_T1.js + * @description Checking prototype, prototype.constructor properties and {DontEnum} property of a constructor. + * Using "function __func(){}" as a FunctionDeclaration + */ + +function __func(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func.prototype !== 'object') { + $ERROR('#1: typeof __func.prototype === \'object\'. Actual: typeof __gunc.prototype ==='+typeof __gunc.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func.prototype.constructor !== __func) { + $ERROR('#2: __func.prototype.constructor === __func. Actual: __gunc.prototype.constructor ==='+__gunc.prototype.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __constructor_was__enumed; + +for (__prop in __func.prototype){ + if (__prop === 'constructor') + __constructor_was__enumed = true; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__constructor_was__enumed) { + $ERROR('#3: __constructor_was__enumed === false. Actual: __constructor_was__enumed ==='+__constructor_was__enumed); +} +// +////////////////////////////////////////////////////////////////////////////// + + + + + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A4_T2.js b/js/src/tests/test262/ch13/13.2/S13.2_A4_T2.js new file mode 100644 index 000000000..2da55b763 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A4_T2.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. + +/** + * When Function object(F) is constructed the following steps from 9 to 11 take place + * 9.Create a new object as would be constructed by the expression new Object(). + * 10. Set the constructor property of Result(9) to F. This property is given attributes { DontEnum }. + * 11. Set the "prototype" property of F to Result(9). + * + * @path ch13/13.2/S13.2_A4_T2.js + * @description Checking prototype, prototype.constructor properties and {DontEnum} property of a constructor. + * Using "var __gunc = function(){}" as a FunctionDeclaration + */ + +var __gunc = function(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __gunc.prototype !== 'object') { + $ERROR('#1: typeof __gunc.prototype === \'object\'. Actual: typeof __gunc.prototype ==='+typeof __gunc.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__gunc.prototype.constructor !== __gunc) { + $ERROR('#2: __gunc.prototype.constructor === __gunc. Actual: __gunc.prototype.constructor ==='+__gunc.prototype.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __constructor_was__enumed; + +for (__prop in __gunc.prototype){ + if (__prop === 'constructor') + __constructor_was__enumed = true; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__constructor_was__enumed) { + $ERROR('#3: __constructor_was__enumed === false. Actual: __constructor_was__enumed ==='+__constructor_was__enumed); +} +// +////////////////////////////////////////////////////////////////////////////// + + + + + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A5.js b/js/src/tests/test262/ch13/13.2/S13.2_A5.js new file mode 100644 index 000000000..6d88fad8e --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A5.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When Function object(F) is constructed + * the [[Prototype]] property of F is set to the original Function prototype object as specified in 15.3.3.1 + * + * @path ch13/13.2/S13.2_A5.js + * @description Function.prototype.isPrototypeOf() is used + */ + +function __func(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(Function.prototype.isPrototypeOf(__func))) { + $ERROR('#1: Function.prototype.isPrototypeOf(__func)'); +} +// +////////////////////////////////////////////////////////////////////////////// + + +var __gunc = function(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!(Function.prototype.isPrototypeOf(__gunc))) { + $ERROR('#1: Function.prototype.isPrototypeOf(__gunc)'); +} +// +////////////////////////////////////////////////////////////////////////////// + + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A6_T1.js b/js/src/tests/test262/ch13/13.2/S13.2_A6_T1.js new file mode 100644 index 000000000..2fca01cc2 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A6_T1.js @@ -0,0 +1,13 @@ +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @path ch13/13.2/S13.2_A6_T1.js + * @description check if "caller" poisoning poisons + * getOwnPropertyDescriptor too + * @onlyStrict + */ + +"use strict"; +Object.getOwnPropertyDescriptor(function(){}, 'caller'); + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A6_T2.js b/js/src/tests/test262/ch13/13.2/S13.2_A6_T2.js new file mode 100644 index 000000000..e8a334462 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A6_T2.js @@ -0,0 +1,13 @@ +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @path ch13/13.2/S13.2_A6_T2.js + * @description check if "arguments" poisoning poisons + * getOwnPropertyDescriptor too + * @onlyStrict + */ + +"use strict"; +Object.getOwnPropertyDescriptor(function(){}, 'arguments'); + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A7_T1.js b/js/src/tests/test262/ch13/13.2/S13.2_A7_T1.js new file mode 100644 index 000000000..d557bbd67 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A7_T1.js @@ -0,0 +1,14 @@ +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @path ch13/13.2/S13.2_A7_T1.js + * @description check if "caller" poisoning poisons + * hasOwnProperty too + * @onlyStrict + */ + +"use strict"; +(function(){}).hasOwnProperty('caller'); + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A7_T2.js b/js/src/tests/test262/ch13/13.2/S13.2_A7_T2.js new file mode 100644 index 000000000..82c03938f --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A7_T2.js @@ -0,0 +1,14 @@ +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @path ch13/13.2/S13.2_A7_T2.js + * @description check if "arguments" poisoning poisons + * hasOwnProperty too + * @onlyStrict + */ + +"use strict"; +(function(){}).hasOwnProperty('arguments'); + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A8_T1.js b/js/src/tests/test262/ch13/13.2/S13.2_A8_T1.js new file mode 100644 index 000000000..a68553e82 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A8_T1.js @@ -0,0 +1,14 @@ +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @path ch13/13.2/S13.2_A8_T1.js + * @description check if "caller" poisoning poisons + * "in" too + * @onlyStrict + */ + +"use strict"; +'caller' in function() {}; + + diff --git a/js/src/tests/test262/ch13/13.2/S13.2_A8_T2.js b/js/src/tests/test262/ch13/13.2/S13.2_A8_T2.js new file mode 100644 index 000000000..0d9eec7c5 --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/S13.2_A8_T2.js @@ -0,0 +1,14 @@ +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @path ch13/13.2/S13.2_A8_T2.js + * @description check if "arguments" poisoning poisons + * "in" too + * @onlyStrict + */ + +"use strict"; +'arguments' in function() {}; + + diff --git a/js/src/tests/test262/ch13/13.2/browser.js b/js/src/tests/test262/ch13/13.2/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/browser.js diff --git a/js/src/tests/test262/ch13/13.2/shell.js b/js/src/tests/test262/ch13/13.2/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch13/13.2/shell.js |