js/src/tests/test262/intl402/ch11/11.1/11.1.1_1.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 an object can't be re-initialized as a NumberFormat.
     6  * @author Norbert Lindenberg
     7  */
     9 $INCLUDE("testIntl.js");
    11 testWithIntlConstructors(function (Constructor) {
    12     var obj, error;
    14     // variant 1: use constructor in a "new" expression
    15     obj = new Constructor();
    16     try {
    17         Intl.NumberFormat.call(obj);
    18     } catch (e) {
    19         error = e;
    20     }
    21     if (error === undefined) {
    22         $ERROR("Re-initializing object created with \"new\" as NumberFormat was not rejected.");
    23     } else if (error.name !== "TypeError") {
    24         $ERROR("Re-initializing object created with \"new\" as NumberFormat was rejected with wrong error " + error.name + ".");
    25     }
    27     // variant 2: use constructor as a function
    28     obj = Constructor.call({});
    29     error = undefined;
    30     try {
    31         Intl.NumberFormat.call(obj);
    32     } catch (e) {
    33         error = e;
    34     }
    35     if (error === undefined) {
    36         $ERROR("Re-initializing object created with constructor as function as NumberFormat was not rejected.");
    37     } else if (error.name !== "TypeError") {
    38         $ERROR("Re-initializing object created with constructor as function as NumberFormat was rejected with wrong error " + error.name + ".");
    39     }
    41     return true;
    42 });

mercurial