js/src/tests/test262/intl402/ch11/11.3/11.3_b.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Copyright 2012 Mozilla Corporation. All rights reserved.
     2 // This code is governed by the BSD license found in the LICENSE file.
     4 /**
     5  * @description Tests that Intl.NumberFormat.prototype functions throw a
     6  *     TypeError if called on a non-object value or an object that hasn't been
     7  *     initialized as a NumberFormat.
     8  * @author Norbert Lindenberg
     9  */
    11 var functions = {
    12     "format getter": Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format").get,
    13     resolvedOptions: Intl.NumberFormat.prototype.resolvedOptions
    14 };
    15 var invalidTargets = [undefined, null, true, 0, "NumberFormat", [], {}];
    17 Object.getOwnPropertyNames(functions).forEach(function (functionName) {
    18     var f = functions[functionName];
    19     invalidTargets.forEach(function (target) {
    20         var error;
    21         try {
    22             f.call(target);
    23         } catch (e) {
    24             error = e;
    25         }
    26         if (error === undefined) {
    27             $ERROR("Calling " + functionName + " on " + target + " was not rejected.");
    28         } else if (error.name !== "TypeError") {
    29             $ERROR("Calling " + functionName + " on " + target + " was rejected with wrong error " + error.name + ".");
    30         }
    31     });
    32 });

mercurial