initial import
[vuplus_webkit] / Source / JavaScriptCore / tests / mozilla / ecma_2 / String / replace-001.js
1 /**
2  *  File Name:          String/replace-001.js
3  *  ECMA Section:       15.6.4.10
4  *  Description:        Based on ECMA 2 Draft 7 February 1999
5  *
6  *  Author:             christine@netscape.com
7  *  Date:               19 February 1999
8  */
9
10     var SECTION = "String/replace-001.js";
11     var VERSION = "ECMA_2";
12     var TITLE   = "String.prototype.replace( regexp, replaceValue )";
13
14     startTest();
15
16     /*
17      * If regexp is not an object of type RegExp, it is replaced with the
18      * result of the expression new RegExp(regexp).  Let string denote the
19      * result of converting the this value to a string.  String is searched
20      * for the first occurrence of the regular expression pattern regexp if
21      * regexp.global is false, or all occurrences if regexp.global is true.
22      *
23      * The match is performed as in String.prototype.match, including the
24      * update of regexp.lastIndex.  Let m be the number of matched
25      * parenthesized subexpressions as specified in section 15.7.5.3.
26      *
27      * If replaceValue is a function, then for each matched substring, call
28      * the function with the following m + 3 arguments. Argument 1 is the
29      * substring that matched. The next m arguments are all of the matched
30      * subexpressions. Argument m + 2 is the length of the left context, and
31      * argument m + 3 is string.
32      *
33      * The result is a string value derived from the original input by
34      * replacing each matched substring with the corresponding return value
35      * of the function call, converted to a string if need be.
36      *
37      * Otherwise, let newstring denote the result of converting replaceValue
38      * to a string. The result is a string value derived from the original
39      * input string by replacing each matched substring with a string derived
40      * from newstring by replacing characters in newstring by replacement text
41      * as specified in the following table:
42      *
43      * $& The matched substring.
44      * $\91 The portion of string that precedes the matched substring.
45      * $\92 The portion of string that follows the matched substring.
46      * $+ The substring matched by the last parenthesized subexpressions in
47      *      the regular expression.
48      * $n The corresponding matched parenthesized subexpression n, where n
49      * is a single digit 0-9. If there are fewer than n subexpressions, \93$n
50      * is left unchanged.
51      *
52      * Note that the replace function is intentionally generic; it does not
53      * require that its this value be a string object. Therefore, it can be
54      * transferred to other kinds of objects for use as a method.
55      */
56
57
58         testcases[0] = { expect:"PASSED", actual:"PASSED", description:"NO TESTS EXIST" };
59
60         test();