aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/parserstress/tests/ecma_3/String
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/parserstress/tests/ecma_3/String')
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.11.js532
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js50
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/browser.js0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js116
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/regress-189898.js157
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js68
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js56
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js77
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/regress-83293.js216
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/shell.js1
10 files changed, 1273 insertions, 0 deletions
diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.11.js b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.11.js
new file mode 100644
index 0000000000..ef518bb9e5
--- /dev/null
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.11.js
@@ -0,0 +1,532 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is JavaScript Engine testing utilities.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * <x00000000@freenet.de>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+var gTestfile = '15.5.4.11.js';
+var BUGNUMBER = 392378;
+var summary = '15.5.4.11 - String.prototype.replace';
+var rex, f, a, i;
+
+reportCompare(
+ 2,
+ String.prototype.replace.length,
+ "Section 1"
+);
+
+reportCompare(
+ "321",
+ String.prototype.replace.call(123, "123", "321"),
+ "Section 2"
+);
+
+reportCompare(
+ "ok",
+ "ok".replace(),
+ "Section 3"
+);
+
+reportCompare(
+ "undefined**",
+ "***".replace("*"),
+ "Section 4"
+);
+
+reportCompare(
+ "xnullz",
+ "xyz".replace("y", null),
+ "Section 5"
+);
+
+reportCompare(
+ "x123",
+ "xyz".replace("yz", 123),
+ "Section 6"
+);
+
+reportCompare(
+ "/x/g/x/g/x/g",
+ "xxx".replace(/x/g, /x/g),
+ "Section 7"
+);
+
+reportCompare(
+ "ok",
+ "undefined".replace(undefined, "ok"),
+ "Section 8"
+);
+
+reportCompare(
+ "ok",
+ "null".replace(null, "ok"),
+ "Section 9"
+);
+
+reportCompare(
+ "ok",
+ "123".replace(123, "ok"),
+ "Section 10"
+);
+
+reportCompare(
+ "xzyxyz",
+ "xyzxyz".replace("yz", "zy"),
+ "Section 11"
+);
+
+reportCompare(
+ "ok",
+ "(xyz)".replace("(xyz)", "ok"),
+ "Section 12"
+);
+
+reportCompare(
+ "*$&yzxyz",
+ "xyzxyz".replace("x", "*$$&"),
+ "Section 13"
+);
+
+reportCompare(
+ "xy*z*",
+ "xyz".replace("z", "*$&*"),
+ "Section 14"
+);
+
+reportCompare(
+ "xyxyzxyz",
+ "xyzxyzxyz".replace("zxy", "$`"),
+ "Section 15"
+);
+
+reportCompare(
+ "zxyzxyzzxyz",
+ "xyzxyz".replace("xy", "$'xyz"),
+ "Section 16"
+);
+
+reportCompare(
+ "$",
+ "xyzxyz".replace("xyzxyz", "$"),
+ "Section 17"
+);
+
+reportCompare(
+ "x$0$00xyz",
+ "xyzxyz".replace("yz", "$0$00"),
+ "Section 18"
+);
+
+// Result for $1/$01 .. $99 is implementation-defined if searchValue is no
+// regular expression. $+ is a non-standard Mozilla extension.
+
+reportCompare(
+ "$!$\"$-1$*$#$.$xyz$$",
+ "xyzxyz$$".replace("xyz", "$!$\"$-1$*$#$.$"),
+ "Section 19"
+);
+
+reportCompare(
+ "$$$&$$$&$&",
+ "$$$&".replace("$$", "$$$$$$&$&$$&"),
+ "Section 20"
+);
+
+reportCompare(
+ "yxx",
+ "xxx".replace(/x/, "y"),
+ "Section 21"
+);
+
+reportCompare(
+ "yyy",
+ "xxx".replace(/x/g, "y"),
+ "Section 22"
+);
+
+rex = /x/, rex.lastIndex = 1;
+reportCompare(
+ "yxx1",
+ "xxx".replace(rex, "y") + rex.lastIndex,
+ "Section 23"
+);
+
+rex = /x/g, rex.lastIndex = 1;
+reportCompare(
+ "yyy0",
+ "xxx".replace(rex, "y") + rex.lastIndex,
+ "Section 24"
+);
+
+rex = /y/, rex.lastIndex = 1;
+reportCompare(
+ "xxx1",
+ "xxx".replace(rex, "y") + rex.lastIndex,
+ "Section 25"
+);
+
+rex = /y/g, rex.lastIndex = 1;
+reportCompare(
+ "xxx0",
+ "xxx".replace(rex, "y") + rex.lastIndex,
+ "Section 26"
+);
+
+rex = /x?/, rex.lastIndex = 1;
+reportCompare(
+ "(x)xx1",
+ "xxx".replace(rex, "($&)") + rex.lastIndex,
+ "Section 27"
+);
+
+rex = /x?/g, rex.lastIndex = 1;
+reportCompare(
+ "(x)(x)(x)()0",
+ "xxx".replace(rex, "($&)") + rex.lastIndex,
+ "Section 28"
+);
+
+rex = /y?/, rex.lastIndex = 1;
+reportCompare(
+ "()xxx1",
+ "xxx".replace(rex, "($&)") + rex.lastIndex,
+ "Section 29"
+);
+
+rex = /y?/g, rex.lastIndex = 1;
+reportCompare(
+ "()x()x()x()0",
+ "xxx".replace(rex, "($&)") + rex.lastIndex,
+ "Section 30"
+);
+
+reportCompare(
+ "xy$0xy$zxy$zxyz$zxyz",
+ "xyzxyzxyz".replace(/zxy/, "$0$`$$$&$$$'$"),
+ "Section 31"
+);
+
+reportCompare(
+ "xy$0xy$zxy$zxyz$$0xyzxy$zxy$z$z",
+ "xyzxyzxyz".replace(/zxy/g, "$0$`$$$&$$$'$"),
+ "Section 32"
+);
+
+reportCompare(
+ "xyxyxyzxyxyxyz",
+ "xyzxyz".replace(/(((x)(y)()()))()()()(z)/g, "$01$2$3$04$5$6$7$8$09$10"),
+ "Section 33"
+);
+
+rex = RegExp(
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()(y)");
+reportCompare(
+ "x(y)z",
+ "xyz".replace(rex, "($99)"),
+ "Section 34"
+);
+
+rex = RegExp(
+ "()()()()()()()()()(x)" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()(y)");
+reportCompare(
+ "(x0)z",
+ "xyz".replace(rex, "($100)"),
+ "Section 35"
+);
+
+reportCompare(
+ "xyz(XYZ)",
+ "xyzXYZ".replace(/XYZ/g, "($&)"),
+ "Section 36"
+);
+
+reportCompare(
+ "(xyz)(XYZ)",
+ "xyzXYZ".replace(/xYz/gi, "($&)"),
+ "Section 37"
+);
+
+reportCompare(
+ "xyz\rxyz\n",
+ "xyz\rxyz\n".replace(/xyz$/g, "($&)"),
+ "Section 38"
+);
+
+reportCompare(
+ "(xyz)\r(xyz)\n",
+ "xyz\rxyz\n".replace(/xyz$/gm, "($&)"),
+ "Section 39"
+);
+
+f = function () { return "failure" };
+
+reportCompare(
+ "ok",
+ "ok".replace("x", f),
+ "Section 40"
+);
+
+reportCompare(
+ "ok",
+ "ok".replace(/(?=k)ok/, f),
+ "Section 41"
+);
+
+reportCompare(
+ "ok",
+ "ok".replace(/(?!)ok/, f),
+ "Section 42"
+);
+
+reportCompare(
+ "ok",
+ "ok".replace(/ok(?!$)/, f),
+ "Section 43"
+);
+
+f = function (sub, offs, str) {
+ return ["", sub, typeof sub, offs, typeof offs, str, typeof str, ""]
+ .join("|");
+};
+
+reportCompare(
+ "x|y|string|1|number|xyz|string|z",
+ "xyz".replace("y", f),
+ "Section 44"
+);
+
+reportCompare(
+ "x|(y)|string|1|number|x(y)z|string|z",
+ "x(y)z".replace("(y)", f),
+ "Section 45"
+);
+
+reportCompare(
+ "x|y*|string|1|number|xy*z|string|z",
+ "xy*z".replace("y*", f),
+ "Section 46"
+);
+
+reportCompare(
+ "12|3|string|2|number|12345|string|45",
+ String.prototype.replace.call(1.2345e4, 3, f),
+ "Section 47"
+);
+
+reportCompare(
+ "|x|string|0|number|xxx|string|xx",
+ "xxx".replace(/^x/g, f),
+ "Section 48"
+);
+
+reportCompare(
+ "xx|x|string|2|number|xxx|string|",
+ "xxx".replace(/x$/g, f),
+ "Section 49"
+);
+
+f = function (sub, paren, offs, str) {
+ return ["", sub, typeof sub, paren, typeof paren, offs, typeof offs,
+ str, typeof str, ""].join("|");
+};
+
+reportCompare(
+ "xy|z|string|z|string|2|number|xyz|string|",
+ "xyz".replace(/(z)/g, f),
+ "Section 50"
+);
+
+reportCompare(
+ "xyz||string||string|3|number|xyz|string|",
+ "xyz".replace(/($)/g, f),
+ "Section 51"
+);
+
+reportCompare(
+ "|xy|string|y|string|0|number|xyz|string|z",
+ "xyz".replace(/(?:x)(y)/g, f),
+ "Section 52"
+);
+
+reportCompare(
+ "|x|string|x|string|0|number|xyz|string|yz",
+ "xyz".replace(/((?=xy)x)/g, f),
+ "Section 53"
+);
+
+reportCompare(
+ "|x|string|x|string|0|number|xyz|string|yz",
+ "xyz".replace(/(x(?=y))/g, f),
+ "Section 54"
+);
+
+reportCompare(
+ "x|y|string|y|string|1|number|xyz|string|z",
+ "xyz".replace(/((?!x)y)/g, f),
+ "Section 55"
+);
+
+reportCompare(
+ "|x|string|x|string|0|number|xyz|string|" +
+ "|y|string||undefined|1|number|xyz|string|z",
+ "xyz".replace(/y|(x)/g, f),
+ "Section 56"
+);
+
+reportCompare(
+ "xy|z|string||string|2|number|xyz|string|",
+ "xyz".replace(/(z?)z/, f),
+ "Section 57"
+);
+
+reportCompare(
+ "xy|z|string||undefined|2|number|xyz|string|",
+ "xyz".replace(/(z)?z/, f),
+ "Section 58"
+);
+
+reportCompare(
+ "xy|z|string||undefined|2|number|xyz|string|",
+ "xyz".replace(/(z)?\1z/, f),
+ "Section 59"
+);
+
+reportCompare(
+ "xy|z|string||undefined|2|number|xyz|string|",
+ "xyz".replace(/\1(z)?z/, f),
+ "Section 60"
+);
+
+reportCompare(
+ "xy|z|string||string|2|number|xyz|string|",
+ "xyz".replace(/(z?\1)z/, f),
+ "Section 61"
+);
+
+f = function (sub, paren1, paren2, offs, str) {
+ return ["", sub, typeof sub, paren1, typeof paren1, paren2, typeof paren2,
+ offs, typeof offs, str, typeof str, ""].join("|");
+};
+
+reportCompare(
+ "x|y|string|y|string||undefined|1|number|xyz|string|z",
+ "xyz".replace(/(y)(\1)?/, f),
+ "Section 62"
+);
+
+reportCompare(
+ "x|yy|string|y|string|y|string|1|number|xyyz|string|z",
+ "xyyz".replace(/(y)(\1)?/g, f),
+ "Section 63"
+);
+
+reportCompare(
+ "x|y|string|y|string||undefined|1|number|xyyz|string|" +
+ "|y|string|y|string||undefined|2|number|xyyz|string|z",
+ "xyyz".replace(/(y)(\1)??/g, f),
+ "Section 64"
+);
+
+reportCompare(
+ "x|y|string|y|string|y|string|1|number|xyz|string|z",
+ "xyz".replace(/(?=(y))(\1)?/, f),
+ "Section 65"
+);
+
+reportCompare(
+ "xyy|z|string||undefined||string|3|number|xyyz|string|",
+ "xyyz".replace(/(?!(y)y)(\1)z/, f),
+ "Section 66"
+);
+
+rex = RegExp(
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()" +
+ "()()()()()()()()()()(z)?(y)");
+a = ["sub"];
+for (i = 1; i <= 102; ++i)
+ a[i] = "p" + i;
+a[103] = "offs";
+a[104] = "str";
+a[105] = "return ['', sub, typeof sub, offs, typeof offs, str, typeof str, " +
+ "p100, typeof p100, p101, typeof p101, p102, typeof p102, ''].join('|');";
+f = Function.apply(null, a);
+reportCompare(
+ "x|y|string|1|number|xyz|string||string||undefined|y|string|z",
+ "xyz".replace(rex, f),
+ "Section 67"
+);
+
+reportCompare(
+ "undefined",
+ "".replace(/.*/g, function () {}),
+ "Section 68"
+);
+
+reportCompare(
+ "nullxnullynullznull",
+ "xyz".replace(/.??/g, function () { return null; }),
+ "Section 69"
+);
+
+reportCompare(
+ "111",
+ "xyz".replace(/./g, function () { return 1; }),
+ "Section 70"
+);
diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js
new file mode 100644
index 0000000000..aa6c7354c2
--- /dev/null
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is JavaScript Engine testing utilities.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Karsten Sperling <spiff@phreax.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+var gTestfile = '15.5.4.14.js';
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 287630;
+var summary = '15.5.4.14 - String.prototype.split(/()/)';
+var actual = '';
+var expect = ['a'].toString();
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+actual = 'a'.split(/()/).toString();
+
+reportCompare(expect, actual, summary);
diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/String/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/browser.js
diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js
new file mode 100644
index 0000000000..c5593948d7
--- /dev/null
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * k.mike@gmx.net, pschwartau@netscape.com
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * Date: 12 October 2001
+ *
+ * SUMMARY: Regression test for string.replace bug 104375
+ * See http://bugzilla.mozilla.org/show_bug.cgi?id=104375
+ */
+//-----------------------------------------------------------------------------
+var gTestfile = 'regress-104375.js';
+var UBound = 0;
+var BUGNUMBER = 104375;
+var summary = 'Testing string.replace() with backreferences';
+var status = '';
+var statusitems = [];
+var actual = '';
+var actualvalues = [];
+var expect= '';
+var expectedvalues = [];
+
+
+/*
+ * Use the regexp to replace 'uid=31' with 'uid=15'
+ *
+ * In the second parameter of string.replace() method,
+ * "$1" refers to the first backreference: 'uid='
+ */
+var str = 'uid=31';
+var re = /(uid=)(\d+)/;
+
+// try the numeric literal 15
+status = inSection(1);
+actual = str.replace (re, "$1" + 15);
+expect = 'uid=15';
+addThis();
+
+// try the string literal '15'
+status = inSection(2);
+actual = str.replace (re, "$1" + '15');
+expect = 'uid=15';
+addThis();
+
+// try a letter before the '15'
+status = inSection(3);
+actual = str.replace (re, "$1" + 'A15');
+expect = 'uid=A15';
+addThis();
+
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+
+
+function addThis()
+{
+ statusitems[UBound] = status;
+ actualvalues[UBound] = actual;
+ expectedvalues[UBound] = expect;
+ UBound++;
+}
+
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+ for (var i=0; i<UBound; i++)
+ {
+ reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
+ }
+
+ exitFunc ('test');
+}
+
+
diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-189898.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-189898.js
new file mode 100644
index 0000000000..c75c081513
--- /dev/null
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-189898.js
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is JavaScript Engine testing utilities.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corp.
+ * Portions created by the Initial Developer are Copyright (C) 2003
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * igor@icesoft.no, pschwartau@netscape.com
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ *
+ * Date: 21 January 2003
+ * SUMMARY: Regression test for bug 189898
+ * See http://bugzilla.mozilla.org/show_bug.cgi?id=189898
+ *
+ */
+//-----------------------------------------------------------------------------
+var gTestfile = 'regress-189898.js';
+var UBound = 0;
+var BUGNUMBER = 189898;
+var summary = 'Regression test for bug 189898';
+var status = '';
+var statusitems = [];
+var actual = '';
+var actualvalues = [];
+var expect= '';
+var expectedvalues = [];
+
+
+status = inSection(1);
+actual = 'XaXY'.replace('XY', '--')
+ expect = 'Xa--';
+addThis();
+
+status = inSection(2);
+actual = '$a$^'.replace('$^', '--')
+ expect = '$a--';
+addThis();
+
+status = inSection(3);
+actual = 'ababc'.replace('abc', '--')
+ expect = 'ab--';
+addThis();
+
+status = inSection(4);
+actual = 'ababc'.replace('abc', '^$')
+ expect = 'ab^$';
+addThis();
+
+
+
+/*
+ * Same as above, but providing a regexp in the first parameter
+ * to String.prototype.replace() instead of a string.
+ *
+ * See http://bugzilla.mozilla.org/show_bug.cgi?id=83293
+ * for subtleties on this issue -
+ */
+status = inSection(5);
+actual = 'XaXY'.replace(/XY/, '--')
+ expect = 'Xa--';
+addThis();
+
+status = inSection(6);
+actual = 'XaXY'.replace(/XY/g, '--')
+ expect = 'Xa--';
+addThis();
+
+status = inSection(7);
+actual = '$a$^'.replace(/\$\^/, '--')
+ expect = '$a--';
+addThis();
+
+status = inSection(8);
+actual = '$a$^'.replace(/\$\^/g, '--')
+ expect = '$a--';
+addThis();
+
+status = inSection(9);
+actual = 'ababc'.replace(/abc/, '--')
+ expect = 'ab--';
+addThis();
+
+status = inSection(10);
+actual = 'ababc'.replace(/abc/g, '--')
+ expect = 'ab--';
+addThis();
+
+status = inSection(11);
+actual = 'ababc'.replace(/abc/, '^$')
+ expect = 'ab^$';
+addThis();
+
+status = inSection(12);
+actual = 'ababc'.replace(/abc/g, '^$')
+ expect = 'ab^$';
+addThis();
+
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+
+
+function addThis()
+{
+ statusitems[UBound] = status;
+ actualvalues[UBound] = actual;
+ expectedvalues[UBound] = expect;
+ UBound++;
+}
+
+
+function test()
+{
+ enterFunc('test');
+ printBugNumber(BUGNUMBER);
+ printStatus(summary);
+
+ for (var i=0; i<UBound; i++)
+ {
+ reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
+ }
+
+ exitFunc ('test');
+}
diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js
new file mode 100755
index 0000000000..733cd713d8
--- /dev/null
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is JavaScript Engine testing utilities.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Blake Kaplan
+ * timeless
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+var gTestfile = 'regress-304376.js';
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 304376;
+var summary = 'String.prototype should be readonly and permanent';
+var actual = '';
+var expect = '';
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+expect = 'TypeError';
+
+var saveString = String;
+
+String = Array;
+
+try
+{
+ // see if we can crash...
+ "".join();
+ String = saveString;
+ actual = 'No Error';
+}
+catch(ex)
+{
+ String = saveString;
+ actual = ex.name;
+ printStatus(ex + '');
+}
+
+reportCompare(expect, actual, summary);
diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js
new file mode 100755
index 0000000000..9610238cc3
--- /dev/null
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is JavaScript Engine testing utilities.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Igor Bukanov
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+var gTestfile = 'regress-313567.js';
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 313567;
+var summary = 'String.prototype.length should not be generic';
+var actual = '';
+var expect = '';
+
+printBugNumber(BUGNUMBER);
+printStatus (summary);
+
+var s = new String("1");
+s.toString = function() {
+ return "22";
+}
+ var expect = 1;
+var actual = s.length;
+printStatus("expect="+expect+" actual="+actual);
+
+reportCompare(expect, actual, summary);
diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js
new file mode 100755
index 0000000000..368fde1278
--- /dev/null
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is JavaScript Engine testing utilities.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+var gTestfile = 'regress-392378.js';
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 392378;
+var summary = 'Regular Expression Non-participating Capture Groups are inaccurate in edge cases';
+var actual = '';
+var expect = '';
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+ expect = ["", undefined, ""] + '';
+ actual = "y".split(/(x)?\1y/) + '';
+ reportCompare(expect, actual, summary + ': "y".split(/(x)?\1y/)');
+
+ expect = ["", undefined, ""] + '';
+ actual = "y".split(/(x)?y/) + '';
+ reportCompare(expect, actual, summary + ': "y".split(/(x)?y/)');
+
+ expect = 'undefined';
+ actual = "y".replace(/(x)?\1y/, function($0, $1){ return String($1); }) + '';
+ reportCompare(expect, actual, summary + ': "y".replace(/(x)?\\1y/, function($0, $1){ return String($1); })');
+
+ expect = 'undefined';
+ actual = "y".replace(/(x)?y/, function($0, $1){ return String($1); }) + '';
+ reportCompare(expect, actual, summary + ': "y".replace(/(x)?y/, function($0, $1){ return String($1); })');
+
+ expect = 'undefined';
+ actual = "y".replace(/(x)?y/, function($0, $1){ return $1; }) + '';
+ reportCompare(expect, actual, summary + ': "y".replace(/(x)?y/, function($0, $1){ return $1; })');
+
+ exitFunc ('test');
+}
diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-83293.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-83293.js
new file mode 100644
index 0000000000..55e74d4dd5
--- /dev/null
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-83293.js
@@ -0,0 +1,216 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * pschwartau@netscape.com, jim@jibbering.com
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+var gTestfile = 'regress-83293.js';
+
+/*
+ * Creation Date: 30 May 2001
+ * Correction Date: 14 Aug 2001
+ *
+ * SUMMARY: Regression test for bugs 83293, 103351
+ * See http://bugzilla.mozilla.org/show_bug.cgi?id=83293
+ * http://bugzilla.mozilla.org/show_bug.cgi?id=103351
+ * http://bugzilla.mozilla.org/show_bug.cgi?id=92942
+ *
+ *
+ * ******************** CORRECTION !!! *****************************
+ *
+ * When I originally wrote this test, I thought this was true:
+ * str.replace(strA, strB) == str.replace(new RegExp(strA),strB).
+ * See ECMA-262 Final Draft, 15.5.4.11 String.prototype.replace
+ *
+ * However, in http://bugzilla.mozilla.org/show_bug.cgi?id=83293
+ * Jim Ley points out the ECMA-262 Final Edition changed on this.
+ * String.prototype.replace (searchValue, replaceValue), if provided
+ * a searchValue that is not a RegExp, is NO LONGER to replace it with
+ *
+ * new RegExp(searchValue)
+ * but rather:
+ * String(searchValue)
+ *
+ * This puts the replace() method at variance with search() and match(),
+ * which continue to follow the RegExp conversion of the Final Draft.
+ * It also makes most of this testcase, as originally written, invalid.
+ **********************************************************************
+ */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 103351; // <--- (Outgrowth of original bug 83293)
+var summ_OLD = 'Testing str.replace(strA, strB) == str.replace(new RegExp(strA),strB)';
+var summ_NEW = 'Testing String.prototype.replace(x,y) when x is a string';
+var summary = summ_NEW;
+var status = '';
+var actual = '';
+var expect= '';
+var cnEmptyString = '';
+var str = 'abc';
+var strA = cnEmptyString;
+var strB = 'Z';
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+
+/*
+ * In this test, it's important to reportCompare() each other case
+ * BEFORE the last two cases are attempted. Don't store all results
+ * in an array and reportCompare() them at the end, as we usually do.
+ *
+ * When this bug was filed, str.replace(strA, strB) would return no value
+ * whatsoever if strA == cnEmptyString, and no error, either -
+ */
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+/******************* THESE WERE INCORRECT; SEE ABOVE ************************
+ status = 'Section A of test';
+ strA = 'a';
+ actual = str.replace(strA, strB);
+ expect = str.replace(new RegExp(strA), strB);
+ reportCompare(expect, actual, status);
+
+ status = 'Section B of test';
+ strA = 'x';
+ actual = str.replace(strA, strB);
+ expect = str.replace(new RegExp(strA), strB);
+ reportCompare(expect, actual, status);
+
+ status = 'Section C of test';
+ strA = undefined;
+ actual = str.replace(strA, strB);
+ expect = str.replace(new RegExp(strA), strB);
+ reportCompare(expect, actual, status);
+
+ status = 'Section D of test';
+ strA = null;
+ actual = str.replace(strA, strB);
+ expect = str.replace(new RegExp(strA), strB);
+ reportCompare(expect, actual, status);
+
+
+ * This example is from jim@jibbering.com (see Bugzilla bug 92942)
+ * It is a variation on the example below.
+ *
+ * Namely, we are using the regexp /$/ instead of the regexp //.
+ * The regexp /$/ means we should match the "empty string" at the
+ * end-boundary of the word, instead of the one at the beginning.
+ *
+ status = 'Section E of test';
+ var strJim = 'aa$aa';
+ strA = '$';
+ actual = strJim.replace(strA, strB); // bug -> 'aaZaa'
+ expect = strJim.replace(new RegExp(strA), strB); // expect 'aa$aaZ'
+ reportCompare(expect, actual, status);
+
+
+ *
+ * Note: 'Zabc' is the result we expect for 'abc'.replace('', 'Z').
+ *
+ * The string '' is supposed to be equivalent to new RegExp('') = //.
+ * The regexp // means we should match the "empty string" conceived of
+ * at the beginning boundary of the word, before the first character.
+ *
+ status = 'Section F of test';
+ strA = cnEmptyString;
+ actual = str.replace(strA, strB);
+ expect = 'Zabc';
+ reportCompare(expect, actual, status);
+
+ status = 'Section G of test';
+ strA = cnEmptyString;
+ actual = str.replace(strA, strB);
+ expect = str.replace(new RegExp(strA), strB);
+ reportCompare(expect, actual, status);
+
+ ************************* END OF INCORRECT CASES ****************************/
+
+
+////////////////////////// OK, LET'S START OVER //////////////////////////////
+
+ status = 'Section 1 of test';
+ actual = 'abc'.replace('a', 'Z');
+ expect = 'Zbc';
+ reportCompare(expect, actual, status);
+
+ status = 'Section 2 of test';
+ actual = 'abc'.replace('b', 'Z');
+ expect = 'aZc';
+ reportCompare(expect, actual, status);
+
+ status = 'Section 3 of test';
+ actual = 'abc'.replace(undefined, 'Z');
+ expect = 'abc'; // String(undefined) == 'undefined'; no replacement possible
+ reportCompare(expect, actual, status);
+
+ status = 'Section 4 of test';
+ actual = 'abc'.replace(null, 'Z');
+ expect = 'abc'; // String(null) == 'null'; no replacement possible
+ reportCompare(expect, actual, status);
+
+ status = 'Section 5 of test';
+ actual = 'abc'.replace(true, 'Z');
+ expect = 'abc'; // String(true) == 'true'; no replacement possible
+ reportCompare(expect, actual, status);
+
+ status = 'Section 6 of test';
+ actual = 'abc'.replace(false, 'Z');
+ expect = 'abc'; // String(false) == 'false'; no replacement possible
+ reportCompare(expect, actual, status);
+
+ status = 'Section 7 of test';
+ actual = 'aa$aa'.replace('$', 'Z');
+ expect = 'aaZaa'; // NOT 'aa$aaZ' as in ECMA Final Draft; see above
+ reportCompare(expect, actual, status);
+
+ status = 'Section 8 of test';
+ actual = 'abc'.replace('.*', 'Z');
+ expect = 'abc'; // not 'Z' as in EMCA Final Draft
+ reportCompare(expect, actual, status);
+
+ status = 'Section 9 of test';
+ actual = 'abc'.replace('', 'Z');
+ expect = 'Zabc'; // Still expect 'Zabc' for this
+ reportCompare(expect, actual, status);
+
+ exitFunc ('test');
+}
diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/String/shell.js
new file mode 100644
index 0000000000..7d850446cc
--- /dev/null
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/shell.js
@@ -0,0 +1 @@
+gTestsubsuite = 'String';