diff options
Diffstat (limited to 'website/resources/scripts/testcases2/15.5.4_Properties_of_the_String_Prototype_Object.json')
-rw-r--r-- | website/resources/scripts/testcases2/15.5.4_Properties_of_the_String_Prototype_Object.json | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/website/resources/scripts/testcases2/15.5.4_Properties_of_the_String_Prototype_Object.json b/website/resources/scripts/testcases2/15.5.4_Properties_of_the_String_Prototype_Object.json new file mode 100644 index 000000000..453b7a3a9 --- /dev/null +++ b/website/resources/scripts/testcases2/15.5.4_Properties_of_the_String_Prototype_Object.json @@ -0,0 +1,122 @@ +{ + "testCollection": { + "name": "15.5.4_Properties_of_the_String_Prototype_Object", + "numTests": 19, + "tests": [ + { + "section": "15.5.4.1", + "description": "Checking String.prototype.constructor", + "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (String.prototype.constructor !== String) {\n $ERROR('#1: String.prototype.constructor === String. Actual: String.prototype.constructor ==='+String.prototype.constructor ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.1_A1_T1" + }, + { + "section": "15.5.4.1", + "description": "Create new String.prototype.constructor object and check it", + "test": "var __constr = String.prototype.constructor;\n\nvar __instance = new __constr(\"choosing one\");\n\n//////////////////////////////////////////////////////////////////////////////\n// CHECK#0\nif (__instance !=\"choosing one\") {\n $ERROR('#0: __constr = String.prototype.constructor; __instance = new __constr(\"choosing one\"); __instance ==\"choosing one\". Actual: __instance =='+__instance ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n// CHECK#1\nif (__instance.constructor !== String) {\n $ERROR('#1: __constr = String.prototype.constructor; __instance = new __constr(\"choosing one\"); __instance.constructor === String. Actual: __instance.constructor ==='+__instance.constructor ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n// CHECK#2\nif (!(String.prototype.isPrototypeOf(__instance))) {\n $ERROR('#2: __constr = String.prototype.constructor; __instance = new __constr(\"choosing one\"); String.prototype.isPrototypeOf(__instance) return true. Actual: '+String.prototype.isPrototypeOf(__instance)); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n// CHECK#3\nvar __to_string_result = '[object '+ 'String' +']';\n\ndelete String.prototype.toString;\n\nif (__instance.toString() !== __to_string_result) {\n $ERROR('#3: __constr = String.prototype.constructor; __instance = new __constr(\"choosing one\"); delete String.prototype.toString; __instance.toString() === __to_string_result. Actual: __instance.toString() ==='+__instance.toString()+' __to_string_result ==='+__to_string_result ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.1_A1_T2" + }, + { + "section": "15.5.4.2", + "description": "Create new String(number) and check it`s method toString()", + "test": "var __string__obj = new String(1);\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#\nif (__string__obj.toString() !== \"\"+1) {\n $ERROR('#1: __string__obj = new String(1); __string__obj.toString() === \"\"+1. Actual: __string__obj.toString() ==='+__string__obj.toString() ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.2_A1_T1" + }, + { + "section": "15.5.4.2", + "description": "Create new String(boolean) and check it`s method toString()", + "test": "var __string__obj = new String(true);\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#\nif (__string__obj.toString() !== \"\"+true) {\n $ERROR('#1: __string__obj = new String(true); __string__obj.toString() === \"\"+true. Actual: __string__obj.toString() ==='+__string__obj.toString() ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.2_A1_T2" + }, + { + "section": "15.5.4.2", + "description": "Create new String(string) and check it`s method toString()", + "test": "var __string__obj = new String(\"metal\");\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#\nif (__string__obj.toString() !== \"metal\") {\n $ERROR('#1: __string__obj = new String(\"metal\"); __string__obj.toString() === \"metal\". Actual: __string__obj.toString() ==='+__string__obj.toString() ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.2_A1_T3" + }, + { + "section": "15.5.4.2", + "description": "Create new String(function(){}()) and check it`s method toString()", + "test": "var __string__obj = new String(function(){}());\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#\nif (__string__obj.toString() !== \"undefined\") {\n $ERROR('#1: __string__obj = new String(function(){}()); __string__obj.toString() === \"undefined\". Actual: __string__obj.toString() ==='+__string__obj.toString() ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.2_A1_T4" + }, + { + "section": "15.5.4.2", + "description": "Checking if creating variable String.prototype.toString fails", + "test": "var __toString = String.prototype.toString;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (typeof __toString !== \"function\") {\n $ERROR('#1: __toString = String.prototype.toString; typeof __toString === \"function\". Actual: typeof __toString ==='+typeof __toString ); \n}\n\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\ntry {\n var x = __toString();\n $FAIL('#2: \"__toString = String.prototype.toString; var x = __toString();\" lead to throwing exception');\n} catch (e) {\n if (!(e instanceof TypeError)) {\n $ERROR('#2.1: \"__toString = String.prototype.toString; var x = __toString();\" lead to throwing exception. Exception is instance of TypeError. Actual: exception is '+e);\n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.2_A2_T1" + }, + { + "section": "15.5.4.2", + "description": "Checking if creating the object String.prototype.toString fails", + "test": "var __obj={toString : String.prototype.toString};\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (typeof __obj[\"toString\"] !== \"function\") {\n $ERROR('#1: var __obj={toString : String.prototype.toString}; typeof __obj[\"toString\"] === \"function\". Actual: typeof __obj[\"toString\"] ==='+typeof __obj[\"toString\"] ); \n}\n\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\ntry {\n var x = (__obj == 1);\n $FAIL('#2: \"var x = (__obj == 1)\" lead to throwing exception');\n} catch (e) {\n if (!(e instanceof TypeError)) {\n $ERROR('#2.1: Exception is instance of TypeError. Actual: exception is '+e);\n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.2_A2_T2" + }, + { + "section": "15.5.4.2, 15.5.4.3", + "description": "Create new String() with various arguments and compare returned results of toString() and valueOf()", + "test": "//CHECK#1\nvar str = new String();\nif(!(str.valueOf() == str.toString()))\n $ERROR('#1: str = new String(),str.valueOf() == str.toString()');\n\n//CHECK#2\nstr = new String(true);\nif(!(str.valueOf() == str.toString()))\n $ERROR('#2: str = new String(true),str.valueOf() == str.toString()');\n\n//CHECK#3\nstr = new String(false);\nif(!(str.valueOf() == str.toString()))\n $ERROR('#3: str = new String(false),str.valueOf() == str.toString()');\n\n//CHECK#4\nstr = new String(Math.PI);\nif(!(str.valueOf() == str.toString()))\n $ERROR('#4: str = new String(Math.PI),str.valueOf() == str.toString()');\n", + "id": "S15.5.4.2_A3_T1" + }, + { + "section": "15.5.4.2", + "description": "Checking String.prototype.toString.length property", + "test": "//CHECK#1\nif (String.prototype.toString.hasOwnProperty('length')!==true){\n $ERROR('#1: String.prototype.toString.hasOwnProperty(\\'length\\')===true. Actual: '+String.prototype.toString.hasOwnProperty('length')); \n}\nelse{\n//CHECK#2\nif (String.prototype.toString.length!==0)\n $ERROR('#2: String.prototype.toString.length===0. Actual: String.prototype.toString.length==='+String.prototype.toString.length); \n}\n", + "id": "S15.5.4.2_A4_T1" + }, + { + "section": "15.5.4.3", + "description": "Create String object as new String(1) and check it`s valueOf()", + "test": "var __string__obj = new String(1);\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#\nif (__string__obj.valueOf() !== \"\"+1) {\n $ERROR('#1: __string__obj = new String(1); __string__obj.valueOf() === \"\"+1. Actual: __string__obj.valueOf() ==='+__string__obj.valueOf() ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.3_A1_T1" + }, + { + "section": "15.5.4.3", + "description": "Create String object as new String(true) and check it`s valueOf()", + "test": "var __string__obj = new String(true);\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#\nif (__string__obj.valueOf() !== \"\"+true) {\n $ERROR('#1: __string__obj = new String(true); __string__obj.valueOf() === \"\"+true. Actual: __string__obj.valueOf() ==='+__string__obj.valueOf() ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.3_A1_T2" + }, + { + "section": "15.5.4.3", + "description": "Create String object as new String(string) and check it`s valueOf()", + "test": "var __string__obj = new String(\"metal\");\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#\nif (__string__obj.valueOf() !== \"metal\") {\n $ERROR('#1: __string__obj = new String(\"metal\"); __string__obj.valueOf() === \"metal\". Actual: __string__obj.valueOf() ==='+__string__obj.valueOf() ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.3_A1_T3" + }, + { + "section": "15.5.4.3", + "description": "Create String object as new String(function(){}()) and check it`s valueOf()", + "test": "var __string__obj = new String(function(){}());\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#\nif (__string__obj.valueOf() !== \"undefined\") {\n $ERROR('#1: __string__obj = new String(function(){}()); __string__obj.valueOf() === \"undefined\". Actual: __string__obj.valueOf() ==='+__string__obj.valueOf() ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.3_A1_T4" + }, + { + "section": "15.5.4.3", + "description": "Checking if creating variable String.prototype.valueOf fails", + "test": "var __valueOf = String.prototype.valueOf;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (typeof __valueOf !== \"function\") {\n $ERROR('#1: __valueOf = String.prototype.valueOf; typeof __valueOf === \"function\". Actual: typeof __valueOf ==='+typeof __valueOf ); \n}\n\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\ntry {\n var x = __valueOf();\n $FAIL('#2: \"__valueOf = String.prototype.valueOf; var x = __valueOf()\" lead to throwing exception');\n} catch (e) {\n if (!(e instanceof TypeError)) {\n $ERROR('#2.1: Exception is instance of TypeError. Actual: exception is '+e);\n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.3_A2_T1" + }, + { + "section": "15.5.4.3", + "description": "Checking if creating the object String.prototype.valueOf fails", + "test": "var __obj={valueOf : String.prototype.valueOf};\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (typeof __obj[\"valueOf\"] !== \"function\") {\n $ERROR('#1: var __obj={valueOf : String.prototype.valueOf}; typeof __obj[\"valueOf\"] === \"function\". Actual: typeof __obj[\"valueOf\"] ==='+typeof __obj[\"valueOf\"] ); \n}\n\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\ntry {\n var x = (__obj == 1);\n $FAIL('#2: \"var __obj={valueOf : String.prototype.valueOf}; var x = (__obj == 1)\" lead to throwing exception');\n} catch (e) {\n if (!(e instanceof TypeError)) {\n $ERROR('#2.1: Exception is instance of TypeError. Actual: exception is '+e);\n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4.3_A2_T2" + }, + { + "section": "15.5.4", + "description": "first we delete String.prototype.toString cause it overrides Object prototype toString.\nObject.prototype.toString returns [object+[[class]]+]", + "test": "delete String.prototype.toString;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (String.prototype.toString() !== \"[object \"+\"String\"+\"]\") {\n $ERROR('#1: delete String.prototype.toString; String.prototype.toString() === \"[object \"+\"String\"+\"]\". Actual: String.prototype.toString() ==='+String.prototype.toString() ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4_A1" + }, + { + "section": "15.5.4", + "description": "Checking String.prototype", + "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (String.prototype !=\"\") {\n $ERROR('#1: String.prototype ==\"\". Actual: String.prototype =='+String.prototype ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4_A2" + }, + { + "section": "15.5.4, 15.2.3.1", + "description": "Checking Object.prototype.isPrototypeOf(String.prototype)", + "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (!(Object.prototype.isPrototypeOf(String.prototype))) {\n $ERROR('#1: Object.prototype.isPrototypeOf(String.prototype) return true. Actual: '+Object.prototype.isPrototypeOf(String.prototype)); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\ndelete String.prototype.toString;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (String.prototype.toString() != \"[object \"+\"String\"+\"]\") {\n $ERROR('#2: delete String.prototype.toString; String.prototype.toString() == \"[object \"+\"String\"+\"]\". Actual: String.prototype.toString() =='+String.prototype.toString() ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n", + "id": "S15.5.4_A3" + } + ] + } +} |