summaryrefslogtreecommitdiff
path: root/test/built-ins/String
diff options
context:
space:
mode:
authorJosh Wolfe <jwolfe@igalia.com>2017-08-28 10:37:38 -0700
committerRick Waldron <waldron.rick@gmail.com>2017-09-08 10:15:19 -0400
commit29938e9525978c3e3601be3b30991bf1ddf5b832 (patch)
tree198c6dbd382e0df7882bf8a9e588604243b2be2e /test/built-ins/String
parent7f88a6d7f94f44a8413458dd53cef37cd46e8f50 (diff)
downloadqtdeclarative-testsuites-29938e9525978c3e3601be3b30991bf1ddf5b832.tar.gz
type coercion harness utilities
Diffstat (limited to 'test/built-ins/String')
-rw-r--r--test/built-ins/String/prototype/indexOf/position-tointeger.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/built-ins/String/prototype/indexOf/position-tointeger.js b/test/built-ins/String/prototype/indexOf/position-tointeger.js
new file mode 100644
index 000000000..749968274
--- /dev/null
+++ b/test/built-ins/String/prototype/indexOf/position-tointeger.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-string.prototype.indexof
+description: String.prototype.indexOf type coercion for position parameter
+info: >
+ String.prototype.indexOf ( searchString [ , position ] )
+
+ 4. Let pos be ? ToInteger(position).
+
+includes: [typeCoercion.js]
+---*/
+
+getValuesCoercibleToIntegerZero().forEach(function(zero) {
+ assert.sameValue("aaaa".indexOf("aa", zero), 0, "with value " + zero);
+});
+
+getValuesCoercibleToIntegerOne().forEach(function(one) {
+ assert.sameValue("aaaa".indexOf("aa", one), 1, "with value " + one);
+});
+
+getValuesCoercibleToIntegerFromInteger(2).forEach(function(two) {
+ assert.sameValue("aaaa".indexOf("aa", two), 2, "with value " + two);
+});
+
+getValuesNotCoercibleToInteger().forEach(function(pair) {
+ var error = pair.error;
+ var value = pair.value;
+ assert.throws(error, function() { "".indexOf("", value); });
+});