Skip to content

Commit 38662ef

Browse files
authored
Merge pull request chakra-core#6660 from rhuanjl/fixIntlPluralRulesAbort
Fix incorrect abort in EntryIntl_PluralRulesSelect
2 parents c091b36 + 95908ad commit 38662ef

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/Runtime/Library/IntlEngineInterfaceExtensionObject.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,8 +3128,10 @@ DEFINE_ISXLOCALEAVAILABLE(PR, uloc)
31283128
}, scriptContext->GetRecycler(), &formattedN, &formattedNLength);
31293129

31303130
double nWithOptions = unum_parseDouble(*nf, reinterpret_cast<UChar *>(formattedN), formattedNLength, nullptr, &status);
3131-
double roundtripDiff = n - nWithOptions;
3132-
ICU_ASSERT(status, roundtripDiff <= 1.0 && roundtripDiff >= -1.0);
3131+
3132+
ICU_ASSERT(status, (n > 0.0 && nWithOptions <= n && nWithOptions >= 0.0) ||
3133+
(n < 0.0 && nWithOptions >= n && nWithOptions <= 0) ||
3134+
(n == 0.0 && nWithOptions == 0));
31333135

31343136
char16 *selected = nullptr;
31353137
int selectedLength = 0;

test/Intl/PluralRules.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56

@@ -159,6 +160,9 @@ testRunner.runTests([
159160
test({ maximumSignificantDigits: 1 }, 1.0, "one");
160161
test({ maximumSignificantDigits: 1 }, 1.1, "one");
161162
test({ maximumSignificantDigits: 1 }, 1.001, "one");
163+
test({ maximumSignificantDigits: 1 }, 110.001, "other");
164+
test({ maximumSignificantDigits: 1 }, -110.001, "other");
165+
test({ maximumSignificantDigits: 1 }, -1, "one");
162166

163167
// significantDigits should override fractionDigits and integerDigits
164168
test({ maximumSignificantDigits: 2, maximumFractionDigits: 0 }, 1.1, "other");

0 commit comments

Comments
 (0)