summaryrefslogtreecommitdiffstats
path: root/js/src/tests/js1_5/Array/regress-364104.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/js1_5/Array/regress-364104.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/js1_5/Array/regress-364104.js')
-rw-r--r--js/src/tests/js1_5/Array/regress-364104.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/js/src/tests/js1_5/Array/regress-364104.js b/js/src/tests/js1_5/Array/regress-364104.js
new file mode 100644
index 000000000..05d8953b6
--- /dev/null
+++ b/js/src/tests/js1_5/Array/regress-364104.js
@@ -0,0 +1,74 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = "364104";
+var summary = "Array.prototype.indexOf, Array.prototype.lastIndexOf issues " +
+ "with the optional second fromIndex argument";
+var actual, expect;
+
+printBugNumber(BUGNUMBER);
+printStatus(summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var failed = false;
+
+try
+{
+ // indexOf
+ if ([2].indexOf(2) != 0)
+ throw "indexOf: not finding 2!?";
+ if ([2].indexOf(2, 0) != 0)
+ throw "indexOf: not interpreting explicit second argument 0!";
+ if ([2].indexOf(2, 1) != -1)
+ throw "indexOf: ignoring second argument with value equal to array length!";
+ if ([2].indexOf(2, 2) != -1)
+ throw "indexOf: ignoring second argument greater than array length!";
+ if ([2].indexOf(2, 17) != -1)
+ throw "indexOf: ignoring large second argument!";
+ if ([2].indexOf(2, -5) != 0)
+ throw "indexOf: calculated fromIndex < 0, should search entire array!";
+ if ([2, 3].indexOf(2, -1) != -1)
+ throw "indexOf: not handling index == (-1 + 2), element 2 correctly!";
+ if ([2, 3].indexOf(3, -1) != 1)
+ throw "indexOf: not handling index == (-1 + 2), element 3 correctly!";
+
+ // lastIndexOf
+ if ([2].lastIndexOf(2) != 0)
+ throw "lastIndexOf: not finding 2!?";
+ if ([2].lastIndexOf(2, 1) != 0)
+ throw "lastIndexOf: not interpreting explicit second argument 1!?";
+ if ([2].lastIndexOf(2, 17) != 0)
+ throw "lastIndexOf: should have searched entire array!";
+ if ([2].lastIndexOf(2, -5) != -1)
+ throw "lastIndexOf: -5 + 1 < 0, so array shouldn't be searched!";
+ if ([2].lastIndexOf(2, -2) != -1)
+ throw "lastIndexOf: -2 + 1 < 0, so array shouldn't be searched!";
+ if ([2, 3].lastIndexOf(2, -1) != 0)
+ throw "lastIndexOf: not handling index == (-1 + 2), element 2 correctly!";
+ if ([2, 3].lastIndexOf(3, -1) != 1)
+ throw "lastIndexOf: not handling index == (-1 + 2), element 3 correctly!";
+ if ([2, 3].lastIndexOf(2, -2) != 0)
+ throw "lastIndexOf: not handling index == (-2 + 2), element 2 correctly!";
+ if ([2, 3].lastIndexOf(3, -2) != -1)
+ throw "lastIndexOf: not handling index == (-2 + 2), element 3 correctly!";
+ if ([2, 3].lastIndexOf(2, -3) != -1)
+ throw "lastIndexOf: calculated fromIndex < 0, shouldn't search array for 2!";
+ if ([2, 3].lastIndexOf(3, -3) != -1)
+ throw "lastIndexOf: calculated fromIndex < 0, shouldn't search array for 3!";
+}
+catch (e)
+{
+ failed = e;
+}
+
+
+expect = false;
+actual = failed;
+
+reportCompare(expect, actual, summary);