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

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 // Copyright 2012 Mozilla Corporation. All rights reserved.
michael@0 2 // This code is governed by the BSD license found in the LICENSE file.
michael@0 3
michael@0 4 /**
michael@0 5 * @description Tests that an object can't be re-initialized as a NumberFormat.
michael@0 6 * @author Norbert Lindenberg
michael@0 7 */
michael@0 8
michael@0 9 $INCLUDE("testIntl.js");
michael@0 10
michael@0 11 testWithIntlConstructors(function (Constructor) {
michael@0 12 var obj, error;
michael@0 13
michael@0 14 // variant 1: use constructor in a "new" expression
michael@0 15 obj = new Constructor();
michael@0 16 try {
michael@0 17 Intl.NumberFormat.call(obj);
michael@0 18 } catch (e) {
michael@0 19 error = e;
michael@0 20 }
michael@0 21 if (error === undefined) {
michael@0 22 $ERROR("Re-initializing object created with \"new\" as NumberFormat was not rejected.");
michael@0 23 } else if (error.name !== "TypeError") {
michael@0 24 $ERROR("Re-initializing object created with \"new\" as NumberFormat was rejected with wrong error " + error.name + ".");
michael@0 25 }
michael@0 26
michael@0 27 // variant 2: use constructor as a function
michael@0 28 obj = Constructor.call({});
michael@0 29 error = undefined;
michael@0 30 try {
michael@0 31 Intl.NumberFormat.call(obj);
michael@0 32 } catch (e) {
michael@0 33 error = e;
michael@0 34 }
michael@0 35 if (error === undefined) {
michael@0 36 $ERROR("Re-initializing object created with constructor as function as NumberFormat was not rejected.");
michael@0 37 } else if (error.name !== "TypeError") {
michael@0 38 $ERROR("Re-initializing object created with constructor as function as NumberFormat was rejected with wrong error " + error.name + ".");
michael@0 39 }
michael@0 40
michael@0 41 return true;
michael@0 42 });
michael@0 43

mercurial