Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1254)

Unified Diff: test/intl/general/constructor.js

Issue 2582993002: [intl] Add new semantics + compat fallback to Intl constructor (Closed)
Patch Set: reformatting Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/intl/assert.js ('k') | test/mjsunit/regress/regress-4870.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/intl/general/constructor.js
diff --git a/test/intl/general/constructor.js b/test/intl/general/constructor.js
new file mode 100644
index 0000000000000000000000000000000000000000..4fb1389f5899667f8d71000dd5150bdc3376160d
--- /dev/null
+++ b/test/intl/general/constructor.js
@@ -0,0 +1,44 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+let compatConstructors = [
+ {c: Intl.DateTimeFormat, m: "format"},
+ {c: Intl.NumberFormat, m: "format"},
+];
+
+for (let {c, m} of compatConstructors) {
+ let i = Object.create(c.prototype);
+ assertTrue(i instanceof c);
+ assertThrows(() => i[m], TypeError);
+ assertEquals(i, c.call(i));
+ assertEquals(i[m], i[m]);
+ assertTrue(i instanceof c);
+
+ for ({c: c2, m: m2} of compatConstructors) {
+ if (c2 === c) {
+ assertThrows(() => c2.call(i), TypeError);
+ } else {
+ let i2 = c2.call(i);
+ assertTrue(i2 != i);
+ assertFalse(i2 instanceof c);
+ assertTrue(i2 instanceof c2);
+ assertEquals(i2[m2], i2[m2]);
+ }
+ }
+}
+
+let noCompatConstructors = [
+ {c: Intl.Collator, m: "compare"},
+ {c: Intl.v8BreakIterator, m: "next"},
+];
+
+for (let {c, m} of noCompatConstructors) {
+ let i = Object.create(c.prototype);
+ assertTrue(i instanceof c);
+ assertThrows(() => i[m], TypeError);
+ let i2 = c.call(i);
+ assertTrue(i2 != i);
+ assertEquals('function', typeof i2[m]);
+ assertTrue(i2 instanceof c);
+}
« no previous file with comments | « test/intl/assert.js ('k') | test/mjsunit/regress/regress-4870.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698