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

Side by Side Diff: test/intl/general/constructor.js

Issue 2582993002: [intl] Add new semantics + compat fallback to Intl constructor (Closed)
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 let compatConstructors = [
6 {c: Intl.DateTimeFormat, m: "format"},
7 {c: Intl.NumberFormat, m: "format"},
8 ];
9
10 for (let {c, m} of compatConstructors) {
11 let i = Object.create(c.prototype);
12 assertTrue(i instanceof c);
13 assertThrows(() => i[m], TypeError);
14 assertEquals(i, c.call(i));
15 assertEquals(i[m], i[m]);
16 assertTrue(i instanceof c);
17
18 for ({c: c2, m: m2} of compatConstructors) {
19 if (c2 === c) {
20 assertThrows(() => c2.call(i), TypeError);
21 } else {
22 let i2 = c2.call(i);
23 assertTrue(i2 != i);
24 assertFalse(i2 instanceof c);
25 assertTrue(i2 instanceof c2);
26 assertEquals(i2[m2], i2[m2]);
27 }
28 }
29 }
30
31 let noCompatConstructors = [
32 {c: Intl.Collator, m: "compare"},
33 {c: Intl.v8BreakIterator, m: "next"},
34 ];
35
36 for (let {c, m} of noCompatConstructors) {
37 let i = Object.create(c.prototype);
38 assertTrue(i instanceof c);
39 assertThrows(() => i[m], TypeError);
40 let i2 = c.call(i);
41 assertTrue(i2 != i);
42 assertEquals('function', typeof i2[m]);
43 assertTrue(i2 instanceof c);
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698