aboutsummaryrefslogtreecommitdiffstats
path: root/website/resources/scripts/testcases2/8.7_The_Reference_Type.json
diff options
context:
space:
mode:
Diffstat (limited to 'website/resources/scripts/testcases2/8.7_The_Reference_Type.json')
-rw-r--r--website/resources/scripts/testcases2/8.7_The_Reference_Type.json98
1 files changed, 98 insertions, 0 deletions
diff --git a/website/resources/scripts/testcases2/8.7_The_Reference_Type.json b/website/resources/scripts/testcases2/8.7_The_Reference_Type.json
new file mode 100644
index 000000000..50305004d
--- /dev/null
+++ b/website/resources/scripts/testcases2/8.7_The_Reference_Type.json
@@ -0,0 +1,98 @@
+{
+ "testCollection": {
+ "name": "8.7_The_Reference_Type",
+ "numTests": 14,
+ "tests": [
+ {
+ "section": "8.7.1, 11.4.1",
+ "description": "Try to delete this.y, where y is this.y=1",
+ "test": "this.y = 1;\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif((delete this.y) !== true){\n $ERROR('#1: this.y = 1; (delete this.y) === true. Actual: ' + ((delete this.y)));\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (this.y !== undefined){\n $ERROR('#2: this.y = 1; (delete this.y) === true; this.y === undefined. Actual: ' + (this.y));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S8.7.1_A1"
+ },
+ {
+ "section": "8.7.1",
+ "description": "Try to delete y, where y is var y=1",
+ "test": "var y = 1;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif(delete y){\n $ERROR('#1: y = 1; (delete y) === false. Actual: ' + ((delete y)));\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (y !== 1) {\n $ERROR('#2: y = 1; delete y; y === 1. Actual: ' + (y));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S8.7.1_A2"
+ },
+ {
+ "section": "8.7.2",
+ "description": ": Checking if execution of \"'litera'=1;\" fails;",
+ "negative": "",
+ "test": "'litera'=1;\n",
+ "id": "S8.7.2_A1_T1"
+ },
+ {
+ "section": "8.7.2",
+ "description": "Checking if execution of \"1=1\" fails",
+ "negative": "",
+ "test": "1=1;\n",
+ "id": "S8.7.2_A1_T2"
+ },
+ {
+ "section": "8.7.2",
+ "description": "Execute x++, where x is var x",
+ "test": "var x;\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (x !== undefined) {\n $ERROR('#1: var x; x === undefined. Actual: ' + (x));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\nx++;\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (x === undefined) {\n $ERROR('#2: var x; x++; x !== undefined');\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S8.7.2_A2"
+ },
+ {
+ "section": "8.7.2",
+ "description": "Execute this.x++, where this.x is undefined",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (this.x !== undefined) {\n $ERROR('#1: this.x === undefined. Actual: ' + (this.x));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\nthis.x++;\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (x === undefined) {\n $ERROR('#2: this.x; this.x++; x !== undefined');\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S8.7.2_A3"
+ },
+ {
+ "section": "8.7",
+ "description": "Create object and refers to the other object, modify a property in the original object.\n We now see that that change is represented in both variables",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#\n// Set obj to an empty object\n//\nvar obj = new Object();\n// objRef now refers to the other object\n//\nvar objRef = obj;\n// Modify a property in the original object\nobjRef.oneProperty = -1;\nobj.oneProperty = true;\n// We now see that that change is represented in both variables\n// (Since they both refer to the same object)\nif(objRef.oneProperty !== true){\n $ERROR('#1: var obj = new Object(); var objRef = obj; objRef.oneProperty = -1; obj.oneProperty = true; objRef.oneProperty === true. Actual: ' + (objRef.oneProperty));\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S8.7_A1"
+ },
+ {
+ "section": "8.7",
+ "description": "Create a reference to the array, and change original array",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\n// Create an array of items\nvar items = new Array( \"one\", \"two\", \"three\" );\n// Create a reference to the array of items\nvar itemsRef = items;\n// Add an item to the original array\nitems.push( \"four\" );var itemsRef = items;\n// The length of each array should be the same,\n// since they both point to the same array object\nif( itemsRef.length !== 4){\n $ERROR('#1: var items = new Array( \"one\", \"two\", \"three\" ); var itemsRef = items; items.push( \"four\" );var itemsRef = items; itemsRef.length !== 4');\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#\n// Create an array of items\nvar items = new Array( \"one\", \"two\", \"three\" );\n// Create a reference to the array of items\nvar itemsRef = items;\n// Add an item to the original array\nitems[1]=\"duo\";\n// The length of each array should be the same,\n// since they both point to the same array object\nif( itemsRef[1] !== \"duo\"){\n $ERROR('#2: var items = new Array( \"one\", \"two\", \"three\" ); var itemsRef = items; items[1]=\"duo\"; itemsRef[1] === \"duo\". Actual: ' + (itemsRef[1]));\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S8.7_A2"
+ },
+ {
+ "section": "8.7",
+ "description": "Create a reference to the array, and redefine original array with new array",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#\n// Set items to an array (object) of strings\nvar items = new Array( \"one\", \"two\", \"three\" );\n// Set itemsRef to a reference to items\n//\nvar itemsRef = items;\n// Set items to equal a new object\n//\nitems = new Array( \"new\", \"array\" );\n// items and itemsRef now point to different objects.\n// items points to new Array( \"new\", \"array\" )\n// itemsRef points to new Array( \"one\", \"two\", \"three\" )\nif( items == itemsRef ){\n $ERROR('#1: var items = new Array( \"one\", \"two\", \"three\" ); var itemsRef = items; items = new Array( \"new\", \"array\" ); items != itemsRef');\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S8.7_A3"
+ },
+ {
+ "section": "8.7",
+ "description": "Create a reference to the string, and Concatenate some new text onto the string object",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#\n// Set item equal to a new string object\nvar item = new String(\"test\");\n// itemRef now refers to the same string object\nvar itemRef = item;\n// Concatenate some new text onto the string object\n// NOTE: This creates a new object, and does not modify\n// the original object.\nitem += \"ing\";\n// The values of item and itemRef are NOT equal, as a whole\n// new string object has been created\nif( item == itemRef ){\n $ERROR('#1: var item = new String(\"test\"); var itemRef = item; item += \"ing\"; item != itemRef');\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S8.7_A4"
+ },
+ {
+ "section": "8.7",
+ "description": "Delete referenced object, var __ref = obj",
+ "strict_mode_negative": "",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (typeof(__ref) !== \"undefined\"){\n $ERROR('#1: typeof(__ref) === \"undefined\". Actual: ' + (typeof(__ref))); \n}; \n//\n//////////////////////////////////////////////////////////////////////////////\n\nvar obj = new Object();\nvar __ref = obj;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (typeof(__ref) === \"undefined\"){\n $ERROR('#2: obj = new Object(); var __ref = obj; typeof(__ref) !== \"undefined\"');\n}; \n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#3\nif (delete __ref !== false){\n $ERROR('#3: obj = new Object(); var __ref = obj; delete __ref === false. Actual: ' + (delete __ref));\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#4\nif (typeof(__ref) !== \"object\"){\n $ERROR('#4: obj = new Object(); var __ref = obj; delete __ref; typeof(__ref) === \"object\". Actual: ' + (typeof(__ref)));\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#5\nif (typeof(obj) !== \"object\"){\n $ERROR('#5: obj = new Object(); var __ref = obj; delete __ref; typeof(obj) === \"object\". Actual: ' + (typeof(obj)));\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S8.7_A5_T1",
+ "strict_only": ""
+ },
+ {
+ "section": "8.7, 11.4.1",
+ "description": "Delete referenced object, __ref = obj",
+ "strict_mode_negative": "",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (typeof(__ref) !== \"undefined\"){\n $ERROR('#1: typeof(__ref) === \"undefined\". Actual: ' + (typeof(__ref))); \n}; \n//\n//////////////////////////////////////////////////////////////////////////////\n\nvar obj = new Object();\nvar __ref = obj;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (typeof(__ref) === \"undefined\"){\n $ERROR('#2: obj = new Object(); __ref = obj; typeof(__ref) !== \"undefined\"');\n}; \n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#3\nif (delete __ref !== true){\n $ERROR('#3: obj = new Object(); __ref = obj; delete __ref === true. Actual: ' + (delete __ref));\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#4\nif (typeof(__ref) !== \"undefined\"){\n $ERROR('#4: obj = new Object(); __ref = obj; delete __ref; typeof(__ref) === \"undefined\". Actual: ' + (typeof(__ref)));\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#5\nif (typeof(obj) !== \"object\"){\n $ERROR('#5: obj = new Object(); __ref = obj; delete __ref; typeof(obj) === \"object\". Actual: ' + (typeof(obj)));\n};\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S8.7_A5_T2",
+ "strict_only": ""
+ },
+ {
+ "section": "8.7",
+ "description": "Adding original variable with referenced one inside function",
+ "test": "var n = 1;\nvar m = n;\n\nfunction addFirst2Second(first, second){first += second;}\n\naddFirst2Second(n, m);\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (m !== 1) {\n $ERROR('#1: var n = 1; var m = n; function addFirst2Second(first, second){first += second;} addFirst2Second(n, m); m === 1. Actual: ' + (m));\n}\n\n//\n//////////////////////////////////////////////////////////////////////////////\n\n",
+ "id": "S8.7_A6"
+ },
+ {
+ "section": "8.7",
+ "description": "Add new property to original variable inside function",
+ "test": "var n = {};\nvar m = n;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (typeof m !== \"object\") {\n $ERROR('#1: var n = {}; var m = n; typeof m === \"object\". Actual: ' + (typeof m));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\nfunction populateAge(person){person.age = 50;}\n\npopulateAge(m);\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (n.age !== 50) {\n $ERROR('#2: var n = {}; var m = n; function populateAge(person){person.age = 50;} populateAge(m); n.age === 50. Actual: ' + (n.age));\n}\n\n//\n//////////////////////////////////////////////////////////////////////////////\n\n",
+ "id": "S8.7_A7"
+ }
+ ]
+ }
+}