michael@0: // Copyright 2012 Mozilla Corporation. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * @description Tests that an object can't be re-initialized as a NumberFormat. michael@0: * @author Norbert Lindenberg michael@0: */ michael@0: michael@0: $INCLUDE("testIntl.js"); michael@0: michael@0: testWithIntlConstructors(function (Constructor) { michael@0: var obj, error; michael@0: michael@0: // variant 1: use constructor in a "new" expression michael@0: obj = new Constructor(); michael@0: try { michael@0: Intl.NumberFormat.call(obj); michael@0: } catch (e) { michael@0: error = e; michael@0: } michael@0: if (error === undefined) { michael@0: $ERROR("Re-initializing object created with \"new\" as NumberFormat was not rejected."); michael@0: } else if (error.name !== "TypeError") { michael@0: $ERROR("Re-initializing object created with \"new\" as NumberFormat was rejected with wrong error " + error.name + "."); michael@0: } michael@0: michael@0: // variant 2: use constructor as a function michael@0: obj = Constructor.call({}); michael@0: error = undefined; michael@0: try { michael@0: Intl.NumberFormat.call(obj); michael@0: } catch (e) { michael@0: error = e; michael@0: } michael@0: if (error === undefined) { michael@0: $ERROR("Re-initializing object created with constructor as function as NumberFormat was not rejected."); michael@0: } else if (error.name !== "TypeError") { michael@0: $ERROR("Re-initializing object created with constructor as function as NumberFormat was rejected with wrong error " + error.name + "."); michael@0: } michael@0: michael@0: return true; michael@0: }); michael@0: