aboutsummaryrefslogtreecommitdiffstats
path: root/website/resources/scripts/testcases2/15.5.4.5_String.prototype.charCodeAt.json
diff options
context:
space:
mode:
Diffstat (limited to 'website/resources/scripts/testcases2/15.5.4.5_String.prototype.charCodeAt.json')
-rw-r--r--website/resources/scripts/testcases2/15.5.4.5_String.prototype.charCodeAt.json128
1 files changed, 128 insertions, 0 deletions
diff --git a/website/resources/scripts/testcases2/15.5.4.5_String.prototype.charCodeAt.json b/website/resources/scripts/testcases2/15.5.4.5_String.prototype.charCodeAt.json
new file mode 100644
index 000000000..9163ec8d6
--- /dev/null
+++ b/website/resources/scripts/testcases2/15.5.4.5_String.prototype.charCodeAt.json
@@ -0,0 +1,128 @@
+{
+ "testCollection": {
+ "name": "15.5.4.5_String.prototype.charCodeAt",
+ "numTests": 20,
+ "tests": [
+ {
+ "section": "15.5.4.5, 13.2",
+ "description": "Checking by using eval",
+ "test": "function __FACTORY(){this.toString = function(){ return \"wizard\";};};\n\n__FACTORY.prototype.charCodeAt = String.prototype.charCodeAt;\n\nvar __instance = new __FACTORY;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nwith(__instance){\n \n if (__instance.charCodeAt(eval(\"1\"),true,null,{})!== 0x69) {\n $ERROR('#1: __instance.charCodeAt(eval(\"1\"),true,null,{})=== 0x69. Actual: __instance.charCodeAt(eval(\"1\"),true,null,{})==='+__instance.charCodeAt(eval(\"1\"),true,null,{})); \n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n",
+ "id": "S15.5.4.5_A1.1"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Checking if varying the String.prototype.charCodeAt.length property fails",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (!(String.prototype.charCodeAt.hasOwnProperty('length'))) {\n $ERROR('#1: String.prototype.charCodeAt.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.charCodeAt.hasOwnProperty('length')); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\nvar __obj = String.prototype.charCodeAt.length;\n\nString.prototype.charCodeAt.length = function(){return \"shifted\";};\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (String.prototype.charCodeAt.length !== __obj) {\n $ERROR('#2: __obj = String.prototype.charCodeAt.length; String.prototype.charCodeAt.length = function(){return \"shifted\";}; String.prototype.charCodeAt.length === __obj. Actual: '+String.prototype.charCodeAt.length ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A10"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Checking String.prototype.charCodeAt.length",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (!(String.prototype.charCodeAt.hasOwnProperty(\"length\"))) {\n $ERROR('#1: String.prototype.charCodeAt.hasOwnProperty(\"length\") return true. Actual: '+String.prototype.charCodeAt.hasOwnProperty(\"length\")); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (String.prototype.charCodeAt.length !== 1) {\n $ERROR('#2: String.prototype.charCodeAt.length === 1. Actual: '+String.prototype.charCodeAt.length ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A11"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "pos is false and true, and instance is object",
+ "test": "var __instance = new Object(42);\n\n__instance.charCodeAt = String.prototype.charCodeAt;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif ((__instance.charCodeAt(false) !== 52)||(__instance.charCodeAt(true) !== 50)) {\n $ERROR('#1: __instance = new Object(42); __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(false) === 52 and __instance.charCodeAt(true) === 50. Actual: __instance.charCodeAt(false) ==='+__instance.charCodeAt(false)+' and __instance.charCodeAt(true) ==='+__instance.charCodeAt(true) ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A1_T1"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Call charCodeAt() function with object argument",
+ "test": "var __obj = {toString:function(){return 1;}}\nvar __str = \"lego\";\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nwith(__str){\n if (charCodeAt(__obj) !== 0x65) {\n $ERROR('#1: var __obj = {toString:function(){return 1;}}; var __str = \"lego\"; charCodeAt(__obj) === 0x65. Actual: charCodeAt(__obj) ==='+charCodeAt(__obj) ); \n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A1_T10"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "pos is equation with false and true, and instance is Boolean object",
+ "test": "var __instance = new Boolean;\n\n__instance.charCodeAt = String.prototype.charCodeAt;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__instance.charCodeAt(false)!==0x66) {\n $ERROR('#1: __instance = new Boolean; __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(false)===0x66. Actual: '+__instance.charCodeAt(false)); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (__instance.charCodeAt(true)!==0x61) {\n $ERROR('#2: __instance = new Boolean; __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(true)===0x61. Actual: '+__instance.charCodeAt(true)); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#3\nif (__instance.charCodeAt(true+1) !== 0x6C) {\n $ERROR('#3: __instance = new Boolean; __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(true+1) === 0x6C. Actual: '+__instance.charCodeAt(true+1) ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A1_T2"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Use numbers and strings as pos",
+ "test": "var charCodeAt = String.prototype.charCodeAt;\n\nif (typeof toString === \"undefined\"){\n var toString = Object.prototype.toString;\n}\n\nvar __class__ = toString();\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (charCodeAt(\"2\") !== 0x62) {\n $ERROR('#1: charCodeAt = String.prototype.charCodeAt; charCodeAt(\"2\") === 0x62. Actual: '+charCodeAt(\"2\") ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (charCodeAt(3) !== 0x6A) {\n $ERROR('#2: charCodeAt = String.prototype.charCodeAt; charCodeAt(3) === 0x6A. Actual: '+charCodeAt(3) ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#3\nif (charCodeAt(\"4\") !== 0x65) {\n $ERROR('#3: charCodeAt = String.prototype.charCodeAt; charCodeAt(\"4\") === 0x65. Actual: '+charCodeAt(\"4\") ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#4\nif (charCodeAt(5) !== 0x63) {\n $ERROR('#4: charCodeAt = String.prototype.charCodeAt; charCodeAt(5) === 0x63. Actual: '+charCodeAt(5) ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#5\nif (charCodeAt(\"6\") !== 0x74) {\n $ERROR('#5: charCodeAt = String.prototype.charCodeAt; charCodeAt(\"6\") === 0x74. Actual: '+charCodeAt(\"6\") ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n",
+ "id": "S15.5.4.5_A1_T3"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Call charCodeAt() function without argument of string object",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\n//since Number() evaluates to 0 charCodeAt() evaluates to charCodeAt(0)\nif (\"smart\".charCodeAt() !== 0x73) {\n $ERROR('#1: \"smart\".charCodeAt() === 0x73. Actual: \"smart\".charCodeAt() ==='+(\"smart\".charCodeAt()) ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A1_T4"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Call charCodeAt() function with null argument of function object",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\n//since ToInteger(null) evaluates to 0 charCodeAt() evaluates to charCodeAt(0)\nif (function(){return \"lego\"}().charCodeAt(null) !== 0x6C) {\n $ERROR('#1: function(){return \"lego\"}().charCodeAt(null) === 0x6C. Actual: '+function(){return \"lego\"}().charCodeAt(null) ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A1_T5"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Call charCodeAt() function with x argument of new String object, where x is undefined variable",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\n//since ToInteger(undefined) evaluates to 0 charCodeAt() evaluates to charCodeAt(0)\nif (new String(\"lego\").charCodeAt(x) !== 0x6C) {\n $ERROR('#1: var x; new String(\"lego\").charCodeAt(x) === 0x6C. Actual: new String(\"lego\").charCodeAt(x) ==='+new String(\"lego\").charCodeAt(x) ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\nvar x;\n",
+ "id": "S15.5.4.5_A1_T6"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Call charCodeAt() function with undefined argument of string object",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\n//since ToInteger(undefined) evaluates to 0 charCodeAt() evaluates to charCodeAt(0)\nif (String(\"lego\").charCodeAt(undefined) !== 0x6C) {\n $ERROR('#1: String(\"lego\").charCodeAt(undefined) === 0x6C. Actual: String(\"lego\").charCodeAt(undefined) ==='+String(\"lego\").charCodeAt(undefined) ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A1_T7"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Call charCodeAt() function with void 0 argument of string object",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\n//since ToInteger(void 0) evaluates to 0 charCodeAt() evaluates to charCodeAt(0)\nif (String(42).charCodeAt(void 0) !== 0x34) {\n $ERROR('#1: String(42).charCodeAt(void 0) === 0x34. Actual: String(42).charCodeAt(void 0) ==='+String(42).charCodeAt(void 0) ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A1_T8"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Call charCodeAt() function with function(){}() argument of string object",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\n//since ToInteger(undefined) evaluates to 0 charCodeAt() evaluates to charCodeAt(0)\nif (new String(42).charCodeAt(function(){}()) !== 0x34) {\n $ERROR('#1: new String(42).charCodeAt(function(){}()) === 0x34. Actual: new String(42).charCodeAt(function(){}()) ==='+new String(42).charCodeAt(function(){}()) ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A1_T9"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Call charCodeAt(pos) with negative pos",
+ "test": "function __FACTORY(){};\n\n__FACTORY.prototype.charCodeAt = String.prototype.charCodeAt;\n\nvar __instance = new __FACTORY;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (!isNaN(__instance.charCodeAt(-1))) {\n $ERROR('#1: function __FACTORY(){}; __FACTORY.prototype.charCodeAt = String.prototype.charCodeAt; __instance = new __FACTORY; isNaN(__instance.charCodeAt(-1)) return true. Actual: '+isNaN(__instance.charCodeAt(-1)));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A2"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "pos is bigger of string length",
+ "test": "var __instance = new String(\"ABC\");\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (!isNaN(__instance.charCodeAt(3))) {\n $ERROR('#1: __instance = new String(\"ABC\"); isNaN(__instance.charCodeAt(3)) return true. Actual: '+isNaN(__instance.charCodeAt(3)));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A3"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Change toString function, it trow exception, and call charCodeAt()",
+ "test": "var __obj={\n valueOf:1,\n toString:function(){throw 'intostring'},\n charCodeAt:String.prototype.charCodeAt\n}\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\ntry {\n var x = __obj.charCodeAt();\n $FAIL('#1: \"var x = __obj.charCodeAt()\" lead to throwing exception');\n} catch (e) {\n if (e !== 'intostring') {\n $ERROR('#1.1: Exception === \\'intostring\\'. Actual: exception ==='+e ); \n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A4"
+ },
+ {
+ "section": "15.5.4.5, 13.2",
+ "description": "Checking String.prototype.charCodeAt.prototype",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (String.prototype.charCodeAt.prototype !== undefined) {\n $ERROR('#1: String.prototype.charCodeAt.prototype === undefined. Actual: '+String.prototype.charCodeAt.prototype ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A6"
+ },
+ {
+ "section": "15.5.4.5, 13.2",
+ "description": "Checking if creating the String.prototype.charCodeAt object fails",
+ "test": "var __FACTORY = String.prototype.charCodeAt;\n\ntry {\n var __instance = new __FACTORY;\n $FAIL('#1: __FACTORY = String.prototype.charCodeAt; \"__instance = new __FACTORY\" lead to throwing exception');\n} catch (e) {}\n",
+ "id": "S15.5.4.5_A7"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Checking if enumerating the String.prototype.charCodeAt.length property fails",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#0\nif (!(String.prototype.charCodeAt.hasOwnProperty('length'))) {\n $FAIL('#0: String.prototype.charCodeAt.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.charCodeAt.hasOwnProperty('length')); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n\n//////////////////////////////////////////////////////////////////////////////\n// CHECK#1\nif (String.prototype.charCodeAt.propertyIsEnumerable('length')) {\n $ERROR('#1: String.prototype.charCodeAt.propertyIsEnumerable(\\'length\\') return false. Actual: '+String.prototype.charCodeAt.propertyIsEnumerable('length'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n// CHECK#2\nvar count=0;\n\nfor (p in String.prototype.charCodeAt){\n if (p===\"length\") count++;\n}\n\nif (count !== 0) {\n $ERROR('#2: count=0; for (p in String.prototype.charCodeAt){if (p===\"length\") count++;} count === 0. Actual: count ==='+count ); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A8"
+ },
+ {
+ "section": "15.5.4.5",
+ "description": "Checking if deleting the String.prototype.charCodeAt.length property fails",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#0\nif (!(String.prototype.charCodeAt.hasOwnProperty('length'))) {\n $FAIL('#0: String.prototype.charCodeAt.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.charCodeAt.hasOwnProperty('length')); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (delete String.prototype.charCodeAt.length) {\n $ERROR('#1: delete String.prototype.charCodeAt.length return false');\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (!(String.prototype.charCodeAt.hasOwnProperty('length'))) {\n $FAIL('#2: delete String.prototype.charCodeAt.length; String.prototype.charCodeAt.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.charCodeAt.hasOwnProperty('length')); \n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.5_A9"
+ }
+ ]
+ }
+}