Skip to content

Commit ee4a412

Browse files
committed
add test for locales object arguments
1 parent a2bef32 commit ee4a412

File tree

4 files changed

+274
-0
lines changed

4 files changed

+274
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//// [localesObjectArgument.ts]
2+
const enUS = new Intl.Locale("en-US");
3+
const deDE = new Intl.Locale("de-DE");
4+
const jaJP = new Intl.Locale("ja-JP");
5+
6+
const now = new Date();
7+
const num = 1000;
8+
const bigint = 123456789123456789n;
9+
10+
now.toLocaleString(enUS);
11+
now.toLocaleDateString(enUS);
12+
now.toLocaleTimeString(enUS);
13+
now.toLocaleString([deDE, jaJP]);
14+
now.toLocaleDateString([deDE, jaJP]);
15+
now.toLocaleTimeString([deDE, jaJP]);
16+
17+
num.toLocaleString(enUS);
18+
num.toLocaleString([deDE, jaJP]);
19+
20+
bigint.toLocaleString(enUS);
21+
bigint.toLocaleString([deDE, jaJP]);
22+
23+
24+
//// [localesObjectArgument.js]
25+
const enUS = new Intl.Locale("en-US");
26+
const deDE = new Intl.Locale("de-DE");
27+
const jaJP = new Intl.Locale("ja-JP");
28+
const now = new Date();
29+
const num = 1000;
30+
const bigint = 123456789123456789n;
31+
now.toLocaleString(enUS);
32+
now.toLocaleDateString(enUS);
33+
now.toLocaleTimeString(enUS);
34+
now.toLocaleString([deDE, jaJP]);
35+
now.toLocaleDateString([deDE, jaJP]);
36+
now.toLocaleTimeString([deDE, jaJP]);
37+
num.toLocaleString(enUS);
38+
num.toLocaleString([deDE, jaJP]);
39+
bigint.toLocaleString(enUS);
40+
bigint.toLocaleString([deDE, jaJP]);
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
=== tests/cases/conformance/es2020/localesObjectArgument.ts ===
2+
const enUS = new Intl.Locale("en-US");
3+
>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 5))
4+
>Intl.Locale : Symbol(Intl.Locale, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --))
5+
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --))
6+
>Locale : Symbol(Intl.Locale, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --))
7+
8+
const deDE = new Intl.Locale("de-DE");
9+
>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 5))
10+
>Intl.Locale : Symbol(Intl.Locale, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --))
11+
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --))
12+
>Locale : Symbol(Intl.Locale, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --))
13+
14+
const jaJP = new Intl.Locale("ja-JP");
15+
>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 5))
16+
>Intl.Locale : Symbol(Intl.Locale, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --))
17+
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --))
18+
>Locale : Symbol(Intl.Locale, Decl(lib.es2020.intl.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --))
19+
20+
const now = new Date();
21+
>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5))
22+
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 1 more)
23+
24+
const num = 1000;
25+
>num : Symbol(num, Decl(localesObjectArgument.ts, 5, 5))
26+
27+
const bigint = 123456789123456789n;
28+
>bigint : Symbol(bigint, Decl(localesObjectArgument.ts, 6, 5))
29+
30+
now.toLocaleString(enUS);
31+
>now.toLocaleString : Symbol(Date.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
32+
>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5))
33+
>toLocaleString : Symbol(Date.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
34+
>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 5))
35+
36+
now.toLocaleDateString(enUS);
37+
>now.toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
38+
>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5))
39+
>toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
40+
>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 5))
41+
42+
now.toLocaleTimeString(enUS);
43+
>now.toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
44+
>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5))
45+
>toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
46+
>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 5))
47+
48+
now.toLocaleString([deDE, jaJP]);
49+
>now.toLocaleString : Symbol(Date.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
50+
>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5))
51+
>toLocaleString : Symbol(Date.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
52+
>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 5))
53+
>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 5))
54+
55+
now.toLocaleDateString([deDE, jaJP]);
56+
>now.toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
57+
>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5))
58+
>toLocaleDateString : Symbol(Date.toLocaleDateString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
59+
>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 5))
60+
>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 5))
61+
62+
now.toLocaleTimeString([deDE, jaJP]);
63+
>now.toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
64+
>now : Symbol(now, Decl(localesObjectArgument.ts, 4, 5))
65+
>toLocaleTimeString : Symbol(Date.toLocaleTimeString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.date.d.ts, --, --))
66+
>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 5))
67+
>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 5))
68+
69+
num.toLocaleString(enUS);
70+
>num.toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --))
71+
>num : Symbol(num, Decl(localesObjectArgument.ts, 5, 5))
72+
>toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --))
73+
>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 5))
74+
75+
num.toLocaleString([deDE, jaJP]);
76+
>num.toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --))
77+
>num : Symbol(num, Decl(localesObjectArgument.ts, 5, 5))
78+
>toLocaleString : Symbol(Number.toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.number.d.ts, --, --))
79+
>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 5))
80+
>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 5))
81+
82+
bigint.toLocaleString(enUS);
83+
>bigint.toLocaleString : Symbol(BigInt.toLocaleString, Decl(lib.es2020.bigint.d.ts, --, --))
84+
>bigint : Symbol(bigint, Decl(localesObjectArgument.ts, 6, 5))
85+
>toLocaleString : Symbol(BigInt.toLocaleString, Decl(lib.es2020.bigint.d.ts, --, --))
86+
>enUS : Symbol(enUS, Decl(localesObjectArgument.ts, 0, 5))
87+
88+
bigint.toLocaleString([deDE, jaJP]);
89+
>bigint.toLocaleString : Symbol(BigInt.toLocaleString, Decl(lib.es2020.bigint.d.ts, --, --))
90+
>bigint : Symbol(bigint, Decl(localesObjectArgument.ts, 6, 5))
91+
>toLocaleString : Symbol(BigInt.toLocaleString, Decl(lib.es2020.bigint.d.ts, --, --))
92+
>deDE : Symbol(deDE, Decl(localesObjectArgument.ts, 1, 5))
93+
>jaJP : Symbol(jaJP, Decl(localesObjectArgument.ts, 2, 5))
94+
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
=== tests/cases/conformance/es2020/localesObjectArgument.ts ===
2+
const enUS = new Intl.Locale("en-US");
3+
>enUS : Intl.Locale
4+
>new Intl.Locale("en-US") : Intl.Locale
5+
>Intl.Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale
6+
>Intl : typeof Intl
7+
>Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale
8+
>"en-US" : "en-US"
9+
10+
const deDE = new Intl.Locale("de-DE");
11+
>deDE : Intl.Locale
12+
>new Intl.Locale("de-DE") : Intl.Locale
13+
>Intl.Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale
14+
>Intl : typeof Intl
15+
>Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale
16+
>"de-DE" : "de-DE"
17+
18+
const jaJP = new Intl.Locale("ja-JP");
19+
>jaJP : Intl.Locale
20+
>new Intl.Locale("ja-JP") : Intl.Locale
21+
>Intl.Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale
22+
>Intl : typeof Intl
23+
>Locale : new (tag?: string, options?: Intl.LocaleOptions) => Intl.Locale
24+
>"ja-JP" : "ja-JP"
25+
26+
const now = new Date();
27+
>now : Date
28+
>new Date() : Date
29+
>Date : DateConstructor
30+
31+
const num = 1000;
32+
>num : 1000
33+
>1000 : 1000
34+
35+
const bigint = 123456789123456789n;
36+
>bigint : 123456789123456789n
37+
>123456789123456789n : 123456789123456789n
38+
39+
now.toLocaleString(enUS);
40+
>now.toLocaleString(enUS) : string
41+
>now.toLocaleString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
42+
>now : Date
43+
>toLocaleString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
44+
>enUS : Intl.Locale
45+
46+
now.toLocaleDateString(enUS);
47+
>now.toLocaleDateString(enUS) : string
48+
>now.toLocaleDateString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
49+
>now : Date
50+
>toLocaleDateString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
51+
>enUS : Intl.Locale
52+
53+
now.toLocaleTimeString(enUS);
54+
>now.toLocaleTimeString(enUS) : string
55+
>now.toLocaleTimeString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
56+
>now : Date
57+
>toLocaleTimeString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
58+
>enUS : Intl.Locale
59+
60+
now.toLocaleString([deDE, jaJP]);
61+
>now.toLocaleString([deDE, jaJP]) : string
62+
>now.toLocaleString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
63+
>now : Date
64+
>toLocaleString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
65+
>[deDE, jaJP] : Intl.Locale[]
66+
>deDE : Intl.Locale
67+
>jaJP : Intl.Locale
68+
69+
now.toLocaleDateString([deDE, jaJP]);
70+
>now.toLocaleDateString([deDE, jaJP]) : string
71+
>now.toLocaleDateString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
72+
>now : Date
73+
>toLocaleDateString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
74+
>[deDE, jaJP] : Intl.Locale[]
75+
>deDE : Intl.Locale
76+
>jaJP : Intl.Locale
77+
78+
now.toLocaleTimeString([deDE, jaJP]);
79+
>now.toLocaleTimeString([deDE, jaJP]) : string
80+
>now.toLocaleTimeString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
81+
>now : Date
82+
>toLocaleTimeString : { (): string; (locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string; }
83+
>[deDE, jaJP] : Intl.Locale[]
84+
>deDE : Intl.Locale
85+
>jaJP : Intl.Locale
86+
87+
num.toLocaleString(enUS);
88+
>num.toLocaleString(enUS) : string
89+
>num.toLocaleString : { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; }
90+
>num : 1000
91+
>toLocaleString : { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; }
92+
>enUS : Intl.Locale
93+
94+
num.toLocaleString([deDE, jaJP]);
95+
>num.toLocaleString([deDE, jaJP]) : string
96+
>num.toLocaleString : { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; }
97+
>num : 1000
98+
>toLocaleString : { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; }
99+
>[deDE, jaJP] : Intl.Locale[]
100+
>deDE : Intl.Locale
101+
>jaJP : Intl.Locale
102+
103+
bigint.toLocaleString(enUS);
104+
>bigint.toLocaleString(enUS) : string
105+
>bigint.toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string
106+
>bigint : 123456789123456789n
107+
>toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string
108+
>enUS : Intl.Locale
109+
110+
bigint.toLocaleString([deDE, jaJP]);
111+
>bigint.toLocaleString([deDE, jaJP]) : string
112+
>bigint.toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string
113+
>bigint : 123456789123456789n
114+
>toLocaleString : (locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions) => string
115+
>[deDE, jaJP] : Intl.Locale[]
116+
>deDE : Intl.Locale
117+
>jaJP : Intl.Locale
118+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// @target: es2020
2+
3+
const enUS = new Intl.Locale("en-US");
4+
const deDE = new Intl.Locale("de-DE");
5+
const jaJP = new Intl.Locale("ja-JP");
6+
7+
const now = new Date();
8+
const num = 1000;
9+
const bigint = 123456789123456789n;
10+
11+
now.toLocaleString(enUS);
12+
now.toLocaleDateString(enUS);
13+
now.toLocaleTimeString(enUS);
14+
now.toLocaleString([deDE, jaJP]);
15+
now.toLocaleDateString([deDE, jaJP]);
16+
now.toLocaleTimeString([deDE, jaJP]);
17+
18+
num.toLocaleString(enUS);
19+
num.toLocaleString([deDE, jaJP]);
20+
21+
bigint.toLocaleString(enUS);
22+
bigint.toLocaleString([deDE, jaJP]);

0 commit comments

Comments
 (0)