Commit 2b352df0 authored by Frank Tang's avatar Frank Tang Committed by V8 LUCI CQ

[intl] Update Intl.Locale.weekInfo sync latest

Implement the changes in
https://github.com/tc39/proposal-intl-locale-info/pull/44
So weekInfo will return weekend as an array instead of weekendStart
and weekendEnd.

Bug: v8:11638
Change-Id: I775b003b36f67179943911faa7f77a323ad9f6f1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3307685Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78172}
parent b7558540
...@@ -116,8 +116,7 @@ ...@@ -116,8 +116,7 @@
V(_, useGrouping_string, "useGrouping") \ V(_, useGrouping_string, "useGrouping") \
V(_, unitDisplay_string, "unitDisplay") \ V(_, unitDisplay_string, "unitDisplay") \
V(_, weekday_string, "weekday") \ V(_, weekday_string, "weekday") \
V(_, weekendEnd_string, "weekendEnd") \ V(_, weekend_string, "weekend") \
V(_, weekendStart_string, "weekendStart") \
V(_, weekInfo_string, "weekInfo") \ V(_, weekInfo_string, "weekInfo") \
V(_, yearName_string, "yearName") V(_, yearName_string, "yearName")
#else // V8_INTL_SUPPORT #else // V8_INTL_SUPPORT
......
...@@ -727,27 +727,29 @@ MaybeHandle<JSObject> JSLocale::WeekInfo(Isolate* isolate, ...@@ -727,27 +727,29 @@ MaybeHandle<JSObject> JSLocale::WeekInfo(Isolate* isolate,
// Let fd be the weekday value indicating which day of the week is considered // Let fd be the weekday value indicating which day of the week is considered
// the 'first' day, for calendar purposes, in the locale. // the 'first' day, for calendar purposes, in the locale.
int32_t fd = weekdayFromEDaysOfWeek(calendar->getFirstDayOfWeek()); int32_t fd = weekdayFromEDaysOfWeek(calendar->getFirstDayOfWeek());
bool thursday_is_weekend =
(UCAL_WEEKDAY != calendar->getDayOfWeekType(UCAL_THURSDAY, status)); // Let wi be ! WeekInfoOfLocale(loc).
bool friday_is_weekend = // Let we be ! CreateArrayFromList( wi.[[Weekend]] ).
(UCAL_WEEKDAY != calendar->getDayOfWeekType(UCAL_FRIDAY, status)); Handle<FixedArray> wi = Handle<FixedArray>::cast(factory->NewFixedArray(2));
bool saturday_is_weekend = int32_t length = 0;
(UCAL_WEEKDAY != calendar->getDayOfWeekType(UCAL_SATURDAY, status)); for (int32_t i = 1; i <= 7; i++) {
bool sunday_is_weekend = UCalendarDaysOfWeek day =
(UCAL_WEEKDAY != calendar->getDayOfWeekType(UCAL_SUNDAY, status)); (i == 7) ? UCAL_SUNDAY : static_cast<UCalendarDaysOfWeek>(i + 1);
if (UCAL_WEEKDAY != calendar->getDayOfWeekType(day, status)) {
wi->set(length++, Smi::FromInt(i));
CHECK_LE(length, 2);
}
}
if (length != 2) {
wi = wi->ShrinkOrEmpty(isolate, wi, length);
}
Handle<JSArray> we = factory->NewJSArrayWithElements(wi);
if (U_FAILURE(status)) { if (U_FAILURE(status)) {
THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError), THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),
JSObject); JSObject);
} }
// Let ws be the weekday value indicating which day of the week is considered
// the starting day of the 'weekend', for calendar purposes, in the locale.
int32_t ws = thursday_is_weekend ? 4 : (friday_is_weekend ? 5 : 6);
// Let we be the weekday value indicating which day of the week is considered
// the ending day of the 'weekend', for calendar purposes, in the locale.
int32_t we = sunday_is_weekend ? 7 : (saturday_is_weekend ? 6 : 5);
// Let md be the minimal days required in the first week of a month or year, // Let md be the minimal days required in the first week of a month or year,
// for calendar purposes, in the locale. // for calendar purposes, in the locale.
int32_t md = calendar->getMinimalDaysInFirstWeek(); int32_t md = calendar->getMinimalDaysInFirstWeek();
...@@ -758,16 +760,9 @@ MaybeHandle<JSObject> JSLocale::WeekInfo(Isolate* isolate, ...@@ -758,16 +760,9 @@ MaybeHandle<JSObject> JSLocale::WeekInfo(Isolate* isolate,
factory->NewNumberFromInt(fd), Just(kDontThrow)) factory->NewNumberFromInt(fd), Just(kDontThrow))
.FromJust()); .FromJust());
// Perform ! CreateDataPropertyOrThrow(info, "weekendStart", ws). // Perform ! CreateDataPropertyOrThrow(info, "weekend", we).
CHECK(JSReceiver::CreateDataProperty( CHECK(JSReceiver::CreateDataProperty(isolate, info, factory->weekend_string(),
isolate, info, factory->weekendStart_string(), we, Just(kDontThrow))
factory->NewNumberFromInt(ws), Just(kDontThrow))
.FromJust());
// Perform ! CreateDataPropertyOrThrow(info, "weekendEnd", we).
CHECK(JSReceiver::CreateDataProperty(
isolate, info, factory->weekendEnd_string(),
factory->NewNumberFromInt(we), Just(kDontThrow))
.FromJust()); .FromJust());
// Perform ! CreateDataPropertyOrThrow(info, "minimalDays", md). // Perform ! CreateDataPropertyOrThrow(info, "minimalDays", md).
......
...@@ -22,18 +22,21 @@ function checkLocale(locale) { ...@@ -22,18 +22,21 @@ function checkLocale(locale) {
assertEquals("string", typeof(l.textInfo.direction)); assertEquals("string", typeof(l.textInfo.direction));
assertEquals("object", typeof(l.weekInfo)); assertEquals("object", typeof(l.weekInfo));
assertEquals(4, Object.keys(l.weekInfo).length); assertEquals(3, Object.keys(l.weekInfo).length);
assertEquals("number", typeof(l.weekInfo.firstDay)); assertEquals("number", typeof(l.weekInfo.firstDay));
assertTrue(l.weekInfo.firstDay >= 1); assertTrue(l.weekInfo.firstDay >= 1);
assertTrue(l.weekInfo.firstDay <= 7); assertTrue(l.weekInfo.firstDay <= 7);
assertEquals("number", typeof(l.weekInfo.weekendStart)); assertEquals("object", typeof(l.weekInfo.weekend));
assertTrue(l.weekInfo.weekendStart >= 1); let last = 0;
assertTrue(l.weekInfo.weekendStart <= 7); l.weekInfo.weekend.forEach((we) => {
// In right range
assertEquals("number", typeof(l.weekInfo.weekendEnd)); assertTrue(we >= 1);
assertTrue(l.weekInfo.weekendEnd >= 1); assertTrue(we <= 7);
assertTrue(l.weekInfo.weekendEnd <= 7); // In order
assertTrue(we >= last);
last = we;
});
assertEquals("number", typeof(l.weekInfo.minimalDays)); assertEquals("number", typeof(l.weekInfo.minimalDays));
assertTrue(l.weekInfo.minimalDays >= 1); assertTrue(l.weekInfo.minimalDays >= 1);
......
...@@ -219,6 +219,9 @@ ...@@ -219,6 +219,9 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=12209 # https://bugs.chromium.org/p/v8/issues/detail?id=12209
'intl402/Intl/supportedValuesOf/collations-accepted-by-Collator': [FAIL], 'intl402/Intl/supportedValuesOf/collations-accepted-by-Collator': [FAIL],
# https://github.com/tc39/test262/pull/3309
'intl402/Locale/prototype/weekInfo/output-object-keys': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=7831 # https://bugs.chromium.org/p/v8/issues/detail?id=7831
'language/statements/generators/generator-created-after-decl-inst': [FAIL], 'language/statements/generators/generator-created-after-decl-inst': [FAIL],
'language/expressions/generators/generator-created-after-decl-inst': [FAIL], 'language/expressions/generators/generator-created-after-decl-inst': [FAIL],
......
...@@ -357,73 +357,73 @@ KNOWN_MAPS = { ...@@ -357,73 +357,73 @@ KNOWN_MAPS = {
("read_only_space", 0x032b9): (131, "BasicBlockCountersMarkerMap"), ("read_only_space", 0x032b9): (131, "BasicBlockCountersMarkerMap"),
("read_only_space", 0x032fd): (147, "ArrayBoilerplateDescriptionMap"), ("read_only_space", 0x032fd): (147, "ArrayBoilerplateDescriptionMap"),
("read_only_space", 0x033fd): (159, "InterceptorInfoMap"), ("read_only_space", 0x033fd): (159, "InterceptorInfoMap"),
("read_only_space", 0x05c8d): (132, "PromiseFulfillReactionJobTaskMap"), ("read_only_space", 0x05c71): (132, "PromiseFulfillReactionJobTaskMap"),
("read_only_space", 0x05cb5): (133, "PromiseRejectReactionJobTaskMap"), ("read_only_space", 0x05c99): (133, "PromiseRejectReactionJobTaskMap"),
("read_only_space", 0x05cdd): (134, "CallableTaskMap"), ("read_only_space", 0x05cc1): (134, "CallableTaskMap"),
("read_only_space", 0x05d05): (135, "CallbackTaskMap"), ("read_only_space", 0x05ce9): (135, "CallbackTaskMap"),
("read_only_space", 0x05d2d): (136, "PromiseResolveThenableJobTaskMap"), ("read_only_space", 0x05d11): (136, "PromiseResolveThenableJobTaskMap"),
("read_only_space", 0x05d55): (139, "FunctionTemplateInfoMap"), ("read_only_space", 0x05d39): (139, "FunctionTemplateInfoMap"),
("read_only_space", 0x05d7d): (140, "ObjectTemplateInfoMap"), ("read_only_space", 0x05d61): (140, "ObjectTemplateInfoMap"),
("read_only_space", 0x05da5): (141, "AccessCheckInfoMap"), ("read_only_space", 0x05d89): (141, "AccessCheckInfoMap"),
("read_only_space", 0x05dcd): (142, "AccessorInfoMap"), ("read_only_space", 0x05db1): (142, "AccessorInfoMap"),
("read_only_space", 0x05df5): (143, "AccessorPairMap"), ("read_only_space", 0x05dd9): (143, "AccessorPairMap"),
("read_only_space", 0x05e1d): (144, "AliasedArgumentsEntryMap"), ("read_only_space", 0x05e01): (144, "AliasedArgumentsEntryMap"),
("read_only_space", 0x05e45): (145, "AllocationMementoMap"), ("read_only_space", 0x05e29): (145, "AllocationMementoMap"),
("read_only_space", 0x05e6d): (148, "AsmWasmDataMap"), ("read_only_space", 0x05e51): (148, "AsmWasmDataMap"),
("read_only_space", 0x05e95): (149, "AsyncGeneratorRequestMap"), ("read_only_space", 0x05e79): (149, "AsyncGeneratorRequestMap"),
("read_only_space", 0x05ebd): (150, "BreakPointMap"), ("read_only_space", 0x05ea1): (150, "BreakPointMap"),
("read_only_space", 0x05ee5): (151, "BreakPointInfoMap"), ("read_only_space", 0x05ec9): (151, "BreakPointInfoMap"),
("read_only_space", 0x05f0d): (152, "CachedTemplateObjectMap"), ("read_only_space", 0x05ef1): (152, "CachedTemplateObjectMap"),
("read_only_space", 0x05f35): (154, "ClassPositionsMap"), ("read_only_space", 0x05f19): (154, "ClassPositionsMap"),
("read_only_space", 0x05f5d): (155, "DebugInfoMap"), ("read_only_space", 0x05f41): (155, "DebugInfoMap"),
("read_only_space", 0x05f85): (158, "FunctionTemplateRareDataMap"), ("read_only_space", 0x05f69): (158, "FunctionTemplateRareDataMap"),
("read_only_space", 0x05fad): (160, "InterpreterDataMap"), ("read_only_space", 0x05f91): (160, "InterpreterDataMap"),
("read_only_space", 0x05fd5): (161, "ModuleRequestMap"), ("read_only_space", 0x05fb9): (161, "ModuleRequestMap"),
("read_only_space", 0x05ffd): (162, "PromiseCapabilityMap"), ("read_only_space", 0x05fe1): (162, "PromiseCapabilityMap"),
("read_only_space", 0x06025): (163, "PromiseReactionMap"), ("read_only_space", 0x06009): (163, "PromiseReactionMap"),
("read_only_space", 0x0604d): (164, "PropertyDescriptorObjectMap"), ("read_only_space", 0x06031): (164, "PropertyDescriptorObjectMap"),
("read_only_space", 0x06075): (165, "PrototypeInfoMap"), ("read_only_space", 0x06059): (165, "PrototypeInfoMap"),
("read_only_space", 0x0609d): (166, "RegExpBoilerplateDescriptionMap"), ("read_only_space", 0x06081): (166, "RegExpBoilerplateDescriptionMap"),
("read_only_space", 0x060c5): (167, "ScriptMap"), ("read_only_space", 0x060a9): (167, "ScriptMap"),
("read_only_space", 0x060ed): (168, "ScriptOrModuleMap"), ("read_only_space", 0x060d1): (168, "ScriptOrModuleMap"),
("read_only_space", 0x06115): (169, "SourceTextModuleInfoEntryMap"), ("read_only_space", 0x060f9): (169, "SourceTextModuleInfoEntryMap"),
("read_only_space", 0x0613d): (170, "StackFrameInfoMap"), ("read_only_space", 0x06121): (170, "StackFrameInfoMap"),
("read_only_space", 0x06165): (171, "TemplateObjectDescriptionMap"), ("read_only_space", 0x06149): (171, "TemplateObjectDescriptionMap"),
("read_only_space", 0x0618d): (172, "Tuple2Map"), ("read_only_space", 0x06171): (172, "Tuple2Map"),
("read_only_space", 0x061b5): (173, "WasmContinuationObjectMap"), ("read_only_space", 0x06199): (173, "WasmContinuationObjectMap"),
("read_only_space", 0x061dd): (174, "WasmExceptionTagMap"), ("read_only_space", 0x061c1): (174, "WasmExceptionTagMap"),
("read_only_space", 0x06205): (175, "WasmIndirectFunctionTableMap"), ("read_only_space", 0x061e9): (175, "WasmIndirectFunctionTableMap"),
("read_only_space", 0x0622d): (193, "SloppyArgumentsElementsMap"), ("read_only_space", 0x06211): (193, "SloppyArgumentsElementsMap"),
("read_only_space", 0x06255): (224, "DescriptorArrayMap"), ("read_only_space", 0x06239): (224, "DescriptorArrayMap"),
("read_only_space", 0x0627d): (229, "UncompiledDataWithoutPreparseDataMap"), ("read_only_space", 0x06261): (229, "UncompiledDataWithoutPreparseDataMap"),
("read_only_space", 0x062a5): (228, "UncompiledDataWithPreparseDataMap"), ("read_only_space", 0x06289): (228, "UncompiledDataWithPreparseDataMap"),
("read_only_space", 0x062cd): (246, "OnHeapBasicBlockProfilerDataMap"), ("read_only_space", 0x062b1): (246, "OnHeapBasicBlockProfilerDataMap"),
("read_only_space", 0x062f5): (207, "TurbofanBitsetTypeMap"), ("read_only_space", 0x062d9): (207, "TurbofanBitsetTypeMap"),
("read_only_space", 0x0631d): (211, "TurbofanUnionTypeMap"), ("read_only_space", 0x06301): (211, "TurbofanUnionTypeMap"),
("read_only_space", 0x06345): (210, "TurbofanRangeTypeMap"), ("read_only_space", 0x06329): (210, "TurbofanRangeTypeMap"),
("read_only_space", 0x0636d): (208, "TurbofanHeapConstantTypeMap"), ("read_only_space", 0x06351): (208, "TurbofanHeapConstantTypeMap"),
("read_only_space", 0x06395): (209, "TurbofanOtherNumberConstantTypeMap"), ("read_only_space", 0x06379): (209, "TurbofanOtherNumberConstantTypeMap"),
("read_only_space", 0x063bd): (242, "InternalClassMap"), ("read_only_space", 0x063a1): (242, "InternalClassMap"),
("read_only_space", 0x063e5): (253, "SmiPairMap"), ("read_only_space", 0x063c9): (253, "SmiPairMap"),
("read_only_space", 0x0640d): (252, "SmiBoxMap"), ("read_only_space", 0x063f1): (252, "SmiBoxMap"),
("read_only_space", 0x06435): (216, "ExportedSubClassBaseMap"), ("read_only_space", 0x06419): (216, "ExportedSubClassBaseMap"),
("read_only_space", 0x0645d): (217, "ExportedSubClassMap"), ("read_only_space", 0x06441): (217, "ExportedSubClassMap"),
("read_only_space", 0x06485): (222, "AbstractInternalClassSubclass1Map"), ("read_only_space", 0x06469): (222, "AbstractInternalClassSubclass1Map"),
("read_only_space", 0x064ad): (223, "AbstractInternalClassSubclass2Map"), ("read_only_space", 0x06491): (223, "AbstractInternalClassSubclass2Map"),
("read_only_space", 0x064d5): (192, "InternalClassWithSmiElementsMap"), ("read_only_space", 0x064b9): (192, "InternalClassWithSmiElementsMap"),
("read_only_space", 0x064fd): (243, "InternalClassWithStructElementsMap"), ("read_only_space", 0x064e1): (243, "InternalClassWithStructElementsMap"),
("read_only_space", 0x06525): (218, "ExportedSubClass2Map"), ("read_only_space", 0x06509): (218, "ExportedSubClass2Map"),
("read_only_space", 0x0654d): (254, "SortStateMap"), ("read_only_space", 0x06531): (254, "SortStateMap"),
("read_only_space", 0x06575): (232, "CallRefDataMap"), ("read_only_space", 0x06559): (232, "CallRefDataMap"),
("read_only_space", 0x0659d): (146, "AllocationSiteWithWeakNextMap"), ("read_only_space", 0x06581): (146, "AllocationSiteWithWeakNextMap"),
("read_only_space", 0x065c5): (146, "AllocationSiteWithoutWeakNextMap"), ("read_only_space", 0x065a9): (146, "AllocationSiteWithoutWeakNextMap"),
("read_only_space", 0x065ed): (137, "LoadHandler1Map"), ("read_only_space", 0x065d1): (137, "LoadHandler1Map"),
("read_only_space", 0x06615): (137, "LoadHandler2Map"), ("read_only_space", 0x065f9): (137, "LoadHandler2Map"),
("read_only_space", 0x0663d): (137, "LoadHandler3Map"), ("read_only_space", 0x06621): (137, "LoadHandler3Map"),
("read_only_space", 0x06665): (138, "StoreHandler0Map"), ("read_only_space", 0x06649): (138, "StoreHandler0Map"),
("read_only_space", 0x0668d): (138, "StoreHandler1Map"), ("read_only_space", 0x06671): (138, "StoreHandler1Map"),
("read_only_space", 0x066b5): (138, "StoreHandler2Map"), ("read_only_space", 0x06699): (138, "StoreHandler2Map"),
("read_only_space", 0x066dd): (138, "StoreHandler3Map"), ("read_only_space", 0x066c1): (138, "StoreHandler3Map"),
("map_space", 0x02119): (1057, "ExternalMap"), ("map_space", 0x02119): (1057, "ExternalMap"),
("map_space", 0x02141): (2114, "JSMessageObjectMap"), ("map_space", 0x02141): (2114, "JSMessageObjectMap"),
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment