Skip to content

Commit 97a841b

Browse files
authored
[wasm][debugger][test] Change DateTime format test (#42136)
* Changing DateTime format tests, we cannot test how we were doing before because wasm and dotnet core uses different versions of ICU. * Changing what @radical suggested.
1 parent 4bc91cb commit 97a841b

File tree

2 files changed

+23
-33
lines changed

2 files changed

+23
-33
lines changed

src/mono/wasm/debugger/DebuggerTestSuite/DateTimeTests.cs

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@ public class DateTimeList : DebuggerTestBase
1212
{
1313

1414
[Theory]
15-
[InlineData("en-US")]
16-
17-
// Currently not passing tests. Issue #19743
18-
// [InlineData ("ja-JP")]
19-
// [InlineData ("es-ES")]
20-
//[InlineData ("de-DE")]
21-
//[InlineData ("ka-GE")]
22-
//[InlineData ("hu-HU")]
23-
public async Task CheckDateTimeLocale(string locale)
15+
[InlineData("en-US", "dddd, MMMM d, yyyy h:mm:ss tt", "dddd, MMMM d, yyyy", "h:mm:ss tt", "M/d/yyyy", "h:mm tt")]
16+
[InlineData("ja-JP", "yyyy年M月d日dddd H:mm:ss", "yyyy年M月d日dddd", "H:mm:ss", "yyyy/MM/dd", "H:mm")]
17+
[InlineData("es-ES", "dddd, d 'de' MMMM 'de' yyyy H:mm:ss", "dddd, d 'de' MMMM 'de' yyyy", "H:mm:ss", "d/M/yyyy", "H:mm")]
18+
[InlineData("de-DE", "dddd, d. MMMM yyyy HH:mm:ss", "dddd, d. MMMM yyyy", "HH:mm:ss", "dd.MM.yyyy", "HH:mm")]
19+
public async Task CheckDateTimeLocale(string locale, string fdtp, string ldp, string ltp, string sdp, string stp)
2420
{
2521
var insp = new Inspector();
2622
var scripts = SubscribeToScripts(insp);
@@ -38,26 +34,20 @@ await insp.Ready(async (cli, token) =>
3834
$"'{locale}'); }}, 1);",
3935
debugger_test_loc, 25, 12, "LocaleTest",
4036
locals_fn: async (locals) =>
41-
{
42-
DateTimeFormatInfo dtfi = CultureInfo.GetCultureInfo(locale).DateTimeFormat;
43-
CultureInfo.CurrentCulture = new CultureInfo(locale, false);
44-
DateTime dt = new DateTime(2020, 1, 2, 3, 4, 5);
45-
string dt_str = dt.ToString();
46-
47-
var fdtp = dtfi.FullDateTimePattern;
48-
var ldp = dtfi.LongDatePattern;
49-
var ltp = dtfi.LongTimePattern;
50-
var sdp = dtfi.ShortDatePattern;
51-
var stp = dtfi.ShortTimePattern;
52-
53-
CheckString(locals, "fdtp", fdtp);
54-
CheckString(locals, "ldp", ldp);
55-
CheckString(locals, "ltp", ltp);
56-
CheckString(locals, "sdp", sdp);
57-
CheckString(locals, "stp", stp);
58-
await CheckDateTime(locals, "dt", dt);
59-
CheckString(locals, "dt_str", dt_str);
60-
}
37+
{
38+
DateTimeFormatInfo dtfi = CultureInfo.GetCultureInfo(locale).DateTimeFormat;
39+
CultureInfo.CurrentCulture = new CultureInfo(locale, false);
40+
41+
await CheckProps(locals, new
42+
{
43+
fdtp = TString(fdtp),
44+
ldp = TString(ldp),
45+
ltp = TString(ltp),
46+
sdp = TString(sdp),
47+
stp = TString(stp),
48+
dt = TDateTime(new DateTime(2020, 1, 2, 3, 4, 5))
49+
}, "locals", num_fields: 8);
50+
}
6151
);
6252

6353
});

src/mono/wasm/debugger/tests/debugger-datetime-test.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace DebuggerTests
77
{
88
public class DateTimeTest
99
{
10-
public static string LocaleTest(string locale)
10+
public static void LocaleTest(string locale)
1111
{
1212
CultureInfo.CurrentCulture = new CultureInfo(locale, false);
1313
Console.WriteLine("CurrentCulture is {0}", CultureInfo.CurrentCulture.Name);
@@ -20,10 +20,10 @@ public static string LocaleTest(string locale)
2020
var stp = dtfi.ShortTimePattern;
2121

2222
DateTime dt = new DateTime(2020, 1, 2, 3, 4, 5);
23-
string dt_str = dt.ToString();
24-
Console.WriteLine("Current time is {0}", dt_str);
2523

26-
return dt_str;
24+
Console.WriteLine("Current time is {0}", dt);
25+
26+
return;
2727
}
2828
}
2929
}

0 commit comments

Comments
 (0)