diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Function/prototype/call')
51 files changed, 1095 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/15.3.4.4-1-s-strict.js b/js/src/tests/test262/built-ins/Function/prototype/call/15.3.4.4-1-s-strict.js new file mode 100644 index 0000000000..be653a8801 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/15.3.4.4-1-s-strict.js @@ -0,0 +1,20 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.3.4.4-1-s +description: > + Strict Mode - 'this' value is a string which cannot be converted + to wrapper objects when the function is called without an array of + arguments +flags: [onlyStrict] +---*/ + +function fun() { + return (this instanceof String); +} + +assert.sameValue(fun.call(""), false, 'fun.call("")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/15.3.4.4-2-s-strict.js b/js/src/tests/test262/built-ins/Function/prototype/call/15.3.4.4-2-s-strict.js new file mode 100644 index 0000000000..eaba805575 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/15.3.4.4-2-s-strict.js @@ -0,0 +1,20 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.3.4.4-2-s +description: > + Strict Mode - 'this' value is a number which cannot be converted + to wrapper objects when the function is called without an array + argument +flags: [onlyStrict] +---*/ + +function fun() { + return (this instanceof Number); +} + +assert.sameValue(fun.call(-12), false, 'fun.call(-12)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/15.3.4.4-3-s-strict.js b/js/src/tests/test262/built-ins/Function/prototype/call/15.3.4.4-3-s-strict.js new file mode 100644 index 0000000000..c14c7644ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/15.3.4.4-3-s-strict.js @@ -0,0 +1,20 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.3.4.4-3-s +description: > + Strict Mode - 'this' value is a boolean which cannot be converted + to wrapper objects when the function is called without an array of + arguments +flags: [onlyStrict] +---*/ + +function fun() { + return (this instanceof Boolean); +} + +assert.sameValue(fun.call(false), false, 'fun.call(false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A10.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A10.js new file mode 100644 index 0000000000..fbe9afc864 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A10.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Function.prototype.call.length property has the attribute ReadOnly +es5id: 15.3.4.4_A10 +description: > + Checking if varying the Function.prototype.call.length property + fails +includes: [propertyHelper.js] +---*/ +assert( + Function.prototype.call.hasOwnProperty('length'), + 'Function.prototype.call.hasOwnProperty(\'length\') must return true' +); + +var obj = Function.prototype.call.length; + +verifyNotWritable(Function.prototype.call, "length", null, function() { + return "shifted"; +}); + +assert.sameValue( + Function.prototype.call.length, + obj, + 'The value of Function.prototype.call.length is expected to equal the value of obj' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A11.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A11.js new file mode 100644 index 0000000000..9263fb6113 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A11.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. + +/*--- +info: The Function.prototype.call.length property has the attribute DontEnum +es5id: 15.3.4.4_A11 +description: > + Checking if enumerating the Function.prototype.call.length + property fails +---*/ +assert( + Function.prototype.call.hasOwnProperty('length'), + 'Function.prototype.call.hasOwnProperty(\'length\') must return true' +); + +assert( + !Function.prototype.call.propertyIsEnumerable('length'), + 'The value of !Function.prototype.call.propertyIsEnumerable(\'length\') is expected to be true' +); + +// CHECK#2 +for (var p in Function.prototype.call) { + assert.notSameValue(p, "length", 'The value of p is not "length"'); +} + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A12.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A12.js new file mode 100644 index 0000000000..1ad9112456 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A12.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Function.prototype.call has not prototype property +es5id: 15.3.4.4_A12 +description: > + Checking if obtaining the prototype property of + Function.prototype.call fails +---*/ +assert.sameValue( + Function.prototype.call.prototype, + undefined, + 'The value of Function.prototype.call.prototype is expected to equal undefined' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A13.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A13.js new file mode 100644 index 0000000000..4e02807274 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A13.js @@ -0,0 +1,13 @@ +// Copyright 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.3.4.4_A13 +description: If IsCallable(func) is false, then throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.call.call(undefined, {}); +}, 'Function.prototype.call.call(undefined, {}) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A14.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A14.js new file mode 100644 index 0000000000..4d0b259054 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A14.js @@ -0,0 +1,13 @@ +// Copyright 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.3.4.4_A14 +description: If IsCallable(func) is false, then throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.call.call(null, {}); +}, 'Function.prototype.call.call(null, {}) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A15.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A15.js new file mode 100644 index 0000000000..412b447fc4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A15.js @@ -0,0 +1,13 @@ +// Copyright 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.3.4.4_A15 +description: If IsCallable(func) is false, then throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.call.call({}, {}); +}, 'Function.prototype.call.call({}, {}) throws a TypeError exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A16.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A16.js new file mode 100644 index 0000000000..604e931eff --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A16.js @@ -0,0 +1,26 @@ +// Copyright 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If IsCallable(func) is false, then throw a TypeError exception. +es5id: 15.3.4.4_A16 +description: > + A RegExp is not a function, but it may be callable. Iff it is, + it's typeof should be 'function', in which case call should accept + it as a valid this value. +---*/ + +var re = (/x/); +if (typeof re === 'function') { + Function.prototype.call.call(re, undefined, 'x'); +} else { + try { + Function.prototype.bind.call(re, undefined); + throw new Test262Error('#1: If IsCallable(func) is false, ' + + 'then (bind should) throw a TypeError exception'); + } catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A1_T1.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A1_T1.js new file mode 100644 index 0000000000..2181d122e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A1_T1.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The call method performs a function call using the [[Call]] property of + the object. If the object does not have a [[Call]] property, a TypeError + exception is thrown +es5id: 15.3.4.4_A1_T1 +description: > + Call "call" method of the object that does not have a [[Call]] + property. Prototype of the object is Function() +---*/ + +var proto = Function(); + +function FACTORY() {} + +FACTORY.prototype = proto; + +var obj = new FACTORY; + +assert.sameValue(typeof obj.call, "function", 'The value of `typeof obj.call` is expected to be "function"'); + +try { + obj.call(); + throw new Test262Error('#2: If the object does not have a [[Call]] property, a TypeError exception is thrown'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A1_T2.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A1_T2.js new file mode 100644 index 0000000000..b0fe479c16 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A1_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. + +/*--- +info: | + The call method performs a function call using the [[Call]] property of + the object. If the object does not have a [[Call]] property, a TypeError + exception is thrown +es5id: 15.3.4.4_A1_T2 +description: > + Calling "call" method of the object that does not have a [[Call]] + property. Prototype of the object is Function.prototype +---*/ + +function FACTORY() {} + +FACTORY.prototype = Function.prototype; + +var obj = new FACTORY; + +assert.sameValue(typeof obj.call, "function", 'The value of `typeof obj.call` is expected to be "function"'); + +try { + obj.call(); + throw new Test262Error('#2: If the object does not have a [[Call]] property, a TypeError exception is thrown'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A2_T1.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A2_T1.js new file mode 100644 index 0000000000..ad09161477 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A2_T1.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of the call method is 1 +es5id: 15.3.4.4_A2_T1 +description: Checking Function.prototype.call.length +---*/ +assert.sameValue( + typeof Function.prototype.call, + "function", + 'The value of `typeof Function.prototype.call` is expected to be "function"' +); + +assert.notSameValue( + typeof Function.prototype.call.length, + "undefined", + 'The value of typeof Function.prototype.call.length is not "undefined"' +); + +assert.sameValue(Function.prototype.call.length, 1, 'The value of Function.prototype.call.length is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A2_T2.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A2_T2.js new file mode 100644 index 0000000000..d0845a1a85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A2_T2.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of the call method is 1 +es5id: 15.3.4.4_A2_T2 +description: Checking f.call.length, where f is new Function +---*/ + +var f = new Function; + +assert.sameValue(typeof f.call, "function", 'The value of `typeof f.call` is expected to be "function"'); +assert.notSameValue(typeof f.call.length, "undefined", 'The value of typeof f.call.length is not "undefined"'); +assert.sameValue(f.call.length, 1, 'The value of f.call.length is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T1.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T1.js new file mode 100644 index 0000000000..58dd4fa91b --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T1.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T1 +description: Not any arguments at call function +---*/ + +Function("this.field=\"strawberry\"").call(); + +assert.sameValue(this["field"], "strawberry", 'The value of this["field"] is expected to be "strawberry"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T10.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T10.js new file mode 100644 index 0000000000..5ba2630d12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T10.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T10 +description: Checking by using eval, no any arguments at call function +flags: [noStrict] +---*/ + +eval(" (function(){this.feat=1}).call()"); + +assert.sameValue(this["feat"], 1, 'The value of this["feat"] is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T2.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T2.js new file mode 100644 index 0000000000..b2012d589d --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T2.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T2 +description: Argument at call function is null +---*/ + +Function("this.field=\"green\"").call(null); + +assert.sameValue(this["field"], "green", 'The value of this["field"] is expected to be "green"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T3.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T3.js new file mode 100644 index 0000000000..770dbb6183 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T3.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T3 +description: Argument at call function is void 0 +---*/ + +Function("this.field=\"battle\"").call(void 0); + +assert.sameValue(this["field"], "battle", 'The value of this["field"] is expected to be "battle"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T4.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T4.js new file mode 100644 index 0000000000..a7c48ffbef --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T4.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T4 +description: Argument at call function is undefined +---*/ + +Function("this.field=\"oil\"").call(undefined); + +assert.sameValue(this["field"], "oil", 'The value of this["field"] is expected to be "oil"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T5.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T5.js new file mode 100644 index 0000000000..7e107200d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T5 +description: > + No any arguments at call function and it called inside function + declaration +---*/ + +function FACTORY() { + Function("this.feat=\"in da haus\"").call(); +} + +var obj = new FACTORY; + +assert.sameValue(this["feat"], "in da haus", 'The value of this["feat"] is expected to be "in da haus"'); +assert.sameValue(typeof obj.feat, "undefined", 'The value of `typeof obj.feat` is expected to be "undefined"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T6.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T6.js new file mode 100644 index 0000000000..1b91976f6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T6.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T6 +description: > + Argument at call function is null and it called inside function + declaration +flags: [noStrict] +---*/ + +function FACTORY() { + (function() { + this.feat = "kamon beyba" + }).call(null); +} + +var obj = new FACTORY; + +assert.sameValue(this["feat"], "kamon beyba", 'The value of this["feat"] is expected to be "kamon beyba"'); +assert.sameValue(typeof obj.feat, "undefined", 'The value of `typeof obj.feat` is expected to be "undefined"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T7.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T7.js new file mode 100644 index 0000000000..4bbb732e06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T7.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T7 +description: > + Argument at call function is void 0 and it called inside function + declaration +---*/ + +(function FACTORY() { + Function("this.feat=\"in da haus\"").call(void 0); +})(); + + +assert.sameValue(this["feat"], "in da haus", 'The value of this["feat"] is expected to be "in da haus"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T8.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T8.js new file mode 100644 index 0000000000..7bf141e483 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T8.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T8 +description: > + Argument at call function is undefined and it called inside + function declaration +flags: [noStrict] +---*/ + +(function FACTORY() { + (function() { + this.feat = "kamon beyba" + }).call(undefined); +})(); + + +assert.sameValue(this["feat"], "kamon beyba", 'The value of this["feat"] is expected to be "kamon beyba"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T9.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T9.js new file mode 100644 index 0000000000..47962ebc30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A3_T9.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T9 +description: Checking by using eval, argument at call function is void 0 +---*/ + +eval(" Function(\"this.feat=1\").call(void 0) "); + + +assert.sameValue(this["feat"], 1, 'The value of this["feat"] is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T1.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T1.js new file mode 100644 index 0000000000..4255230d83 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T1 +description: thisArg is number +---*/ + +var obj = 1; + +var retobj = Function("this.touched= true; return this;").call(obj); + +assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T2.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T2.js new file mode 100644 index 0000000000..7194b044be --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T2 +description: thisArg is boolean true +---*/ + +var obj = true; + +var retobj = new Function("this.touched= true; return this;").call(obj); + +assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T3.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T3.js new file mode 100644 index 0000000000..8b5c52d4d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T3 +description: thisArg is string +flags: [noStrict] +---*/ + +var obj = "soap"; + +var retobj = (function() { + this.touched = true; + return this; +}).call(obj); + +assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T4.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T4.js new file mode 100644 index 0000000000..f2e10b1020 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T4.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T4 +description: thisArg is function variable that return this +flags: [noStrict] +---*/ + +var f = function() { + this.touched = true; + return this; +}; + +var retobj = f.call(obj); + +assert.sameValue(typeof obj, "undefined", 'The value of `typeof obj` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); + +var obj; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T5.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T5.js new file mode 100644 index 0000000000..e1e34c9ade --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T5.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T5 +description: thisArg is function variable +---*/ + +var f = function() { + this.touched = true; +}; + +var obj = {}; + +f.call(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T6.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T6.js new file mode 100644 index 0000000000..1a1d96d6cf --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T6.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. + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T6 +description: thisArg is new String() +---*/ + +var obj = new String("soap"); + +(function() { + this.touched = true; +}).call(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T7.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T7.js new file mode 100644 index 0000000000..0497ca630d --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T7.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T7 +description: thisArg is new Number() +---*/ + +var obj = new Number(1); + +Function("this.touched= true;").call(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T8.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T8.js new file mode 100644 index 0000000000..bd7a7d454b --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A5_T8.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T8 +description: thisArg is Function() +---*/ + +var obj = Function(); + +new Function("this.touched= true; return this;").call(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T1.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T1.js new file mode 100644 index 0000000000..095ca34cd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T1.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T1 +description: Argunemts of call function is (null,[1]) +---*/ + +Function("a1,a2,a3", "this.shifted=a1;").call(null, [1]); + +assert.sameValue( + this["shifted"].constructor, + Array, + 'The value of this["shifted"].constructor is expected to equal the value of Array' +); + +assert.sameValue(this["shifted"].length, 1, 'The value of this["shifted"].length is expected to be 1'); +assert.sameValue(this["shifted"][0], 1, 'The value of this["shifted"][0] is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T10.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T10.js new file mode 100644 index 0000000000..dbdc95ea2a --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T10.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. + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T10 +description: > + Argunemts of call function is (empty object, "", arguments,2), + inside function call without declaration used +---*/ + +var obj = {}; + +(function() { + Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(obj, arguments, "", "2"); +})("", 4, 2, "a"); + +assert.sameValue(obj["shifted"], "42", 'The value of obj["shifted"] is expected to be "42"'); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T2.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T2.js new file mode 100644 index 0000000000..55ca9efc3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_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. + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T2 +description: Argunemts of call function is (null,[3,2,1]) +---*/ + +new Function("a1,a2", "a3", "this.shifted=a1;").call(null, [3, 2, 1]); + +assert.sameValue(this["shifted"].length, 3); + +if ((this["shifted"][0] !== 3) || (this["shifted"][1] !== 2) || (this["shifted"][2] !== 1)) { + throw new Test262Error('#2: The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs a function call using the [[Call]] property of the object'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T3.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T3.js new file mode 100644 index 0000000000..b64be6bfb1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T3.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. + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T3 +description: > + Argunemts of call function is (empty object, new + Array("nine","inch","nails")) +---*/ + +var i = 0; + +var p = { + toString: function() { + return "a" + (++i); + } +}; + +var obj = {}; + +Function(p, "a2,a3", "this.shifted=a1;").call(obj, new Array("nine", "inch", "nails")); + +assert.sameValue(obj["shifted"].length, 3); + +if ((obj["shifted"][0] !== "nine") || (obj["shifted"][1] !== "inch") || (obj["shifted"][2] !== "nails")) { + throw new Test262Error('#2: The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs a function call using the [[Call]] property of the object'); +} + +if (typeof this["shifted"] !== "undefined") { + throw new Test262Error('#3: The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs a function call using the [[Call]] property of the object'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T4.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T4.js new file mode 100644 index 0000000000..9050ef44f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T4.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. + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T4 +description: > + Argunemts of call function is (empty object, ( function(){return + arguments;})("a","b","c","d"),"",2) +---*/ + +var i = 0; + +var p = { + toString: function() { + return "a" + (++i); + } +}; + +var obj = {}; + +new Function(p, p, p, "this.shifted=a3+a2+a1.length;").call(obj, (function() { + return arguments; +})("a", "b", "c", "d"), "", 2); + +assert.sameValue(obj["shifted"], "24", 'The value of obj["shifted"] is expected to be "24"'); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T5.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T5.js new file mode 100644 index 0000000000..232a96d70b --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T5 +description: > + Argunemts of call function is (null, arguments,"",2), inside + function declaration used +---*/ + +function FACTORY() { + Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); +} + +var obj = new FACTORY("", 1, 2, "A"); + +assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); +assert.sameValue(typeof obj.shifted, "undefined", 'The value of `typeof obj.shifted` is expected to be "undefined"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T6.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T6.js new file mode 100644 index 0000000000..f69635c168 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T6.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. + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T6 +description: > + Argunemts of call function is (this, arguments,"",2), inside + function declaration used +---*/ + +function FACTORY() { + Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); +} + +var obj = new FACTORY("", 4, 2, "A"); + +assert.sameValue(obj["shifted"], "42", 'The value of obj["shifted"] is expected to be "42"'); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T7.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T7.js new file mode 100644 index 0000000000..ad606b3093 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T7.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. + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T7 +description: > + Argunemts of call function is (null, arguments,"",2), inside + function call without declaration used +---*/ + +(function() { + Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); +})("", 1, 2, true); + +assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T8.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T8.js new file mode 100644 index 0000000000..7bf2c014a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T8.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. + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T8 +description: > + Argunemts of call function is (this, arguments,"",2), inside + function call without declaration used +---*/ + +(function() { + Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); +})("", 4, 2, null); + +assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T9.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T9.js new file mode 100644 index 0000000000..cca95016d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A6_T9.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. + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T9 +description: > + Argunemts of call function is (empty object, "", arguments,2), + inside function declaration used +---*/ + +function FACTORY() { + var obj = {}; + Function("a1,a2,a3", "this.shifted=a1+a2.length+a3;").call(obj, "", arguments, 2); + return obj; +} + +var obj = new FACTORY("", 1, 2, void 0); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); + +assert.sameValue(obj.shifted, "42", 'The value of obj.shifted is expected to be "42"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T3.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T3.js new file mode 100644 index 0000000000..c567e3cd99 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T3.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Function.prototype.call can't be used as [[Construct]] caller +es5id: 15.3.4.4_A7_T3 +description: Checking if creating "new Function.call" fails +---*/ + +try { + var obj = new Function.call; + throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T4.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T4.js new file mode 100644 index 0000000000..0134e8f315 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T4.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Function.prototype.call can't be used as [[Construct]] caller +es5id: 15.3.4.4_A7_T4 +description: Checking if creating "new (Function("this.p1=1").call)" fails +---*/ + +try { + var obj = new(Function("this.p1=1").call); + throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T5.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T5.js new file mode 100644 index 0000000000..2c911dda0b --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T5.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Function.prototype.call can't be used as [[Construct]] caller +es5id: 15.3.4.4_A7_T5 +description: Checking if creating "new Function("this.p1=1").call" fails +---*/ + +try { + var FACTORY = Function("this.p1=1").call; + var obj = new FACTORY(); + throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T6.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T6.js new file mode 100644 index 0000000000..5e0c6494de --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A7_T6.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. + +/*--- +info: Function.prototype.call can't be used as [[Construct]] caller +es5id: 15.3.4.4_A7_T6 +description: > + Checking if creating "new (Function("function + f(){this.p1=1;};return f").call())" fails +---*/ + +try { + var obj = new(Function("function f(){this.p1=1;};return f").call()); +} catch (e) { + throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); +} + +assert.sameValue(obj.p1, 1, 'The value of obj.p1 is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A9.js b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A9.js new file mode 100644 index 0000000000..043f28af3c --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/S15.3.4.4_A9.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. + +/*--- +info: | + The Function.prototype.call.length property does not have the attribute + DontDelete +es5id: 15.3.4.4_A9 +description: > + Checking if deleting the Function.prototype.call.length property + fails +---*/ +assert( + Function.prototype.call.hasOwnProperty('length'), + 'Function.prototype.call.hasOwnProperty(\'length\') must return true' +); + +assert( + delete Function.prototype.call.length, + 'The value of delete Function.prototype.call.length is expected to be true' +); + +assert( + !Function.prototype.call.hasOwnProperty('length'), + 'The value of !Function.prototype.call.hasOwnProperty(\'length\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/browser.js b/js/src/tests/test262/built-ins/Function/prototype/call/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/browser.js diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/name.js b/js/src/tests/test262/built-ins/Function/prototype/call/name.js new file mode 100644 index 0000000000..d919573ff9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.2.3.3 +description: > + Function.prototype.call.name is "call". +info: | + Function.prototype.call (thisArg , ...args) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Function.prototype.call.name, "call"); + +verifyNotEnumerable(Function.prototype.call, "name"); +verifyNotWritable(Function.prototype.call, "name"); +verifyConfigurable(Function.prototype.call, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/not-a-constructor.js b/js/src/tests/test262/built-ins/Function/prototype/call/not-a-constructor.js new file mode 100644 index 0000000000..1ae179235e --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/not-a-constructor.js @@ -0,0 +1,43 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Function.prototype.call does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Function.prototype.call), + false, + 'isConstructor(Function.prototype.call) must return false' +); + +assert.throws(TypeError, () => { + new Function.prototype.call(); +}, '`new Function.prototype.call()` throws TypeError'); + +assert.throws(TypeError, () => { + new Function.prototype.call; +}, '`new Function.prototype.call` throws TypeError'); + +var call = Function.prototype.call; +assert.throws(TypeError, () => { + new call; +}, '`new call()` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/shell.js b/js/src/tests/test262/built-ins/Function/prototype/call/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/call/shell.js |