aboutsummaryrefslogtreecommitdiffstats
path: root/website/resources/scripts/testcases2/10.1_Definitions.json
blob: 72b92edf047eb3f36e3db29d8394cd2e6e3201af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
 "testCollection": {
  "name": "10.1_Definitions",
  "numTests": 8,
  "tests": [
   {
    "section": "10.1.1",
    "description": "Defining function by a FunctionDeclaration",
    "test": "//CHECK#1\nfunction f1(){\n  return 1;\n}\nif(typeof(f1)!==\"function\")\n  $ERROR('#1: typeof(f1)!==\"function\"');\n",
    "id": "S10.1.1_A1_T1"
   },
   {
    "section": "10.1.1",
    "description": "Creating function dynamically by using a FunctionExpression",
    "test": "//CHECK#1\nvar x=function f1(){return 1;}();\nif(x!==1)\n  $ERROR('#1: Create function dynamically either by using a FunctionExpression');\n\n//CHECK#2\nvar y=function  (){return 2;}();\nif(y!==2){\n  $ERROR('#2: Create an anonymous function dynamically either by using a FunctionExpression');\n}\n\n//CHECK#2\nvar z = (function(){return 3;})();\nif(z!==3){\n  $ERROR('#3: Create an anonymous function dynamically either by using a FunctionExpression wrapped in a group operator');\n}\n",
    "id": "S10.1.1_A1_T2"
   },
   {
    "section": "10.1.1",
    "description": "Creating function dynamically by using the built-in Function object as a constructor",
    "test": "//CHECK#1\nvar x=new function f1(){return 1;};\nif(typeof(x.constructor)!==\"function\")\n  $ERROR('#1: typeof(x.constructor)!==\"function\"');\n",
    "id": "S10.1.1_A1_T3"
   },
   {
    "section": "10.1.1",
    "description": "Checking types of parseInt and Math.exp",
    "test": "//CHECK#1\nif(typeof(Math.exp)!==\"function\")\n  $ERROR('#1: typeof(Math.exp(10))!==\"function\" '+typeof(Math.exp()));\n\n//CHECK#2\nif(typeof(parseInt)!==\"function\")\n  $ERROR('#2: typeof(parseInt())!==\"function\" '+typeof(parseInt()));\n  \n",
    "id": "S10.1.1_A2_T1"
   },
   {
    "section": "10.1.6",
    "description": "Checking ifdeleting function parameter is possible",
    "test": "//CHECK#1\nfunction f1(a){\n  delete a;\n  return a;\n}\nif (f1(1) !== 1)\n  $ERROR('#1: Function parameter was deleted');\n  \n",
    "id": "S10.1.6_A1_T1"
   },
   {
    "section": "10.1.6",
    "description": "Checking funtion which returns property \"arguments\"",
    "test": "var ARG_STRING = \"value of the argument property\";\n\nfunction f1() {\n  this.constructor.prototype.arguments = ARG_STRING;\n  return arguments;\n}\n  \n//CHECK#1\nif ((new f1(1,2,3,4,5)).length !== 5)\n  $ERROR('#1: (new f1(1,2,3,4,5)).length===5, where f1 returns \"arguments\" that is set to \"'+ ARG_STRING + '\"');\n\n//CHECK#2  \nif ((new f1(1,2,3,4,5))[3] !== 4)\n  $ERROR('#2: (new f1(1,2,3,4,5))[3]===4, where f1 returns \"arguments\" that is set to \"'+ ARG_STRING + '\"');\n\n//CHECK#3\nvar x = new f1(1,2,3,4,5); \nif (delete x[3] !== true)\n  $ERROR('#3.1: Function parameters have attribute {DontDelete}');\n  \nif (x[3] === 4)\n  $ERROR('#3.2: Function parameters have attribute {DontDelete}');\n",
    "id": "S10.1.6_A1_T2"
   },
   {
    "section": "10.1.6",
    "description": "Checking function which returns \"this\"",
    "test": "function f1() {\n  if (delete arguments) {\n    $ERROR(\"#1: Function parameters have attribute {DontDelete}\" + arguments);\n  }\n  return arguments;\n}\n\nf1();\n",
    "id": "S10.1.6_A1_T3"
   },
   {
    "section": "10.1.7",
    "description": "Checking if deleting \"this\" fails",
    "test": "//CHECK#1\nif (delete this !== true)\n  $ERROR('#1: The this value associated with an executioncontext is immutable. Actual: this was deleted');\n  \n",
    "id": "S10.1.7_A1_T1"
   }
  ]
 }
}