diff options
Diffstat (limited to 'external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition')
111 files changed, 4067 insertions, 0 deletions
diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A1_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A1_T1.js new file mode 100644 index 000000000..3ea38a422 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A1_T1.js @@ -0,0 +1,73 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.1_A1_T1; +* @section: 13.2.1; +* @assertion: The depth of nested function calls reaches 32; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T1.js new file mode 100644 index 000000000..36f464543 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T1.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. + +/** +* @name: S13.2.1_A4_T1; +* @section: 13.2.1; +* @assertion: Objects as arguments are passed by reference; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T2.js new file mode 100644 index 000000000..c7f68eba3 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T2.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. + +/** +* @name: S13.2.1_A4_T2; +* @section: 13.2.1; +* @assertion: Objects as arguments are passed by reference; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T3.js new file mode 100644 index 000000000..c12c86b26 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T3.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. + +/** +* @name: S13.2.1_A4_T3; +* @section: 13.2.1; +* @assertion: Objects as arguments are passed by reference; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T4.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T4.js new file mode 100644 index 000000000..e313f516a --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A4_T4.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. + +/** +* @name: S13.2.1_A4_T4; +* @section: 13.2.1; +* @assertion: Objects as arguments are passed by reference; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A5_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A5_T1.js new file mode 100644 index 000000000..7b36af3a9 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A5_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. + +/** +* @name: S13.2.1_A5_T1; +* @section: 13.2.1; +* @assertion: Closures are admitted; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A5_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A5_T2.js new file mode 100644 index 000000000..85965e28a --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A5_T2.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. + +/** +* @name: S13.2.1_A5_T2; +* @section: 13.2.1; +* @assertion: Closures are admitted; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A6_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A6_T1.js new file mode 100644 index 000000000..2bb3a254a --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A6_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. + +/** +* @name: S13.2.1_A6_T1; +* @section: 13.2.1; +* @assertion: Primitive types are passed by value; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A6_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A6_T2.js new file mode 100644 index 000000000..1a127f84e --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A6_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. + +/** +* @name: S13.2.1_A6_T2; +* @section: 13.2.1; +* @assertion: Primitive types are passed by value; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_T1.js new file mode 100644 index 000000000..123715abc --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_T1.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. + +/** +* @name: S13.2.1_A7_T1; +* @section: 13.2.1; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_T2.js new file mode 100644 index 000000000..19b79bb02 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_T2.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. + +/** +* @name: S13.2.1_A7_T2; +* @section: 13.2.1; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_T3.js new file mode 100644 index 000000000..f39174e3a --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_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. + +/** +* @name: S13.2.1_A7_T3; +* @section: 13.2.1; +* @assertion: 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; +* @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) {} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_T4.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_T4.js new file mode 100644 index 000000000..f3d8cb30f --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A7_T4.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.1_A7_T4; +* @section: 13.2.1; +* @assertion: 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; +* @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) {} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//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) {} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A8_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A8_T1.js new file mode 100644 index 000000000..b54b56e84 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A8_T1.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. + +/** +* @name: S13.2.1_A8_T1; +* @section: 13.2.1; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A8_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A8_T2.js new file mode 100644 index 000000000..ce562f24a --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A8_T2.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. + +/** +* @name: S13.2.1_A8_T2; +* @section: 13.2.1; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9.1_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9.1_T1.js new file mode 100644 index 000000000..0411a09ce --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9.1_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. + +/** +* @name: S13.2.1_A9.1_T1; +* @section: 13.2.1; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9.1_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9.1_T2.js new file mode 100644 index 000000000..678361b98 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9.1_T2.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. + +/** +* @name: S13.2.1_A9.1_T2; +* @section: 13.2.1; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9_T1.js new file mode 100644 index 000000000..61d48275f --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9_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. + +/** +* @name: S13.2.1_A9_T1; +* @section: 13.2.1; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9_T2.js new file mode 100644 index 000000000..a8b719771 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.1_A9_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. + +/** +* @name: S13.2.1_A9_T2; +* @section: 13.2.1; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A10.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A10.js new file mode 100644 index 000000000..dbe9c401b --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A10.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. + +/** +* @name: S13.2.2_A10; +* @section: 13.2.2; +* @assertion: Calling a function as a constructor is possible as long as this.any_Function is declared; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A11.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A11.js new file mode 100644 index 000000000..3ff216c97 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A11.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. + +/** +* @name: S13.2.2_A11; +* @section: 13.2.2; +* @assertion: Calling a function as a constructor is possible as long as this.any_Function is declared and called; +* @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) {} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A12.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A12.js new file mode 100644 index 000000000..7718f4f8f --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A12.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. + +/** +* @name: S13.2.2_A12; +* @section: 13.2.2; +* @assertion: Calling a function as a constructor is possible as long as this.any_Function is declared and called; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A13.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A13.js new file mode 100644 index 000000000..ec2a1b4b3 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A13.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. + +/** +* @name: S13.2.2_A13; +* @section: 13.2.2; +* @assertion: Calling a function as a constructor is inadmissible as long as this.any_Function is declared by eval and called; +* @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) {} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A14.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A14.js new file mode 100644 index 000000000..69e150a60 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A14.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. + +/** +* @name: S13.2.2_A14; +* @section: 13.2.2; +* @assertion: Calling a function as a constructor is inadmissible as long as this.any_Function is declared by eval and called; +* @description: Calling a function as a constructor after it has been declared by eval; +*/ + +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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_T1.js new file mode 100644 index 000000000..c03427e91 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_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. + +/** +* @name: S13.2.2_A15_T1; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_T2.js new file mode 100644 index 000000000..fb7c1e792 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_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. + +/** +* @name: S13.2.2_A15_T2; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_T3.js new file mode 100644 index 000000000..c217e089b --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_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. + +/** +* @name: S13.2.2_A15_T3; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_T4.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_T4.js new file mode 100644 index 000000000..d300d093c --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A15_T4.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A15_T4; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A16_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A16_T1.js new file mode 100644 index 000000000..eae337fac --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A16_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. + +/** +* @name: S13.2.2_A16_T1; +* @section: 13.2.2; +* @assertion: FunctionExpression within a new statement is admitted; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A16_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A16_T2.js new file mode 100644 index 000000000..bcd08f83b --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A16_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. + +/** +* @name: S13.2.2_A16_T2; +* @section: 13.2.2; +* @assertion: FunctionExpression within a new statement is admitted; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A16_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A16_T3.js new file mode 100644 index 000000000..16fe05d0e --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A16_T3.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A16_T3; +* @section: 13.2.2; +* @assertion: FunctionExpression within a new statement is admitted; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A17_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A17_T1.js new file mode 100644 index 000000000..88ecf891f --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A17_T1.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. + +/** +* @name: S13.2.2_A17_T1; +* @section: 13.2.2; +* @assertion: FunctionExpression containing "with" statement is admitted; +* @description: Using "with" statement within a function body; +*/ + +var p1="alert"; + +var __obj={p1:1,getRight:function(){return "right";}}; + +this.getRight=function(){return "napravo";}; + +(function(){ + with(__obj){ + p1="w1"; + function getRight(){return false;} + } +})(); + +////////////////////////////////////////////////////////////////////////////// +//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()!=="right") { + $ERROR('#4: __obj.getRight() === "right". Actual: __obj.getRight() ==='+__obj.getRight()); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A17_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A17_T2.js new file mode 100644 index 000000000..d0e14cb4b --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A17_T2.js @@ -0,0 +1,71 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A17_T2; +* @section: 13.2.2; +* @assertion: FunctionExpression containing "with" statement is admitted; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A17_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A17_T3.js new file mode 100644 index 000000000..47409b15e --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A17_T3.js @@ -0,0 +1,67 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A17_T3; +* @section: 13.2.2; +* @assertion: FunctionExpression containing "with" statement is admitted; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A18_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A18_T1.js new file mode 100644 index 000000000..46d3a9ed0 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A18_T1.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A18_T1; +* @section: 13.2.2; +* @assertion: Using arguments object within a "with" Expression that is nested in a function is admitted; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A18_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A18_T2.js new file mode 100644 index 000000000..52accec4c --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A18_T2.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A18_T2; +* @section: 13.2.2; +* @assertion: Using arguments object within a "with" Expression that is nested in a function is admitted; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T1.js new file mode 100644 index 000000000..a21ce40eb --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_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. + +/** +* @name: S13.2.2_A19_T1; +* @section: 13.2.2; +* @assertion: Function's scope chain is started when it is declared; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T2.js new file mode 100644 index 000000000..2440a2e12 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T2.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. + +/** +* @name: S13.2.2_A19_T2; +* @section: 13.2.2; +* @assertion: Function's scope chain is started when it is declared; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T3.js new file mode 100644 index 000000000..901e3c830 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_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. + +/** +* @name: S13.2.2_A19_T3; +* @section: 13.2.2; +* @assertion: Function's scope chain is started when it is declared; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T4.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T4.js new file mode 100644 index 000000000..10aacbe90 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T4.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. + +/** +* @name: S13.2.2_A19_T4; +* @section: 13.2.2; +* @assertion: Function's scope chain is started when it is declared; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T5.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T5.js new file mode 100644 index 000000000..c0e5a62ac --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T5.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A19_T5; +* @section: 13.2.2; +* @assertion: Function's scope chain is started when it is declared; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T6.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T6.js new file mode 100644 index 000000000..df7b522fb --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T6.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. + +/** +* @name: S13.2.2_A19_T6; +* @section: 13.2.2; +* @assertion: Function's scope chain is started when it is declared; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T7.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T7.js new file mode 100644 index 000000000..cfa12338a --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T7.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A19_T7; +* @section: 13.2.2; +* @assertion: Function's scope chain is started when it is declared; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T8.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T8.js new file mode 100644 index 000000000..aea475781 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A19_T8.js @@ -0,0 +1,73 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A19_T8; +* @section: 13.2.2; +* @assertion: Function's scope chain is started when it is declared; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A1_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A1_T1.js new file mode 100644 index 000000000..8a319f0a8 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A1_T1.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A1_T1; +* @section: 13.2.2; +* @assertion: Since a function is an object, it might be set to [[Prototype]] property of a new created object through [[Construct]] property; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A1_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A1_T2.js new file mode 100644 index 000000000..949b8f02c --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A1_T2.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A1_T2; +* @section: 13.2.2; +* @assertion: Since a function is an object, it might be set to [[Prototype]] property of a new created object through [[Construct]] property; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A2.js new file mode 100644 index 000000000..f09062251 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A2.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. + +/** +* @name: S13.2.2_A2; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A3_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A3_T1.js new file mode 100644 index 000000000..741540701 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A3_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. + +/** +* @name: S13.2.2_A3_T1; +* @section: 13.2.2, 15.2.3.1; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A3_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A3_T2.js new file mode 100644 index 000000000..41bd3fbce --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A3_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. + +/** +* @name: S13.2.2_A3_T2; +* @section: 13.2.2, 15.2.3.1; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A4_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A4_T1.js new file mode 100644 index 000000000..4f2fdfe70 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A4_T1.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A4_T1; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A4_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A4_T2.js new file mode 100644 index 000000000..0f09869d6 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A4_T2.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. + +/** +* @name: S13.2.2_A4_T2; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A5_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A5_T1.js new file mode 100644 index 000000000..5c68631a4 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A5_T1.js @@ -0,0 +1,79 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A5_T1; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A5_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A5_T2.js new file mode 100644 index 000000000..6ce86db7e --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A5_T2.js @@ -0,0 +1,79 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A5_T2; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A6_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A6_T1.js new file mode 100644 index 000000000..17b9e3d58 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A6_T1.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. + +/** +* @name: S13.2.2_A6_T1; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A6_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A6_T2.js new file mode 100644 index 000000000..1e46f0897 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A6_T2.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. + +/** +* @name: S13.2.2_A6_T2; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A7_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A7_T1.js new file mode 100644 index 000000000..7895e2085 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A7_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. + +/** +* @name: S13.2.2_A7_T1; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A7_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A7_T2.js new file mode 100644 index 000000000..221b5a697 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A7_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. + +/** +* @name: S13.2.2_A7_T2; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A8_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A8_T1.js new file mode 100644 index 000000000..ab3e2fef5 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A8_T1.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A8_T1; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A8_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A8_T2.js new file mode 100644 index 000000000..ab0a8b9e9 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A8_T2.js @@ -0,0 +1,51 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A8_T2; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A8_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A8_T3.js new file mode 100644 index 000000000..a8c9ded84 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A8_T3.js @@ -0,0 +1,51 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2.2_A8_T3; +* @section: 13.2.2; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A9.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A9.js new file mode 100644 index 000000000..bba1a0c0d --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2.2_A9.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. + +/** +* @name: S13.2.2_A9; +* @section: 13.2.2; +* @assertion: Calling a function as a constructor is inadmissible as long as this.any_Function is called before it is declared; +* @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) {} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A1_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A1_T1.js new file mode 100644 index 000000000..30bc47e09 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A1_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. + +/** +* @name: S13.2_A1_T1; +* @section: 13.2; +* @assertion: A "prototype" property is automatically created for every function; +* @description: Using "function __func(){}" as a FunctionDeclaration; +*/ + +function __func(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func.prototype === undefined) { + $ERROR('#1: __func.prototype !== undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A1_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A1_T2.js new file mode 100644 index 000000000..eed54fb2b --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A1_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2_A1_T2; +* @section: 13.2; +* @assertion: A "prototype" property is automatically created for every function; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A2_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A2_T1.js new file mode 100644 index 000000000..f98111a3f --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A2_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. + +/** +* @name: S13.2_A2_T1; +* @section: 13.2; +* @assertion: Nested function are admitted; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A2_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A2_T2.js new file mode 100644 index 000000000..dbcf99b32 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A2_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. + +/** +* @name: S13.2_A2_T2; +* @section: 13.2; +* @assertion: Nested function are admitted; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A3.js new file mode 100644 index 000000000..71bd35b86 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A3.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. + +/** +* @name: S13.2_A3; +* @section: 13.2; +* @assertion: When Function object(F) is constructed the length property of F is set to the number of formal properties specified in FormalParameterList; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A4_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A4_T1.js new file mode 100644 index 000000000..a8928f097 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A4_T1.js @@ -0,0 +1,51 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2_A4_T1; +* @section: 13.2; +* @assertion: 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).; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A4_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A4_T2.js new file mode 100644 index 000000000..78215214e --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A4_T2.js @@ -0,0 +1,51 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13.2_A4_T2; +* @section: 13.2; +* @assertion: 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).; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A5.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A5.js new file mode 100644 index 000000000..9840c93d4 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/13.2_Creating_Function_Objects/S13.2_A5.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. + +/** +* @name: S13.2_A5; +* @section: 13.2, 15.3.3.1; +* @assertion: 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; +* @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/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A1.js new file mode 100644 index 000000000..ffddd8c0d --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A1.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. + +/** +* @name: S13_A1; +* @section: 13; +* @assertion: "x=function y(){}" statement does not store a reference to the new function in the varaible y(Identifier); +* @description: Checking the type of y; +*/ + +var __func = function __exp__func(){return 0;}; + +//////////////////////////////////////////////// +// ////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + $ERROR('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof __exp__func !== "undefined"){ + $ERROR('#2: typeof __exp__func === "undefined". Actual: typeof __exp__func ==='+typeof __exp__func); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A10.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A10.js new file mode 100644 index 000000000..a6dad273b --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_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. + +/** +* @name: S13_A10; +* @section: 13; +* @assertion: Function is a data; +* @description: Using function as a property of an object; +*/ + +function __ziggy__func(){return "ziggy stardust"} + +var __music_box={}; + +__music_box.ziggy = __ziggy__func; + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +if (typeof __music_box.ziggy !== "function") { + $ERROR('#1: typeof __music_box.ziggy === "function". Actual: typeof __music_box.ziggy ==='+typeof __music_box.ziggy); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__music_box.ziggy() !== "ziggy stardust") { + $ERROR('#2: __music_box.ziggy() === "ziggy stardust". Actual: __music_box.ziggy() ==='+__music_box.ziggy()); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_T1.js new file mode 100644 index 000000000..299bc5552 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_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. + +/** +* @name: S13_A11_T1; +* @section: 13; +* @assertion: Since arguments property has attribute { DontDelete }, only its elements can be deleted; +* @description: Returning result of "delete arguments"; +*/ + +function __func(){ return delete arguments;} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func("A","B",1,2)) { + $ERROR('#1: arguments property has attribute { DontDelete }'); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_T2.js new file mode 100644 index 000000000..130d4c899 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_T2.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. + +/** +* @name: S13_A11_T2; +* @section: 13; +* @assertion: Since arguments property has attribute { DontDelete }, only its elements can be deleted; +* @description: Checking if deleting the arguments property fails and then returning it; +*/ + +function __func(){ + delete arguments; + return arguments; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func("A","B",1,2) !== "object") { + $ERROR('#1: arguments property has attribute { DontDelete }'); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_T3.js new file mode 100644 index 000000000..10e879400 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_T3.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. + +/** +* @name: S13_A11_T3; +* @section: 13; +* @assertion: Since arguments property has attribute { DontDelete }, only its elements can be deleted; +* @description: Deleting arguments[i] and returning result of the operation; +*/ + +function __func(){ + was_del=false; + for (i=0; i < arguments.length; i++) + was_del= was_del || delete arguments[i]; + return was_del; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!__func("A","B",1,2)) { + $ERROR('#1: Since arguments property has attribute { DontDelete } elements of arguments can be deleted'); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_T4.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_T4.js new file mode 100644 index 000000000..d446882ef --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A11_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. + +/** +* @name: S13_A11_T4; +* @section: 13; +* @assertion: Since arguments property has attribute { DontDelete }, only its elements can be deleted; +* @description: Deleting arguments[i] and checking the type of arguments[i]; +*/ + +function __func(){ + is_undef=true; + for (i=0; i < arguments.length; i++) + { + delete arguments[i]; + is_undef= is_undef && (typeof arguments[i] === "undefined"); + }; + return is_undef; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!__func("A","B",1,2)) { + $ERROR('#1: Since arguments property has attribute { DontDelete }, but elements of arguments can be deleted'); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A12_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A12_T1.js new file mode 100644 index 000000000..82ff29beb --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A12_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. + +/** +* @name: S13_A12_T1; +* @section: 13; +* @assertion: Function declarations in global or function scope are {DontDelete}; +* @description: Checking if deleting a function that is declared in global scope fails; +*/ + +ALIVE="Letov is alive" + +function __func(){ + return ALIVE; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (delete __func) { + $ERROR('#1: delete __func returning false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func() !== ALIVE) { + $ERROR('#2: __func() === ALIVE. Actual: __func() ==='+__func()); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A12_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A12_T2.js new file mode 100644 index 000000000..4467cdc46 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A12_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. + +/** +* @name: S13_A12_T2; +* @section: 13; +* @assertion: Function declarations in global or function scope are {DontDelete}; +* @description: Checking if deleting a function that is declared in function scope fails; +*/ + +ALIVE="Letov is alive" + +function __cont(){ + + function __func(){ + return ALIVE; + }; + + ////////////////////////////////////////////////////////////////////////////// + //CHECK#1 + if (delete __func) { + $ERROR('#1: delete __func returning false'); + } + // + ////////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////////// + //CHECK#2 + if (__func() !== ALIVE) { + $ERROR('#2: __func() === ALIVE. Actual: __func() ==='+__func()); + } + // + ////////////////////////////////////////////////////////////////////////////// +}; + +__cont(); diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A13_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A13_T1.js new file mode 100644 index 000000000..ad024f20b --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A13_T1.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. + +/** +* @name: S13_A13_T1; +* @section: 13; +* @assertion: Deleting arguments[i] leads to breaking the connection to local reference; +* @description: Deleting arguments[i]; +*/ + +function __func(__arg){ + delete arguments[0]; + if (arguments[0] !== undefined) { + $ERROR('#1.1: arguments[0] === undefined'); + } + return __arg; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(1) !== 1) { + $ERROR('#1.2: __func(1) === 1. Actual: __func(1) ==='+__func(1)); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A13_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A13_T2.js new file mode 100644 index 000000000..13db07dbb --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A13_T2.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. + +/** +* @name: S13_A13_T2; +* @section: 13; +* @assertion: Deleting arguments[i] leads to breaking the connection to local reference; +* @description: Changing arguments value and then deleting the argument; +*/ + +function __func(__arg){ + __arg = 2; + delete arguments[0]; + if (arguments[0] !== undefined) { + $ERROR('#1.1: arguments[0] === undefined'); + } + return __arg; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(1) !== 2) { + $ERROR('#1.2: __func(1) === 2. Actual: __func(1) ==='+__func(1)); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A13_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A13_T3.js new file mode 100644 index 000000000..870304d72 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A13_T3.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. + +/** +* @name: S13_A13_T3; +* @section: 13; +* @assertion: Deleting arguments[i] leads to breaking the connection to local reference; +* @description: Changing argument value, deleting the argument and then defining a new value for arguments[i]; +*/ + +function __func(__arg){ + __arg = 2; + delete arguments[0]; + if (arguments[0] !== undefined) { + $ERROR('#1.1: arguments[0] === undefined'); + } + arguments[0] = "A"; + if (arguments[0] !== "A") { + $ERROR('#1.2: arguments[0] === "A"'); + } + return __arg; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(1) !== 2) { + $ERROR('#1.3: __func(1) === 2. Actual: __func(1) ==='+__func(1)); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A14.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A14.js new file mode 100644 index 000000000..44b8f9f68 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A14.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. + +/** +* @name: S13_A14; +* @section: 13; +* @assertion: Unicode symbols in function name are allowed; +* @description: Defining function name with unicode symbols; +*/ + +eval("function __func\u0041(__arg){return __arg;};"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __funcA !== "function") { + $ERROR('#1: unicode symbols in function name are allowed'); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T1.js new file mode 100644 index 000000000..e9f6a8514 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T1.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. + +/** +* @name: S13_A15_T1; +* @section: 13; +* @assertion: ''arguments'' variable overrides ActivationObject.arguments; +* @description: Declaring a function with "__func(arguments)"; +*/ + +function __func(arguments){ + return arguments; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(42) !== 42) { + $ERROR('#1: "arguments" variable overrides ActivationObject.arguments'); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T2.js new file mode 100644 index 000000000..b86409a57 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T2.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. + +/** +* @name: S13_A15_T2; +* @section: 13; +* @assertion: ''arguments'' variable overrides ActivationObject.arguments; +* @description: Overriding arguments within functions body; +*/ + +THE_ANSWER="Answer to Life, the Universe, and Everything"; + +function __func(){ + var arguments = THE_ANSWER; + return arguments; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(42,42,42) !== THE_ANSWER) { + $ERROR('#1: "arguments" variable overrides ActivationObject.arguments'); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T3.js new file mode 100644 index 000000000..502dc1c94 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T3.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. + +/** +* @name: S13_A15_T3; +* @section: 13; +* @assertion: ''arguments'' variable overrides ActivationObject.arguments; +* @description: Declaring a variable named with "arguments" without a function; +*/ + +THE_ANSWER="Answer to Life, the Universe, and Everything"; + +var arguments = THE_ANSWER; + +function __func(arguments){ + return arguments; + +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func() !== "undefined") { + $ERROR('#1: typeof __func() === "undefined". Actual: typeof __func() ==='+typeof __func()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func("The Ultimate Question") !== "The Ultimate Question") { + $ERROR('#2: __func("The Ultimate Question") === "The Ultimate Question". Actual: __func("The Ultimate Question")==='+__func("The Ultimate Question")); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T4.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T4.js new file mode 100644 index 000000000..47a7045ac --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T4.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. + +/** +* @name: S13_A15_T4; +* @section: 13; +* @assertion: ''arguments'' variable overrides ActivationObject.arguments; +* @description: Declaring a variable named with "arguments" and following a "return" statement within a function body; +*/ + +THE_ANSWER="Answer to Life, the Universe, and Everything"; + +function __func(){ + return typeof arguments; + var arguments = THE_ANSWER; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func(42,42,42) !== "object") { + $ERROR('#1: __func(42,42,42) === "object". Actual: __func(42,42,42)==='+__func(42,42,42)); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T5.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T5.js new file mode 100644 index 000000000..636e3833a --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A15_T5.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. + +/** +* @name: S13_A15_T5; +* @section: 13; +* @assertion: ''arguments'' variable overrides ActivationObject.arguments; +* @description: Creating a variable named with "arguments" without a function; +*/ + +THE_ANSWER="Answer to Life, the Universe, and Everything"; + +var arguments = THE_ANSWER; + +function __func(){ + return arguments; +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ( __func() === THE_ANSWER) { + $ERROR('#1: __func() !== THE_ANSWER'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func("The Ultimate Question") === "The Ultimate Question") { + $ERROR('#2: __func("The Ultimate Question") !== "The Ultimate Question"'); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A16.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A16.js new file mode 100644 index 000000000..2c4da1b75 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A16.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13_A16; +* @section: 13; +* @assertion: Any separators are admitted between declaration chunks; +* @description: Inserting separators between declaration chunks; +*/ + +function +x +( +) +{ +} +; + +x(); + +function y ( ) {}; + +y(); + +function + +z + +( + +) + +{ + +} + +; + +z(); + +eval("function\u0009\u2029w(\u000C)\u00A0{\u000D};"); + +w(); diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A17_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A17_T1.js new file mode 100644 index 000000000..ab4287e3d --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A17_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. + +/** +* @name: S13_A17_T1; +* @section: 13; +* @assertion: Function call cannot appear in the program before the FunctionExpression appears; +* @description: Trying to call a function before the FunctionExpression appears; +*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var __result = __func(); + $FAIL("#1.1: var __result = __func() lead to throwing exception"); +} catch(e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: func should throw a TypeError Actual: ' + (e)); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +var __func = function (){return "ONE";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +var __result = __func(); +if (__result !== "ONE") { + $ERROR('#2: __result === "ONE". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// + +__func = function (){return "TWO";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +var __result = __func(); +if (__result !== "TWO") { + $ERROR('#3: __result === "TWO". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A17_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A17_T2.js new file mode 100644 index 000000000..61d2e837e --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A17_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. + +/** +* @name: S13_A17_T2; +* @section: 13; +* @assertion: Function call cannot appear in the program before the FunctionExpression appears; +* @description: Trying to call a function before the FunctionExpression appears and then using the FunctionExpression one more time; +*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var __result = __func(); + $ERROR("#1: var __result = __func() lead to throwing exception"); +} catch(e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: func should throw a TypeError Actual: ' + (e)); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +// now we reach the __func overwriting by new expression +var __func = function __func(){return "ONE";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +var __result = __func(); +if (__result !== "ONE") { + $ERROR('#2: __result === "ONE". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// + +__func = function __func(){return "TWO";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +var __result = __func(); +if (__result !== "TWO") { + $ERROR('#3: __result === "TWO". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A18.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A18.js new file mode 100644 index 000000000..d16252c92 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A18.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. + +/** +* @name: S13_A18; +* @section: 13; +* @assertion: Closures are admitted; +* @description: Using a function declaration as a function parameter; +*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof sinx !== 'undefined') { + $ERROR('#1: typeof sinx === \'undefined\'. Actual: typeof sinx ==='+typeof sinx); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __val = function derivative(f, dx) { + return function(x) { + return (f(x + dx) - f(x)) / dx; + }; +}(function sinx(x){return Math.sin(x);},.0001)(0.5); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof sinx !== 'undefined') { + $ERROR('#2: typeof sinx === \'undefined\'. Actual: typeof sinx ==='+typeof sinx); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A19_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A19_T1.js new file mode 100644 index 000000000..b686b19e2 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A19_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. + +/** +* @name: S13_A19_T1; +* @section: 13,13.2; +* @assertion: "var" does not override function declaration; +* @description: Creating a function and a variable with identical Identifiers in global scope; +*/ + +// since "var" does not override function declaration __decl is set to function +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __decl !== "function") { + $ERROR('#1: typeof __decl === "function". Actual: typeof __decl ==='+typeof __decl); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __decl = 1; + +//since statement was evaluted __decl turns to 1 from function +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__decl !== 1) { + $ERROR('#2: __decl === 1. Actual: __decl ==='+__decl); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __decl(){return 1;} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A19_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A19_T2.js new file mode 100644 index 000000000..b3f8d3be3 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A19_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. + +/** +* @name: S13_A19_T2; +* @section: 13,13.2; +* @assertion: "var" does not override function declaration; +* @description: Creating a function and a variable with identical Identifiers within function scope; +*/ + +(function (){ + + // since "var" does not override function declaration __decl is set to function + ////////////////////////////////////////////////////////////////////////////// + //CHECK#1 + if (typeof __decl !== "function") { + $ERROR('#1: typeof __decl === "function". Actual: typeof __decl ==='+typeof __decl); + } + // + ////////////////////////////////////////////////////////////////////////////// + + var __decl = 1; + + //since statement was evaluted __decl turns to 1 from function + ////////////////////////////////////////////////////////////////////////////// + //CHECK#2 + if (__decl !== 1) { + $ERROR('#2: __decl === 1. Actual: __decl ==='+__decl); + } + // + ////////////////////////////////////////////////////////////////////////////// + + function __decl(){return 1;} +})(); diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A2_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A2_T1.js new file mode 100644 index 000000000..bb00e6be4 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_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. + +/** +* @name: S13_A2_T1; +* @section: 13; +* @assertion: function must be evaluated inside the expression; +* @description: Defining function body with "return arg"; +*/ + +var x = (function __func(arg){return arg})(1); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x !== 1) { + $ERROR('#1: x === 1. Actual: x ==='+x); +} + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof __func !== 'undefined') { + $ERROR('#2: typeof __func === \'undefined\'. Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A2_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A2_T2.js new file mode 100644 index 000000000..1d929c9c8 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A2_T2.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. + +/** +* @name: S13_A2_T2; +* @section: 13; +* @assertion: function must be evaluated inside the expression; +* @description: Defining function body with "return arg + arguments[1]"; +*/ + +var x = (function __func(arg){return arg + arguments[1]})(1,"1"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x !== "11") { + $ERROR('#1: x === "11". Actual: x ==='+x); +} + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof __func !== 'undefined') { + $ERROR('#2: typeof __func === \'undefined\'. Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A2_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A2_T3.js new file mode 100644 index 000000000..dd9c3379a --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A2_T3.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. + +/** +* @name: S13_A2_T3; +* @section: 13; +* @assertion: function must be evaluated inside the expression; +* @description: Defining function body with "return arguments[0] +"-"+ arguments[1]"; +*/ + +var x = (function __func(){return arguments[0] +"-"+ arguments[1]})("Obi","Wan"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x !== "Obi-Wan") { + $ERROR('#1: x === "Obi-Wan". Actual: x ==='+x); +} + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof __func !== 'undefined') { + $ERROR('#2: typeof __func === \'undefined\'. Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A3_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A3_T1.js new file mode 100644 index 000000000..2865a6a4c --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A3_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. + +/** +* @name: S13_A3_T1; +* @section: 13; +* @assertion: The Identifier in a FunctionExpression can be referenced from inside the FunctionExpression's FunctionBody to allow the function calling itself recursively; +* @description: Creating a recursive function that calculates factorial, as a variable. +* Function call itself by it`s name; +*/ + +var __func = function __exp__func(arg){ + if (arg === 1) { + return arg; + } else { + return __exp__func(arg-1)*arg; + } +}; + +var fact_of_3 = __func(3); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (fact_of_3 !== 6) { + $ERROR("#1: fact_of_3 === 6. Actual: fact_of_3 ==="+fact_of_3); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A3_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A3_T2.js new file mode 100644 index 000000000..fa97513bd --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A3_T2.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. + +/** +* @name: S13_A3_T2; +* @section: 13; +* @assertion: The Identifier in a FunctionExpression can be referenced from inside the FunctionExpression's FunctionBody to allow the function calling itself recursively; +* @description: Creating a recursive function that calculates factorial, as a variable. +* Function calls itself by the name of the variable; +*/ + +var __func = function (arg){ + if (arg === 1) { + return arg; + } else { + return __func(arg-1)*arg; + } +}; + +var fact_of_3 = __func(3); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (fact_of_3 !== 6) { + $ERROR("#1: fact_of_3 === 6. Actual: fact_of_3 ==="+fact_of_3); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A3_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A3_T3.js new file mode 100644 index 000000000..0f9b72eac --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A3_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. + +/** +* @name: S13_A3_T3; +* @section: 13; +* @assertion: The Identifier in a FunctionExpression can be referenced from inside the FunctionExpression's FunctionBody to allow the function calling itself recursively; +* @description: Creating simple recursive function that calculates factorial; +*/ + +function __func(arg){ + if (arg === 1) { + return arg; + } else { + return __func(arg-1)*arg; + } +}; + +var fact_of_3 = __func(3); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (fact_of_3 !== 6) { + $ERROR("#1: fact_of_3 === 6. Actual: fact_of_3 ==="+fact_of_3); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A4_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A4_T1.js new file mode 100644 index 000000000..332c26855 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_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. + +/** +* @name: S13_A4_T1; +* @section: 13; +* @assertion: The production FunctionDeclaration: "function Identifier ( FormalParameterList_opt ) { FunctionBody }" is processed by function declarations; +* @description: Declaring a function that returns string; +*/ + +function __func(){return "zig-zig-sputnik";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + $ERROR('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func() !== "zig-zig-sputnik") { + $ERROR('#2: __func() === "zig-zig-sputnik". Actual: __func() ==='+__func()); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A4_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A4_T2.js new file mode 100644 index 000000000..ce4678332 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_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. + +/** +* @name: S13_A4_T2; +* @section: 13; +* @assertion: The production FunctionDeclaration: "function Identifier ( FormalParameterList_opt ) { FunctionBody }" is processed by function declarations; +* @description: Declaring a function that uses prefix increment operator within its "return" Expression; +*/ + +function __func(arg){return ++arg;}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + $ERROR('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func(1) !== 2) { + $ERROR('#2: __func(1) === 2. Actual: __func(1) ==='+__func(1)); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A4_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A4_T3.js new file mode 100644 index 000000000..8f6240227 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_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. + +/** +* @name: S13_A4_T3; +* @section: 13; +* @assertion: The production FunctionDeclaration: "function Identifier ( FormalParameterList_opt ) { FunctionBody }" is processed by function declarations; +* @description: Declaring a function that uses arithmetical operators within its "return" Expression; +*/ + +function __func(arg1, arg2, arg3){return arg1+=(arg2+=arg3);}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + $ERROR('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func(10, 20, 30) !== 60) { + $ERROR('#2: __func(10, 20, 30) === 60. Actual: __func(10,20,30) ==='+__func(10,20,30)); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A4_T4.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A4_T4.js new file mode 100644 index 000000000..7609bba96 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A4_T4.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13_A4_T4; +* @section: 13; +* @assertion: The production FunctionDeclaration: "function Identifier ( FormalParameterList_opt ) { FunctionBody }" is processed by function declarations; +* @description: Declaring a function that uses strings concatenaion opeator within its "return" Expression; +*/ + +function __func(){return arguments[0].name + " " + arguments[0].surname;}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + $ERROR('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func({name:'fox', surname:'malder'}) !== "fox malder") { + $ERROR('#2: __func({name:\'fox\', surname:\'malder\'}) === "fox malder". Actual: __func({name:\'fox\', surname:\'malder\'}) ==='+__func({name:'fox', surname:'malder'})); +} +// +////////////////////////////////////////////////////////////////////////////// + +function func__(arg){return arg.name + " " + arg.surname;}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof func__ !== "function") { + $ERROR('#3: typeof func__ === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (func__({name:'john', surname:'lennon'}) !== "john lennon") { + $ERROR('#4: func__({name:\'john\', surname:\'lennon\'}) === "john lennon". Actual: __func({name:\'john\', surname:\'lennon\'}) ==='+__func({name:'john', surname:'lennon'})); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A5.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A5.js new file mode 100644 index 000000000..34ce13e00 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A5.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13_A5; +* @section: 13, 10.1.2; +* @assertion: Only FormalParameterList as arguments list is allowed; +* @description: Trying to use [arg1, arg2, arg3], (arg1, arg2, arg3), etc. as a FormalParameterList; +*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + eval("function __func([arg1, arg2, arg3]){return arguments.length;}"); + $ERROR('#1: eval("function __func([arg1, arg2, arg3]){return arguments.length;}") lead to throwing exception'); +} catch(e){ + if(!(e instanceof SyntaxError)){ + $ERROR('#1.1: eval("function __func([arg1, arg2, arg3]){return arguments.length;}") lead to throwing exception of SyntaxError. Actual: exception is '+e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try{ + eval("function __func((arg1, arg2, arg3)){return arguments.length;}"); + $ERROR('#2: eval("function __func((arg1, arg2, arg3)){return arguments.length;}") lead to throwing exception') +} catch(e){ + if(!(e instanceof SyntaxError)){ + $ERROR('#2.1: eval("function __func((arg1, arg2, arg3)){return arguments.length;}") lead to throwing exception of SyntaxError. Actual: exception is '+e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +try{ + eval("function __func(arg1, arg2, arg3,){return arguments.length;}"); + $ERROR('#3: eval("function __func(arg1, arg2, arg3,){return arguments.length;}") lead to throwing exception') +} catch(e){ + if(!(e instanceof SyntaxError)){ + $ERROR('#3.1: eval("function __func(arg1, arg2, arg3,){return arguments.length;}") lead to throwing exception of SyntaxError. Actual: exception is '+e); + } +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A6_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A6_T1.js new file mode 100644 index 000000000..4da1f1e6b --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A6_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. + +/** +* @name: S13_A6_T1; +* @section: 13; +* @assertion: FunctionDeclaration can be overrided by other FunctionDeclaration with the same Identifier; +* @description: Duplicating function declaration; +*/ + +function __func(){return 1}; + +var __store__func = __func; + +var __1 = __func(); + + function __func(){return 'A'}; + +var __A = __func(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__store__func !== __func) { + $ERROR('#1: __store__func === __func. Actual: __store__func ==='+__store__func); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__1 !== __A) { + $ERROR('#2: __1 === __A. Actual: __1 ==='+__1); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A6_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A6_T2.js new file mode 100644 index 000000000..fd2fcb83d --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A6_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. + +/** +* @name: S13_A6_T2; +* @section: 13; +* @assertion: FunctionDeclaration can be overrided by other FunctionDeclaration with the same Identifier; +* @description: Calling a function before it is declared one more time; +*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + var __result = __func(); +} catch(e) { + $FAIL("#1: Function call can appears in the program before the FunctionDeclaration appears"); +} +if (__result !== "SECOND") { + $ERROR('#1.1: __result === "SECOND". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func(){return "FIRST";}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +__result = __func(); +if (__result !== "SECOND") { + $ERROR('#2: __result === "SECOND". Actual: __result ==='+__result); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func(){return "SECOND";}; diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A7_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A7_T1.js new file mode 100644 index 000000000..df5614109 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A7_T1.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. + +/** +* @name: S13_A7_T1; +* @section: 13; +* @assertion: The FunctionBody must be SourceElements; +* @description: Using only SourceElements within the FunctionBody; +*/ + +function __func(){'ground control to major tom'}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __func !== "function") { + $ERROR('#1: typeof __func === "function". Actual: typeof __func ==='+typeof __func); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func__2(){b}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof __func__2 !== "function") { + $ERROR('#2: typeof __func__2 === "function". Actual: typeof __func__2 ==='+typeof __func__2); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func__3(){1}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __func__3 !== "function") { + $ERROR('#3: typeof __func__3 === "function". Actual: typeof __func__3 ==='+typeof __func__3); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func__4(){1+c}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (typeof __func__4 !== "function") { + $ERROR('#4: typeof __func__4 === "function". Actual: typeof __func__4 ==='+typeof __func__4); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func__5(){inc(d)}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof __func__5 !== "function") { + $ERROR('#5: typeof __func__5 === "function". Actual: typeof __func__5 ==='+typeof __func__5); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func__6(){var \u0042 = 1;}; +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (typeof __func__6 !== "function") { + $ERROR('#6: typeof __func__6 === "function". Actual: typeof __func__6 ==='+typeof __func__6); +} +// +////////////////////////////////////////////////////////////////////////////// + +//function __func__7(){var \u003d = 1;}; +//////////////////////////////////////////////////////////////////////////////// +////CHECK#7 +//if (typeof __func__7 !== "function") { +// $ERROR('#7: The FunctionBody must be SourceElements'); +//} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A7_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A7_T2.js new file mode 100644 index 000000000..54d006747 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A7_T2.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13_A7_T2; +* @section: 13; +* @assertion: The FunctionBody must be SourceElements; +* @description: Inserting elements that is different from SourceElements into the FunctionBody; +*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try{ + eval("function __func(){/ ABC}"); + $ERROR('#1: eval("function __func(){/ ABC}") lead to throwing exception'); +} catch(e){ + if(!(e instanceof SyntaxError)){ + $ERROR('#1.1: eval("function __func(){/ ABC}") lead to throwing exception of SyntaxError. Actual: exception is '+e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +try{ + eval("function __func(){&1}"); + $ERROR('#3: eval("function __func(){&1}") lead to throwing exception'); +} catch(e){ + if(!(e instanceof SyntaxError)){ + $ERROR('#3.1: eval("function __func(){&1}") lead to throwing exception of SyntaxError. Actual: exception is '+e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +try{ + eval("function __func(){# ABC}"); + $ERROR('#4: eval("function __func(){# ABC}") lead to throwing exception'); +} catch(e){ + if(!(e instanceof SyntaxError)){ + $ERROR('#4.1: eval("function __func(){# ABC}") lead to throwing exception of SyntaxError. Actual: exception is '+e); + } +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A7_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A7_T3.js new file mode 100644 index 000000000..1fef1dff8 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A7_T3.js @@ -0,0 +1,12 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S13_A7_T3; +* @section: 13; +* @assertion: The FunctionBody must be SourceElements; +* @description: Checking if execution of "function __func(){\A\B\C}" fails; +* @negative; +*/ + +function __func(){\A\B\C}; diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A8_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A8_T1.js new file mode 100644 index 000000000..941035b32 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A8_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. + +/** +* @name: S13_A8_T1; +* @section: 13; +* @assertion: Arguments property of activation object contains real params to be passed; +* @description: Creating a function declared with "function __func(param1, param2, param3)" and using arguments.length property in order to perform the test; +*/ + + function __func(param1, param2, param3) { + return arguments.length; + } + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func('A') !== 1) { + $ERROR('#1: __func(\'A\') === 1. Actual: __func(\'A\') ==='+__func('A')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func('A', 'B', 1, 2,__func) !== 5) { + $ERROR('#2: __func(\'A\', \'B\', 1, 2,__func) === 5. Actual: __func(\'A\', \'B\', 1, 2,__func) ==='+__func('A', 'B', 1, 2,__func)); +} +// +////////////////////////////////////////////////////////////////////////////// + + + diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A8_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A8_T2.js new file mode 100644 index 000000000..3de62a732 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A8_T2.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. + +/** +* @name: S13_A8_T2; +* @section: 13; +* @assertion: Arguments property of activation object contains real params to be passed; +* @description: Creating a function with no parameters and using arguments.length property in order to perform the test; +*/ + + function __func() { + return arguments.length; + } + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func('A') !== 1) { + $ERROR('#1: __func(\'A\') === 1. Actual: __func(\'A\') ==='+__func('A')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__func('A', 'B', 1, 2,__func) !== 5) { + $ERROR('#2: __func(\'A\', \'B\', 1, 2,__func) === 5. Actual: __func(\'A\', \'B\', 1, 2,__func) ==='+__func('A', 'B', 1, 2,__func)); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__func() !== 0) { + $ERROR('#3: __func() === 0. Actual: __func() ==='+__func()); +} +// +////////////////////////////////////////////////////////////////////////////// diff --git a/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A9.js b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A9.js new file mode 100644 index 000000000..9e8d73218 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/13_Function_Definition/S13_A9.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. + +/** +* @name: S13_A9; +* @section: 13; +* @assertion: Function can be passed as argument; +* @description: Using function as argument of another function; +*/ + +function __func__INC(arg){return arg + 1;}; +function __func__MULT(incrementator, arg, mult){ return incrementator(arg)*mult; }; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func__MULT(__func__INC, 2, 2) !== 6) { + $ERROR('#1: function can be passed as argument'); +} +// +////////////////////////////////////////////////////////////////////////////// + |