aboutsummaryrefslogtreecommitdiffstats
path: root/website/resources/scripts/testcases2/15.5.4.17_String.prototype.toLocaleLowerCase.json
blob: 398459e55bc1c76ec02ef29f05529ef54ae3af9b (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
 "testCollection": {
  "name": "15.5.4.17_String.prototype.toLocaleLowerCase",
  "numTests": 21,
  "tests": [
   {
    "section": "15.5.4.17",
    "description": "Checking if varying the String.prototype.toLocaleLowerCase.length property fails",
    "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (!(String.prototype.toLocaleLowerCase.hasOwnProperty('length'))) {\n  $FAIL('#1: String.prototype.toLocaleLowerCase.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.toLocaleLowerCase.hasOwnProperty('length'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n__obj = String.prototype.toLocaleLowerCase.length;\n\nString.prototype.toLocaleLowerCase.length = function(){return \"shifted\";};\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (String.prototype.toLocaleLowerCase.length !== __obj) {\n  $ERROR('#2: __obj = String.prototype.toLocaleLowerCase.length; String.prototype.toLocaleLowerCase.length = function(){return \"shifted\";}; String.prototype.toLocaleLowerCase.length === __obj. Actual: '+String.prototype.toLocaleLowerCase.length );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A10"
   },
   {
    "section": "15.5.4.17",
    "description": "Checking String.prototype.toLocaleLowerCase.length",
    "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (!(String.prototype.toLocaleLowerCase.hasOwnProperty(\"length\"))) {\n  $ERROR('#1: String.prototype.toLocaleLowerCase.hasOwnProperty(\"length\") return true. Actual: '+String.prototype.toLocaleLowerCase.hasOwnProperty(\"length\"));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (String.prototype.toLocaleLowerCase.length !== 0) {\n  $ERROR('#2: String.prototype.toLocaleLowerCase.length === 0. Actual: '+String.prototype.toLocaleLowerCase.length );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A11"
   },
   {
    "section": "15.5.4.17",
    "description": "Arguments is true, and instance is object",
    "test": "var __instance = new Object(true);\n\n__instance.toLocaleLowerCase = String.prototype.toLocaleLowerCase;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__instance.toLocaleLowerCase() !== \"true\") {\n  $ERROR('#1: __instance = new Object(true); __instance.toLocaleLowerCase = String.prototype.toLocaleLowerCase;  __instance.toLocaleLowerCase() === \"true\". Actual: '+__instance.toLocaleLowerCase() );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T1"
   },
   {
    "section": "15.5.4.17",
    "description": "Call toLocaleLowerCase() function of object with overrode toString function",
    "test": "var __obj = {toString:function(){return \"\\u0041B\";}}\n__obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__obj.toLocaleLowerCase() !==\"ab\") {\n  $ERROR('#1: var __obj = {toString:function(){return \"\\u0041B\";}}; __obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase; __obj.toLocaleLowerCase() ===\"ab\". Actual: '+__obj.toLocaleLowerCase() );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T10"
   },
   {
    "section": "15.5.4.17",
    "description": "Override toString function, toString throw exception, then call toLocaleLowerCase() function for this object",
    "test": "var __obj = {toString:function(){throw \"intostr\";}}\n__obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\ntry {\n  var x = __obj.toLocaleLowerCase();\n   \t$FAIL('#1: \"var x = __obj.toLocaleLowerCase()\" lead to throwing exception');\n} catch (e) {\n  if (e!==\"intostr\") {\n    $ERROR('#1.1: Exception === \"intostr\". Actual: '+e);\n  }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T11"
   },
   {
    "section": "15.5.4.17",
    "description": "Override toString and valueOf functions, valueOf throw exception, then call toLocaleLowerCase() function for this object",
    "test": "var __obj = {toString:function(){return {};},valueOf:function(){throw \"intostr\";}}\n__obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\ntry {\n  var x = __obj.toLocaleLowerCase();\n \t$FAIL('#1: \"var x = __obj.toLocaleLowerCase()\" lead to throwing exception');\n} catch (e) {\n  if (e!==\"intostr\") {\n    $ERROR('#1.1: Exception === \"intostr\". Actual: '+e);\n  }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T12"
   },
   {
    "section": "15.5.4.17",
    "description": "Override toString and valueOf functions, then call toLocaleLowerCase() function for this object",
    "test": "var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}\n__obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__obj.toLocaleLowerCase() !==\"1\") {\n  $ERROR('#1: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; __obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase; __obj.toLocaleLowerCase() ===\"1\". Actual: '+__obj.toLocaleLowerCase() );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (__obj.toLocaleLowerCase().length !== 1) {\n  $ERROR('#2: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; __obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase; __obj.toLocaleLowerCase().length === 1. Actual: '+__obj.toLocaleLowerCase().length );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T13"
   },
   {
    "section": "15.5.4.17",
    "description": "Call toLocaleLowerCase() function for RegExp object",
    "test": "var __reg = new RegExp(\"ABC\");\n__reg.toLocaleLowerCase = String.prototype.toLocaleLowerCase;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__reg.toLocaleLowerCase() !== \"/abc/\") {\n  $ERROR('#1: var __reg = new RegExp(\"ABC\"); __reg.toLocaleLowerCase = String.prototype.toLocaleLowerCase; __reg.toLocaleLowerCase() === \"/abc/\". Actual: '+__reg.toLocaleLowerCase() );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T14"
   },
   {
    "section": "15.5.4.17",
    "description": "Instance is Boolean object",
    "test": "var __instance = new Boolean;\n\n__instance.toLocaleLowerCase = String.prototype.toLocaleLowerCase;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__instance.toLocaleLowerCase() !== \"false\") {\n  $ERROR('#1: __instance = new Boolean; __instance.toLocaleLowerCase = String.prototype.toLocaleLowerCase;  __instance.toLocaleLowerCase() === \"false\". Actual: '+__instance.toLocaleLowerCase() );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T2"
   },
   {
    "section": "15.5.4.17",
    "description": "Checking by using eval",
    "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (eval(\"\\\"BJ\\\"\").toLocaleLowerCase() !== \"bj\") {\n  $ERROR('#1: eval(\"\\\\\"BJ\\\\\"\").toLocaleLowerCase() === \"bj\". Actual: '+eval(\"\\\"BJ\\\"\").toLocaleLowerCase() );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T3"
   },
   {
    "section": "15.5.4.17",
    "description": "Call toLocaleLowerCase() function without arguments of string and from empty string",
    "test": "var __lowerCase = \"\".toLocaleLowerCase();\n\nvar __expected = \"\"; \n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__lowerCase.length !== __expected.length) {\n  $ERROR('#1: __lowerCase = \"\".toLocaleLowerCase(); __expected = \"\"; __lowerCase.length === __expected.length. Actual: '+__lowerCase.length );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (__lowerCase.index !== __expected.index) {\n  $ERROR('#2: __lowerCase = \"\".toLocaleLowerCase(); __expected = \"\"; __lowerCase.index === __expected.index. Actual: '+__lowerCase.index );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#3\nif (__lowerCase.input !== __expected.input) {\n  $ERROR('#3: __lowerCase = \"\".toLocaleLowerCase(); __expected = \"\"; __lowerCase.input === __expected.input. Actual: '+__lowerCase.input );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#4\nif (__lowerCase[0]!==__expected[0]) {\n  $ERROR('#4: __lowerCase = \"\".toLocaleLowerCase(); __expected = \"\"; __lowerCase[0]===__expected[0]. Actual: '+__lowerCase[0]);\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T4"
   },
   {
    "section": "15.5.4.17",
    "description": "Call toLocaleLowerCase() function for function call",
    "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\n//since ToString(null) evaluates to \"null\" match(null) evaluates to match(\"null\")\nif (function(){return \"GnulLuNa\"}().toLocaleLowerCase() !== \"gnulluna\") {\n  $ERROR('#1: function(){return \"GnulLuNa\"}().toLocaleLowerCase() === \"gnulluna\". Actual: '+function(){return \"GnulLuNa\"}().toLocaleLowerCase() );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T5"
   },
   {
    "section": "15.5.4.17",
    "description": "Call toLocaleLowerCase() function of Number.NEGATIVE_INFINITY",
    "test": "Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif ((Number.NEGATIVE_INFINITY).toLocaleLowerCase() !== \"-infinity\") {\n  $ERROR('#1: Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase; (Number.NEGATIVE_INFINITY).toLocaleLowerCase() === \"-infinity\". Actual: '+(Number.NEGATIVE_INFINITY).toLocaleLowerCase() );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T6"
   },
   {
    "section": "15.5.4.17",
    "description": "Call toLocaleLowerCase() function of NaN",
    "test": "Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (NaN.toLocaleLowerCase()!== \"nan\") {\n  $ERROR('#1: Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase; NaN.toLocaleLowerCase()=== \"nan\". Actual: '+NaN.toLocaleLowerCase());\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T7"
   },
   {
    "section": "15.5.4.17",
    "description": "Call toLocaleLowerCase() function of Infinity",
    "test": "Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase;\n\nif (Infinity.toLocaleLowerCase()!== \"infinity\") {\n  $ERROR('#1: Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase; Infinity.toLocaleLowerCase()=== \"infinity\". Actual: '+Infinity.toLocaleLowerCase());\n}\n",
    "id": "S15.5.4.17_A1_T8"
   },
   {
    "section": "15.5.4.17",
    "description": "Call toLocaleLowerCase() function of string object",
    "test": "var __obj = {\n    valueOf:function(){},\n    toString:void 0\n};\n\nvar __lowerCase = new String(__obj).toLocaleLowerCase();\n\n\nvar __expected =\"undefined\"; \n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__lowerCase.length !== __expected.length) {\n  $ERROR('#1: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleLowerCase(); __expected =\"undefined\"; __lowerCase.length === __expected.length. Actual: '+__lowerCase.length );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (__lowerCase.index !== __expected.index) {\n  $ERROR('#2: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleLowerCase(); __expected =\"undefined\"; __lowerCase.index === __expected.index. Actual: '+__lowerCase.index );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#3\nif (__lowerCase.input !== __expected.input) {\n  $ERROR('#3: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleLowerCase(); __expected =\"undefined\"; __lowerCase.input === __expected.input. Actual: '+__lowerCase.input );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#4\nfor(var index=0; index<__expected.length; index++) {\n  if (__lowerCase[index]!==__expected[index]) {\n    $ERROR('#4.'+index+': __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleLowerCase(); __expected =\"undefined\"; __lowerCase['+index+']=== '+__expected[index]+'. Actual: '+__lowerCase[index]);\n  }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A1_T9"
   },
   {
    "section": "15.5.4.17",
    "description": "Checking returned result",
    "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (\"Hello, WoRlD!\".toLocaleLowerCase() !== \"hello, world!\") {\n  $ERROR('#1: \"Hello, WoRlD!\".toLocaleLowerCase() === \"hello, world!\". Actual: '+(\"Hello, WoRlD!\".toLocaleLowerCase()) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (\"Hello, WoRlD!\".toLocaleLowerCase() !== String(\"hello, world!\")) {\n  $ERROR('#2: \"Hello, WoRlD!\".toLocaleLowerCase() === String(\"hello, world!\"). Actual: '+(\"Hello, WoRlD!\".toLocaleLowerCase()) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#3\nif (\"Hello, WoRlD!\".toLocaleLowerCase() === new String(\"hello, world!\")) {\n  $ERROR('#3: \"Hello, WoRlD!\".toLocaleLowerCase() !== new String(\"hello, world!\")');\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A2_T1"
   },
   {
    "section": "15.5.4.17, 13.2",
    "description": "Checking String.prototype.toLocaleLowerCase.prototype",
    "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (String.prototype.toLocaleLowerCase.prototype !== undefined) {\n  $ERROR('#1: String.prototype.toLocaleLowerCase.prototype === undefined. Actual: '+String.prototype.toLocaleLowerCase.prototype );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A6"
   },
   {
    "section": "15.5.4.17, 13.2",
    "description": "Checking if creating the String.prototype.toLocaleLowerCase object fails",
    "test": "var __FACTORY = String.prototype.toLocaleLowerCase;\n\ntry {\n  var __instance = new __FACTORY;\n  $FAIL('#1: var __FACTORY = String.prototype.toLocaleLowerCase; \"__instance = new __FACTORY\" lead to throwing exception');\n} catch (e) {\n  if ((e instanceof TypeError) !== true) {\n    $ERROR('#1.1: var __FACTORY = String.prototype.toLocaleLowerCase; \"var __instance = new __FACTORY\" throw a TypeError. Actual: ' + (e));  \n  }\n  $PRINT(e);\n}\n",
    "id": "S15.5.4.17_A7"
   },
   {
    "section": "15.5.4.17",
    "description": "Checking if enumerating the String.prototype.toLocaleLowerCase.length property fails",
    "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#0\nif (!(String.prototype.toLocaleLowerCase.hasOwnProperty('length'))) {\n  $FAIL('#0: String.prototype.toLocaleLowerCase.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.toLocaleLowerCase.hasOwnProperty('length'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n\n//////////////////////////////////////////////////////////////////////////////\n// CHECK#1\nif (String.prototype.toLocaleLowerCase.propertyIsEnumerable('length')) {\n  $ERROR('#1: String.prototype.toLocaleLowerCase.propertyIsEnumerable(\\'length\\') return false');\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n// CHECK#2\nvar count=0;\n\nfor (var p in String.prototype.toLocaleLowerCase){\n  if (p===\"length\") count++;\n}\n\nif (count !== 0) {\n  $ERROR('#2: count=0; for (p in String.prototype.toLocaleLowerCase){if (p===\"length\") count++;}; count === 0. Actual: '+count );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A8"
   },
   {
    "section": "15.5.4.17",
    "description": "Checking if deleting the String.prototype.toLocaleLowerCase.length property fails",
    "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#0\nif (!(String.prototype.toLocaleLowerCase.hasOwnProperty('length'))) {\n  $FAIL('#0: String.prototype.toLocaleLowerCase.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.toLocaleLowerCase.hasOwnProperty('length'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (delete String.prototype.toLocaleLowerCase.length) {\n  $ERROR('#1: delete String.prototype.toLocaleLowerCase.length return false');\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (!(String.prototype.toLocaleLowerCase.hasOwnProperty('length'))) {\n  $FAIL('#2: delete String.prototype.toLocaleLowerCase.length; String.prototype.toLocaleLowerCase.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.toLocaleLowerCase.hasOwnProperty('length'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
    "id": "S15.5.4.17_A9"
   }
  ]
 }
}