summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/date-is-nan-throws.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/date-is-nan-throws.js')
-rw-r--r--js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/date-is-nan-throws.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/date-is-nan-throws.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/date-is-nan-throws.js
new file mode 100644
index 0000000000..ab062734e0
--- /dev/null
+++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/date-is-nan-throws.js
@@ -0,0 +1,35 @@
+// Copyright 2016 Leonardo Balter. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: >
+ Throws a RangeError if date arg is cast to NaN
+info: |
+ Intl.DateTimeFormat.prototype.formatToParts ([ date ])
+
+ 4. If _date_ is not provided or is *undefined*, then
+ a. Let _x_ be *%Date_now%*().
+ 5. Else,
+ a. Let _x_ be ? ToNumber(_date_).
+ 6. Return ? FormatDateTimeToParts(_dtf_, _x_).
+
+ FormatDateTimeToParts(dateTimeFormat, x)
+
+ 1. Let _parts_ be ? PartitionDateTimePattern(_dateTimeFormat_, _x_).
+
+ PartitionDateTimePattern (dateTimeFormat, x)
+
+ 1. If _x_ is not a finite Number, throw a *RangeError* exception.
+---*/
+
+var dtf = new Intl.DateTimeFormat(["pt-BR"]);
+
+assert.throws(RangeError, function() {
+ dtf.formatToParts(NaN);
+});
+
+assert.throws(RangeError, function() {
+ dtf.formatToParts("lol");
+});
+
+reportCompare(0, 0);