Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
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 DateTimeFormat. |
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.DateTimeFormat.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 DateTimeFormat was not rejected."); |
michael@0 | 23 | } else if (error.name !== "TypeError") { |
michael@0 | 24 | $ERROR("Re-initializing object created with \"new\" as DateTimeFormat 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.DateTimeFormat.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 DateTimeFormat was not rejected."); |
michael@0 | 37 | } else if (error.name !== "TypeError") { |
michael@0 | 38 | $ERROR("Re-initializing object created with constructor as function as DateTimeFormat was rejected with wrong error " + error.name + "."); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | return true; |
michael@0 | 42 | }); |
michael@0 | 43 |