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