summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/RelativeTimeFormat/prototype/format/value-tonumber.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/intl402/RelativeTimeFormat/prototype/format/value-tonumber.js')
-rw-r--r--js/src/tests/test262/intl402/RelativeTimeFormat/prototype/format/value-tonumber.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/RelativeTimeFormat/prototype/format/value-tonumber.js b/js/src/tests/test262/intl402/RelativeTimeFormat/prototype/format/value-tonumber.js
new file mode 100644
index 0000000000..2ca5ae6100
--- /dev/null
+++ b/js/src/tests/test262/intl402/RelativeTimeFormat/prototype/format/value-tonumber.js
@@ -0,0 +1,40 @@
+// Copyright 2018 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-Intl.RelativeTimeFormat.prototype.format
+description: Checks the handling of non-number value arguments to Intl.RelativeTimeFormat.prototype.format().
+info: |
+ Intl.RelativeTimeFormat.prototype.format( value, unit )
+
+ 3. Let value be ? ToNumber(value).
+
+features: [Intl.RelativeTimeFormat]
+---*/
+
+const rtf = new Intl.RelativeTimeFormat("en-US");
+
+assert.sameValue(typeof rtf.format, "function", "format should be supported");
+
+const values = [
+ [null, 0],
+
+ [true, 1],
+ [false, 0],
+
+ ["5", 5],
+ ["-5", -5],
+ ["0", 0],
+ ["-0", -0],
+ [" 6 ", 6],
+
+ [{ toString() { return 7; } }, 7, "object with toString"],
+ [{ valueOf() { return 7; } }, 7, "object with valueOf"],
+];
+
+for (const [input, number, name = String(input)] of values) {
+ assert.sameValue(rtf.format(input, "second"), rtf.format(number, "second"),
+ `Should treat ${name} as ${number}`)
+}
+
+reportCompare(0, 0);