js/src/tests/test262/intl402/ch12/12.1/12.1.1_1.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 an object can't be re-initialized as a DateTimeFormat.
     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.DateTimeFormat.call(obj);
    18     } catch (e) {
    19         error = e;
    20     }
    21     if (error === undefined) {
    22         $ERROR("Re-initializing object created with \"new\" as DateTimeFormat was not rejected.");
    23     } else if (error.name !== "TypeError") {
    24         $ERROR("Re-initializing object created with \"new\" as DateTimeFormat 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.DateTimeFormat.call(obj);
    32     } catch (e) {
    33         error = e;
    34     }
    35     if (error === undefined) {
    36         $ERROR("Re-initializing object created with constructor as function as DateTimeFormat was not rejected.");
    37     } else if (error.name !== "TypeError") {
    38         $ERROR("Re-initializing object created with constructor as function as DateTimeFormat was rejected with wrong error " + error.name + ".");
    39     }
    41     return true;
    42 });

mercurial