aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite/intl402/ch10/10.1/10.1.1_1.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/suite/intl402/ch10/10.1/10.1.1_1.js')
-rw-r--r--test/suite/intl402/ch10/10.1/10.1.1_1.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/suite/intl402/ch10/10.1/10.1.1_1.js b/test/suite/intl402/ch10/10.1/10.1.1_1.js
new file mode 100644
index 000000000..432e073fc
--- /dev/null
+++ b/test/suite/intl402/ch10/10.1/10.1.1_1.js
@@ -0,0 +1,43 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that an object can't be re-initialized as a Collator.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testWithIntlConstructors(function (Constructor) {
+ var obj, error;
+
+ // variant 1: use constructor in a "new" expression
+ obj = new Constructor();
+ try {
+ Intl.Collator.call(obj);
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Re-initializing object created with \"new\" as Collator was not rejected.");
+ } else if (error.name !== "TypeError") {
+ $ERROR("Re-initializing object created with \"new\" as Collator was rejected with wrong error " + error.name + ".");
+ }
+
+ // variant 2: use constructor as a function
+ obj = Constructor.call({});
+ error = undefined;
+ try {
+ Intl.Collator.call(obj);
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Re-initializing object created with constructor as function as Collator was not rejected.");
+ } else if (error.name !== "TypeError") {
+ $ERROR("Re-initializing object created with constructor as function as Collator was rejected with wrong error " + error.name + ".");
+ }
+
+ return true;
+});
+