aboutsummaryrefslogtreecommitdiffstats
path: root/website/resources/scripts/testcases2/15.5.4.11_String.prototype.replace.json
diff options
context:
space:
mode:
Diffstat (limited to 'website/resources/scripts/testcases2/15.5.4.11_String.prototype.replace.json')
-rw-r--r--website/resources/scripts/testcases2/15.5.4.11_String.prototype.replace.json260
1 files changed, 260 insertions, 0 deletions
diff --git a/website/resources/scripts/testcases2/15.5.4.11_String.prototype.replace.json b/website/resources/scripts/testcases2/15.5.4.11_String.prototype.replace.json
new file mode 100644
index 000000000..d6b0e451a
--- /dev/null
+++ b/website/resources/scripts/testcases2/15.5.4.11_String.prototype.replace.json
@@ -0,0 +1,260 @@
+{
+ "testCollection": {
+ "name": "15.5.4.11_String.prototype.replace",
+ "numTests": 42,
+ "tests": [
+ {
+ "section": "15.5.4.11",
+ "description": "Checking if varying the String.prototype.replace.length property fails",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (!(String.prototype.replace.hasOwnProperty('length'))) {\n $FAIL('#1: String.prototype.replace.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.replace.hasOwnProperty('length'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\nvar __obj = String.prototype.replace.length;\n\nString.prototype.replace.length = function(){return \"shifted\";};\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (String.prototype.replace.length !== __obj) {\n $ERROR('#2: __obj = String.prototype.replace.length; String.prototype.replace.length = function(){return \"shifted\";}; String.prototype.replace.length === __obj. Actual: '+String.prototype.replace.length );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A10"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Checking String.prototype.replace.length",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (!(String.prototype.replace.hasOwnProperty(\"length\"))) {\n $ERROR('#1: String.prototype.replace.hasOwnProperty(\"length\") return true. Actual: '+String.prototype.replace.hasOwnProperty(\"length\"));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (String.prototype.replace.length !== 2) {\n $ERROR('#2: String.prototype.replace.length === 2. Actual: '+String.prototype.replace.length );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A11"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "replaceValue tests that its this value is undefined",
+ "test": "var global = this;\n'x'.replace(/x/, function() {\n \"use strict\";\n\n if (this === global) {\n $FAIL('#1: String replace leaks global');\n }\n if (this !== undefined) {\n $FAIL('#2: replaceValue should be called with this===undefined. ' +\n 'Actual: ' + this);\n }\n return 'y';\n});\n",
+ "id": "S15.5.4.11_A12"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Arguments are true and 1, and instance is object",
+ "test": "var __instance = new Object(true);\n\n__instance.replace = String.prototype.replace;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__instance.replace(true, 1) !== \"1\") {\n $ERROR('#1: __instance = new Object(true); __instance.replace = String.prototype.replace; __instance.replace(true, 1) === \"1\". Actual: '+__instance.replace(true, 1) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A1_T1"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Call replace (searchValue, replaceValue) function with object and function arguments of string. Object have overrided toString function",
+ "test": "var __obj = {toString:function(){return \"\\u0041B\";}};\n\nvar __str = \"ABB\\u0041BABAB\";\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nwith(__str){\n if (replace(__obj, function(){return x;}) !== \"undefinedBABABAB\") {\n $ERROR('#1: var x; var __obj = {toString:function(){return \"\\u0041B\";}}; var __str = \"ABB\\u0041BABAB\"; replace(__obj, function(){return x;}) === \"undefinedBABABAB\". Actual: '+replace(__obj, function(){return x;}) );\n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\nvar x;\n",
+ "id": "S15.5.4.11_A1_T10"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Call replace (searchValue, replaceValue) function with objects arguments of string object. Objects have overrided toString function, that throw exception",
+ "test": "var __obj = {toString:function(){throw \"insearchValue\";}};\nvar __obj2 = {toString:function(){throw \"inreplaceValue\";}};\nvar __str = {str__:\"ABB\\u0041BABAB\"};\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nwith(__str){\n with(str__){\n try {\n var x = replace(__obj,__obj2);\n $FAIL('#1: \"var x = replace(__obj,__obj2)\" lead to throwing exception');\n } catch (e) {\n if (e!==\"insearchValue\") {\n $ERROR('#1.1: Exception === \"insearchValue\". Actual: '+e);\n }\n }\n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A1_T11"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Call replace (searchValue, replaceValue) function with objects arguments of String object.\nFirst objects have overrided toString and valueOf functions, valueOf throw exception.\nSecond objects have overrided toString function, that throw exception",
+ "test": "var __obj = {toString:function(){return {};}, valueOf:function(){throw \"insearchValue\";}};\nvar __obj2 = {toString:function(){throw \"inreplaceValue\";}};\nvar __str = new String(\"ABB\\u0041BABAB\");\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nwith(__str){\n try {\n var x = replace(__obj, __obj2);\n $FAIL('#1: \"var x = replace(__obj,__obj2)\" lead to throwing exception');\n } catch (e) {\n if (e!==\"insearchValue\") {\n $ERROR('#1.1: Exception === \"insearchValue\". Actual: '+e);\n }\n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A1_T12"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Call replace (searchValue, replaceValue) function with objects arguments of string.\nFirst objects have overrided toString and valueOf functions.\nSecond objects have overrided toString function, that throw exception",
+ "test": "var __obj = {toString:function(){return {};}, valueOf:function(){return 1;}};\nvar __obj2 = {toString:function(){throw \"inreplaceValue\";}};\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\ntry {\n var x = \"ABB\\u0041BABAB\\u0031BBAA\".replace(__obj, __obj2);\n $FAIL('#1: var x = \"ABB\\\\u0041BABAB\\\\u0031BBAA\".replace(__obj,__obj2) lead to throwing exception');\n} catch (e) {\n if (e!==\"inreplaceValue\") {\n $ERROR('#1.1: Exception === \"inreplaceValue\". Actual: '+e);\n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n",
+ "id": "S15.5.4.11_A1_T13"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Instance is string, searchValue is regular expression",
+ "test": "var __reg = new RegExp(\"77\");\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (\"ABB\\u0041BABAB\\u0037\\u0037BBAA\".replace(__reg, 1) !== \"ABBABABAB\\u0031BBAA\") {\n $ERROR('#1: var __reg = new RegExp(\"77\"); \"ABB\\\\u0041BABAB\\\\u0037\\\\u0037BBAA\".replace(__reg, 1) === \"ABBABABAB\\\\u0031BBAA\". Actual: '+(\"ABB\\u0041BABAB\\u0037\\u0037BBAA\".replace(__reg, 1)) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A1_T14"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Instance is Object, searchValue is regular expression",
+ "test": "var __obj = {toString:function(){return /77/}};\n\nvar __instance = new Object(1100.00777001);\n\nObject.prototype.replace = String.prototype.replace;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\ntry {\n var x = __instance.replace(__obj, 1) === \"1100.0017001\";\n $FAIL('#1.0: x = __instance.replace(__obj, 1) === \"1100.0017001\" lead to throwing exception');\n} catch (e) {\n if (!(e instanceof TypeError)) {\n $ERROR('#1.1: Exception is instance of TypeError. Actual: '+e);\n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A1_T15"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Instance is Number, searchValue is regular expression",
+ "test": "var __re = /77/;\n\nvar __instance = new Number(1100.00777001);\n\nNumber.prototype.replace = String.prototype.replace;\n\nvar __obj = {toString:function(){return function(a1,a2,a3){return a2+\"z\"};}}\n//__obj = function(a1,a2,a3){return a2+\"z\"};\n\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\ntry {\n var x = __instance.replace(__re, __obj) === \"1100.007z7001\";\n $FAIL('#1.0: x = __instance.replace(__obj, 1) === \"1100.007z7001\" lead to throwing exception');\n} catch (e) {\n if (!(e instanceof TypeError)) {\n $ERROR('#1.1: Exception is instance of TypeError. Actual: '+e);\n }\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A1_T16"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Instance is String object, searchValue is regular expression",
+ "test": "var __re = new RegExp(x,\"g\");\n\nvar __instance = String(\"asdf\");\n\nvar __str = \"1\";\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__instance.replace(__re, __str) !== \"1a1s1d1f1\") {\n $ERROR('#1: var x; var __re = new RegExp(x,\"g\"); __instance = String(\"asdf\"); __str = \"1\"; __instance.replace(__re, __str) === \"1a1s1d1f1\". Actual: '+__instance.replace(__re, __str) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\nvar x;\n",
+ "id": "S15.5.4.11_A1_T17"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Argument is function that return boolean, and instance is Boolean object",
+ "test": "var __instance = new Boolean;\n\n__instance.replace = String.prototype.replace;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__instance.replace(function(){return false;}(),x) !== \"undefined\") {\n $ERROR('#1: var x; __instance = new Boolean; __instance.replace = String.prototype.replace; __instance.replace(function(){return false;}(),x) === \"undefined\". Actual: '+__instance.replace(function(){return false;}(),x) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\nvar x;\n",
+ "id": "S15.5.4.11_A1_T2"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Checking by using eval",
+ "test": "replace = String.prototype.replace;\n\nif (typeof toString === \"undefined\"){\n toString = Object.prototype.toString;\n}\n\n__class__ = toString();\n__toggle = 1;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\n__replaced = replace(eval(\"\\\"b\\\"\"),\"^\");\n\n__golden = \"\";\nfor(var i=0; i<__class__.length; i++) {\n if ((__class__.charAt(i)===\"b\")&&(__toggle)) {\n __golden+=\"^\";\n __toggle = 0;\n } else {\n __golden+=__class__.charAt(i);\n }\n\n}\nif (__replaced !==__golden) {\n $ERROR('#1: __replaced ===__golden. Actual: '+__replaced );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A1_T3"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": ": Call replace (searchValue, replaceValue) function with null and function(a1,a2,a3){return a2+\"\";} arguments of function object;",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (function(){return \"gnulluna\"}().replace(null,function(a1,a2,a3){return a2+\"\";}) !== \"g1una\") {\n $ERROR('#1: function(){return \"gnulluna\"}().replace(null,function(a1,a2,a3){return a2+\"\";}) === \"g1una\". Actual: '+function(){return \"gnulluna\"}().replace(null,function(a1,a2,a3){return a2+\"\";}) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A1_T4"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Call replace (searchValue, replaceValue) function with null and Function() arguments of function object",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (function(){return \"gnulluna\"}().replace(null, Function()) !== \"gundefineduna\") {\n $ERROR('#1: function(){return \"gnulluna\"}().replace(null, Function()) === \"gundefineduna\". Actual: '+function(){return \"gnulluna\"}().replace(null, Function()) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A1_T5"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": ": Call replace (searchValue, replaceValue) function with x and Function(\"return arguments[1]+42;\") arguments of new String object. x is undefined variable;",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (new String(\"undefined\").replace(x,Function(\"return arguments[1]+42;\")) !== \"42\") {\n $ERROR('#1: var x; new String(\"undefined\").replace(x,Function(\"return arguments[1]+42;\")) === \"42\". Actual: '+new String(\"undefined\").replace(x,Function(\"return arguments[1]+42;\")) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\nvar x;\n",
+ "id": "S15.5.4.11_A1_T6"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Call replace (searchValue, replaceValue) function with string and undefined arguments of String object",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (String(void 0).replace(\"e\",undefined) !== \"undundefinedfined\") {\n $ERROR('#1: String(void 0).replace(\"e\",undefined) === \"undundefinedfined\". Actual: '+String(void 0).replace(\"e\",undefined) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A1_T7"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Call replace (searchValue, replaceValue) function with regular expression and void 0 arguments of String object",
+ "test": "var __obj = {toString:function(){}};\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (String(__obj).replace(/e/g,void 0) !== \"undundefinedfinundefinedd\") {\n $ERROR('#1: __obj = {toString:function(){}}; String(__obj).replace(/e/g,void 0) === \"undundefinedfinundefinedd\". Actual: '+String(__obj).replace(/e/g,void 0) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A1_T8"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Call replace (searchValue, replaceValue) function with functions arguments of new String object",
+ "test": "var __obj = {\n valueOf:function(){},\n toString:void 0\n};\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (new String(__obj).replace(function(){}(),__func) !== \"undefined0undefined\") {\n $ERROR('#1: __obj = {valueOf:function(){}, toString:void 0}; function __func(a1,a2,a3){return a1+a2+a3;}; new String(__obj).replace(function(){}(),__func) === \"undefined0undefined\". Actual: '+new String(__obj).replace(function(){}(),__func) );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\nfunction __func(a1,a2,a3){return a1+a2+a3;};\n",
+ "id": "S15.5.4.11_A1_T9"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Don`t use $ in replaceValue, searchValue is regular expression /sh/g",
+ "test": "var __str = 'She sells seashells by the seashore.';\nvar __re = /sh/g;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re,'sch')!=='She sells seaschells by the seaschore.') {\n $ERROR('#1: var __str = \\'She sells seashells by the seashore.\\'; var __re = /sh/g; __str.replace(__re,\\'sch\\')===\\'She sells seaschells by the seaschore.\\'. Actual: '+__str.replace(__re,'sch'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A2_T1"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Use $' in replaceValue, searchValue is regular expression /sh/",
+ "test": "var __str = 'She sells seashells by the seashore.';\nvar __re = /sh/;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re, \"$'\" + 'sch')!=='She sells seaells by the seashore.schells by the seashore.') {\n $ERROR('#1: var __str = \\'She sells seashells by the seashore.\\'; var __re = /sh/; __str.replace(__re, \"$\\'\" + \\'sch\\')===\\'She sells seaells by the seashore.schells by the seashore.\\'. Actual: '+__str.replace(__re, \"$'\" + 'sch'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A2_T10"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Use $$ in replaceValue, searchValue is regular expression /sh/g",
+ "test": "var __str = 'She sells seashells by the seashore.';\nvar __re = /sh/g;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re,\"$$\" + 'sch')!=='She sells sea$schells by the sea$schore.') {\n $ERROR('#1: var __str = \\'She sells seashells by the seashore.\\'; var __re = /sh/g; __str.replace(__re,\"$$\" + \\'sch\\')===\\'She sells sea$schells by the sea$schore.\\'. Actual: '+__str.replace(__re,\"$$\" + 'sch'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A2_T2"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Use $& in replaceValue, searchValue is regular expression /sh/g",
+ "test": "var __str = 'She sells seashells by the seashore.';\nvar __re = /sh/g;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re,\"$&\" + 'sch')!=='She sells seashschells by the seashschore.') {\n $ERROR('#1: var __str = \\'She sells seashells by the seashore.\\'; var __re = /sh/g; __str.replace(__re,\"$&\" + \\'sch\\')===\\'She sells seashschells by the seashschore.\\'. Actual: '+__str.replace(__re,\"$&\" + 'sch'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A2_T3"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Use $` in replaceValue, searchValue is regular expression /sh/g",
+ "test": "var __str = 'She sells seashells by the seashore.';\nvar __re = /sh/g;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re, \"$`\" + 'sch')!=='She sells seaShe sells seaschells by the seaShe sells seashells by the seaschore.') {\n $ERROR('#1: var __str = \\'She sells seashells by the seashore.\\'; var __re = /sh/g; __str.replace(__re, \"$`\" + \\'sch\\')===\\'She sells seaShe sells seaschells by the seaShe sells seashells by the seaschore.\\'. Actual: '+__str.replace(__re, \"$`\" + 'sch'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A2_T4"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Use $' in replaceValue, searchValue is regular expression /sh/g",
+ "test": "var __str = 'She sells seashells by the seashore.';\nvar __re = /sh/g;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re, \"$'\" + 'sch')!=='She sells seaells by the seashore.schells by the seaore.schore.') {\n $ERROR('#1: var __str = \\'She sells seashells by the seashore.\\'; var __re = /sh/g; __str.replace(__re, \"$\\'\" + \\'sch\\')===\\'She sells seaells by the seashore.schells by the seaore.schore.\\'. Actual: '+__str.replace(__re, \"$'\" + 'sch'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A2_T5"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Don`t use $ in replaceValue, searchValue is regular expression /sh/",
+ "test": "var __str = 'She sells seashells by the seashore.';\nvar __re = /sh/;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re, 'sch')!=='She sells seaschells by the seashore.') {\n $ERROR('#1: var __str = \\'She sells seashells by the seashore.\\'; var __re = /sh/; __str.replace(__re, \\'sch\\')===\\'She sells seaschells by the seashore.\\'. Actual: '+__str.replace(__re, 'sch'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A2_T6"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Use $$ in replaceValue, searchValue is regular expression /sh/",
+ "test": "var __str = 'She sells seashells by the seashore.';\nvar __re = /sh/;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re, \"$$\" + 'sch')!=='She sells sea$schells by the seashore.') {\n $ERROR('#1: var __str = \\'She sells seashells by the seashore.\\'; var __re = /sh/; __str.replace(__re, \"$$\" + \\'sch\\')===\\'She sells sea$schells by the seashore.\\'. Actual: '+__str.replace(__re, \"$$\" + 'sch'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A2_T7"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Use $& in replaceValue, searchValue is regular expression /sh/",
+ "test": "var __str = 'She sells seashells by the seashore.';\nvar __re = /sh/;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re, \"$&\" + 'sch')!=='She sells seashschells by the seashore.') {\n $ERROR('#1: var __str = \\'She sells seashells by the seashore.\\'; var __re = /sh/; __str.replace(__re, \"$&\" + \\'sch\\')===\\'She sells seashschells by the seashore.\\'. Actual: '+__str.replace(__re, \"$&\" + 'sch'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A2_T8"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Use $` in replaceValue, searchValue is regular expression /sh/",
+ "test": "var __str = 'She sells seashells by the seashore.';\nvar __re = /sh/;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re, \"$`\" + 'sch')!=='She sells seaShe sells seaschells by the seashore.') {\n $ERROR('#1: var __str = \\'She sells seashells by the seashore.\\'; var __re = /sh/; __str.replace(__re, \"$`\" + \\'sch\\')===\\'She sells seaShe sells seaschells by the seashore.\\'. Actual: '+__str.replace(__re, \"$`\" + 'sch'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A2_T9"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "replaceValue is \"$11\" + 15",
+ "test": "var __str = 'uid=31';\nvar __re = /(uid=)(\\d+)/;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re, \"$11\" + 15)!=='uid=115') {\n $ERROR('#1: var __str = \\'uid=31\\'; var __re = /(uid=)(\\d+)/; __str.replace(__re, \"$11\" + 15)===\\'uid=115\\'. Actual: '+__str.replace(__re, \"$11\" + 15));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A3_T1"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "replaceValue is \"$11\" + '15'",
+ "test": "var __str = 'uid=31';\nvar __re = /(uid=)(\\d+)/;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re, \"$11\" + '15')!=='uid=115') {\n $ERROR('#1: var __str = \\'uid=31\\'; var __re = /(uid=)(\\d+)/; __str.replace(__re, \"$11\" + \\'15\\')===\\'uid=115\\'. Actual: '+__str.replace(__re, \"$11\" + '15'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A3_T2"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "replaceValue is \"$11\" + 'A15'",
+ "test": "var __str = 'uid=31';\nvar __re = /(uid=)(\\d+)/;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__re, \"$11\" + 'A15')!=='uid=1A15' ) {\n $ERROR('#1: var __str = \\'uid=31\\'; var __re = /(uid=)(\\d+)/; __str.replace(__re, \"$11\" + \\'A15\\')===\\'uid=1A15\\' . Actual: '+__str.replace(__re, \"$11\" + 'A15'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A3_T3"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "searchValue is /([a-z]+)([0-9]+)/",
+ "test": "var __str = \"abc12 def34\";\nvar __pattern = /([a-z]+)([0-9]+)/;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__pattern, __replFN)!=='12abc def34') {\n $ERROR('#1: var __str = \"abc12 def34\"; var __pattern = /([a-z]+)([0-9]+)/; function __replFN() {return arguments[2] + arguments[1];}; __str.replace(__pattern, __replFN)===\\'12abc def34\\'. Actual: '+__str.replace(__pattern, __replFN));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n \nfunction __replFN() {\n return arguments[2] + arguments[1];\n}\n",
+ "id": "S15.5.4.11_A4_T1"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "searchValue is /([a-z]+)([0-9]+)/g",
+ "test": "var __str = \"abc12 def34\";\nvar __pattern = /([a-z]+)([0-9]+)/g;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__pattern, __replFN)!=='12abc 34def') {\n $ERROR('#1: var __str = \"abc12 def34\"; var __pattern = /([a-z]+)([0-9]+)/g; function __replFN() {return arguments[2] + arguments[1];}; __str.replace(__pattern, __replFN)===\\'12abc 34def\\'. Actual: '+__str.replace(__pattern, __replFN));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n \nfunction __replFN() {\n return arguments[2] + arguments[1];\n}\n",
+ "id": "S15.5.4.11_A4_T2"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "searchValue is /([a-z]+)([0-9]+)/i",
+ "test": "var __str = \"aBc12 def34\";\nvar __pattern = /([a-z]+)([0-9]+)/i;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__pattern, __replFN)!=='12aBc def34') {\n $ERROR('#1: var __str = \"aBc12 def34\"; var __pattern = /([a-z]+)([0-9]+)/i; function __replFN() {return arguments[2] + arguments[1];}; __str.replace(__pattern, __replFN)===\\'12aBc def34\\'. Actual: '+__str.replace(__pattern, __replFN));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n \nfunction __replFN() {\n return arguments[2] + arguments[1];\n}\n",
+ "id": "S15.5.4.11_A4_T3"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "searchValue is /([a-z]+)([0-9]+)/ig",
+ "test": "var __str = \"aBc12 dEf34\";\nvar __pattern = /([a-z]+)([0-9]+)/ig;\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__pattern, __replFN)!=='12aBc 34dEf') {\n $ERROR('#1: var __str = \"aBc12 dEf34\"; var __pattern = /([a-z]+)([0-9]+)/ig; function __replFN() {return arguments[2] + arguments[1];}; __str.replace(__pattern, __replFN)===\\'12aBc 34dEf\\'. Actual: '+__str.replace(__pattern, __replFN));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n \nfunction __replFN() {\n return arguments[2] + arguments[1];\n}\n",
+ "id": "S15.5.4.11_A4_T4"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "searchValue is regexp /^(a+)\\1*,\\1+$/ and replaceValue is \"$1\"",
+ "test": "var __str = \"aaaaaaaaaa,aaaaaaaaaaaaaaa\";\nvar __pattern = /^(a+)\\1*,\\1+$/;\nvar __repl = \"$1\";\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (__str.replace(__pattern, __repl)!=='aaaaa') {\n $ERROR('#1: var __str = \"aaaaaaaaaa,aaaaaaaaaaaaaaa\"; var __pattern = /^(a+)\\1*,\\1+$/; var __repl = \"$1\"; __str.replace(__pattern, __repl)===\\'aaaaa\\'. Actual: '+__str.replace(__pattern, __repl));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A5_T1"
+ },
+ {
+ "section": "15.5.4.11, 13.2",
+ "description": ": Checking String.prototype.replace.prototype;",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (String.prototype.replace.prototype !== undefined) {\n $ERROR('#1: String.prototype.replace.prototype === undefined. Actual: '+String.prototype.replace.prototype );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A6"
+ },
+ {
+ "section": "15.5.4.11, 13.2",
+ "description": "Checking if creating the String.prototype.replace object fails",
+ "test": "var __FACTORY = String.prototype.replace;\n\ntry {\n var __instance = new __FACTORY;\n $FAIL('#1: __FACTORY = String.prototype.replace; \"__instance = new __FACTORY\" lead to throwing exception');\n} catch (e) {}\n",
+ "id": "S15.5.4.11_A7"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Checking if enumerating the String.prototype.replace.length property fails",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#0\nif (!(String.prototype.replace.hasOwnProperty('length'))) {\n $FAIL('#0: String.prototype.replace.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.replace.hasOwnProperty('length'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n\n//////////////////////////////////////////////////////////////////////////////\n// CHECK#1\nif (String.prototype.replace.propertyIsEnumerable('length')) {\n $ERROR('#1: String.prototype.replace.propertyIsEnumerable(\\'length\\') return false');\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n// CHECK#2\ncount=0;\n\nfor (p in String.prototype.replace){\n if (p===\"length\") count++;\n}\n\nif (count !== 0) {\n $ERROR('#2: count=0; for (p in String.prototype.replace){if (p===\"length\") count++;} count === 0. Actual: '+count );\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A8"
+ },
+ {
+ "section": "15.5.4.11",
+ "description": "Checking if deleting the String.prototype.replace.length property fails",
+ "test": "//////////////////////////////////////////////////////////////////////////////\n//CHECK#0\nif (!(String.prototype.replace.hasOwnProperty('length'))) {\n $FAIL('#0: String.prototype.replace.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.replace.hasOwnProperty('length'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#1\nif (delete String.prototype.replace.length) {\n $ERROR('#1: delete String.prototype.replace.length return false');\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n\n//////////////////////////////////////////////////////////////////////////////\n//CHECK#2\nif (!(String.prototype.replace.hasOwnProperty('length'))) {\n $FAIL('#2: delete String.prototype.replace.length; String.prototype.replace.hasOwnProperty(\\'length\\') return true. Actual: '+String.prototype.replace.hasOwnProperty('length'));\n}\n//\n//////////////////////////////////////////////////////////////////////////////\n",
+ "id": "S15.5.4.11_A9"
+ }
+ ]
+ }
+}