summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/NumberFormat/prototype/formatToParts/this-value-not-numberformat.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/intl402/NumberFormat/prototype/formatToParts/this-value-not-numberformat.js')
-rw-r--r--js/src/tests/test262/intl402/NumberFormat/prototype/formatToParts/this-value-not-numberformat.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/NumberFormat/prototype/formatToParts/this-value-not-numberformat.js b/js/src/tests/test262/intl402/NumberFormat/prototype/formatToParts/this-value-not-numberformat.js
new file mode 100644
index 0000000000..e5beb30623
--- /dev/null
+++ b/js/src/tests/test262/intl402/NumberFormat/prototype/formatToParts/this-value-not-numberformat.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2018 Ujjwal Sharma. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-Intl.NumberFormat.prototype.formatToParts
+description: >
+ Tests that Intl.NumberFormat.prototype.formatToParts throws a
+ TypeError if called on a non-object value or an object that hasn't
+ been initialized as a NumberFormat.
+---*/
+
+const invalidTargets = [undefined, null, true, 0, 'NumberFormat', [], {}, Symbol()];
+const fn = Intl.NumberFormat.prototype.formatToParts;
+
+invalidTargets.forEach(target => {
+ assert.throws(
+ TypeError,
+ () => fn.call(target),
+ `Calling formatToParts on ${String(target)} should throw a TypeError.`
+ );
+});
+
+reportCompare(0, 0);