Skip to content

Commit 93fc05c

Browse files
authored
[browser][HybridGlobalization] Fix incorrect value in FirstDayOfWeek test (#93595)
* Prevent from returning Sunday randomly. * Unify logic. * Add wrap for exception, revert returning Sunday on error.
1 parent 0f4196f commit 93fc05c

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoFirstDayOfWeek.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ public static IEnumerable<object[]> FirstDayOfWeek_Get_TestData()
1212
{
1313
yield return new object[] { DateTimeFormatInfo.InvariantInfo, DayOfWeek.Sunday, "invariant" };
1414
yield return new object[] { new CultureInfo("en-US", false).DateTimeFormat, DayOfWeek.Sunday, "en-US" };
15-
// ActiveIssue: https://github.com/dotnet/runtime/issues/93354
16-
if (!PlatformDetection.IsHybridGlobalizationOnBrowser)
17-
yield return new object[] { new CultureInfo("fr-FR", false).DateTimeFormat, DayOfWeek.Monday, "fr-FR" };
15+
yield return new object[] { new CultureInfo("fr-FR", false).DateTimeFormat, DayOfWeek.Monday, "fr-FR" };
1816
}
1917

2018
public static IEnumerable<object[]> FirstDayOfWeek_Get_TestData_HybridGlobalization()

src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Browser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private static unsafe int GetFirstWeekOfYear(string localeName)
4848
if (exception != 0)
4949
{
5050
// Failed, just use 0
51-
Debug.Fail($"[CultureData.GetFirstWeekOfYear()] failed with {ex_result}");
51+
Debug.Fail($"[CultureData.GetFirstDayOfWeek()] failed with {ex_result}");
5252
return 0;
5353
}
5454
return result;

src/mono/wasm/runtime/hybrid-globalization/change-case.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export function mono_wasm_change_case_invariant(src: number, srcLength: number,
7575
}
7676
}
7777
}
78+
wrap_no_error_root(is_exception, exceptionRoot);
7879
}
7980
catch (ex: any) {
8081
wrap_error_root(is_exception, ex, exceptionRoot);

src/mono/wasm/runtime/hybrid-globalization/locales.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
import { wrap_error_root } from "../invoke-js";
4+
import { wrap_error_root, wrap_no_error_root } from "../invoke-js";
55
import { mono_wasm_new_external_root } from "../roots";
66
import { monoStringToString } from "../strings";
77
import { Int32Ptr } from "../types/emscripten";
@@ -15,6 +15,7 @@ export function mono_wasm_get_first_day_of_week(culture: MonoStringRef, isExcept
1515
try {
1616
const cultureName = monoStringToString(cultureRoot);
1717
const canonicalLocale = normalizeLocale(cultureName);
18+
wrap_no_error_root(isException, exceptionRoot);
1819
return getFirstDayOfWeek(canonicalLocale);
1920
}
2021
catch (ex: any) {
@@ -34,6 +35,7 @@ export function mono_wasm_get_first_week_of_year(culture: MonoStringRef, isExcep
3435
try {
3536
const cultureName = monoStringToString(cultureRoot);
3637
const canonicalLocale = normalizeLocale(cultureName);
38+
wrap_no_error_root(isException, exceptionRoot);
3739
return getFirstWeekOfYear(canonicalLocale);
3840
}
3941
catch (ex: any) {

0 commit comments

Comments
 (0)