Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
test262
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pmaksimo
test262
Commits
0ec5b02a
Commit
0ec5b02a
authored
7 years ago
by
André Bargull
Committed by
Rick Waldron
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add test case for tc39/ecma402#204
parent
2cb0028b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/intl402/DateTimeFormat/prototype/resolvedOptions/resolved-locale-with-hc-unicode.js
+87
-0
87 additions, 0 deletions
...totype/resolvedOptions/resolved-locale-with-hc-unicode.js
with
87 additions
and
0 deletions
test/intl402/DateTimeFormat/prototype/resolvedOptions/resolved-locale-with-hc-unicode.js
0 → 100644
+
87
−
0
View file @
0ec5b02a
// Copyright 2018 André Bargull. All rights reserved.
// This code is governed by the license found in the LICENSE file.
/*---
esid: sec-Intl.DateTimeFormat.prototype.resolvedOptions
description: >
The resolved locale doesn't include a hc Unicode extension value if the
hour12 or hourCycle option is also present.
info: |
12.1.1 InitializeDateTimeFormat(dateTimeFormat, locales, options)
...
6. Let hour12 be ? GetOption(options, "hour12", "boolean", undefined, undefined).
7. Let hourCycle be ? GetOption(options, "hourCycle", "string", « "h11", "h12", "h23", "h24" », undefined).
8. If hour12 is not undefined, then
a. Let hourCycle be null.
9. Set opt.[[hc]] to hourCycle.
...
9.2.6 ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData)
...
8. For each element key of relevantExtensionKeys in List order, do
...
i. If options has a field [[<key>]], then
i. Let optionsValue be options.[[<key>]].
ii. Assert: Type(optionsValue) is either String, Undefined, or Null.
iii. If keyLocaleData contains optionsValue, then
1. If SameValue(optionsValue, value) is false, then
a. Let value be optionsValue.
b. Let supportedExtensionAddition be "".
...
---*/
var
defaultLocale
=
new
Intl
.
DateTimeFormat
().
resolvedOptions
().
locale
;
var
defaultLocaleWithHourCycle
=
defaultLocale
+
"
-u-hc-h11
"
;
function
assertLocale
(
locale
,
expectedLocale
,
options
,
message
)
{
var
resolved
=
new
Intl
.
DateTimeFormat
(
locale
,
{
hour
:
"
2-digit
"
,
hour12
:
options
.
hour12
,
hourCycle
:
options
.
hourCycle
,
}).
resolvedOptions
();
assert
.
sameValue
(
resolved
.
locale
,
expectedLocale
,
message
+
"
(With hour option.)
"
);
// Also test the case when no hour option is present at all.
// The resolved options don't include hour12 and hourCycle if the date-time
// formatter doesn't include an hour option. This restriction doesn't apply
// to the hc Unicode extension value.
resolved
=
new
Intl
.
DateTimeFormat
(
locale
,
{
hour12
:
options
.
hour12
,
hourCycle
:
options
.
hourCycle
,
}).
resolvedOptions
();
assert
.
sameValue
(
resolved
.
locale
,
expectedLocale
,
message
+
"
(Without hour option.)
"
);
}
assertLocale
(
defaultLocaleWithHourCycle
,
defaultLocale
,
{
hour12
:
false
,
hourCycle
:
"
h23
"
,
},
"
hour12 and hourCycle options and hc Unicode extension value are present.
"
);
assertLocale
(
defaultLocaleWithHourCycle
,
defaultLocale
,
{
hour12
:
false
,
},
"
hour12 option and hc Unicode extension value are present.
"
);
assertLocale
(
defaultLocaleWithHourCycle
,
defaultLocale
,
{
hourCycle
:
"
h23
"
,
},
"
hourCycle option and hc Unicode extension value are present.
"
);
assertLocale
(
defaultLocaleWithHourCycle
,
defaultLocaleWithHourCycle
,
{
},
"
Only hc Unicode extension value is present.
"
);
// And make sure the hc Unicode extension doesn't get added if it's not present
// in the requested locale.
assertLocale
(
defaultLocale
,
defaultLocale
,
{
hour12
:
false
,
hourCycle
:
"
h23
"
,
},
"
hour12 and hourCycle options are present, but no hc Unicode extension value.
"
);
assertLocale
(
defaultLocale
,
defaultLocale
,
{
hour12
:
false
,
},
"
hourCycle option is present, but no hc Unicode extension value.
"
);
assertLocale
(
defaultLocale
,
defaultLocale
,
{
hourCycle
:
"
h23
"
,
},
"
hourCycle option is present, but no hc Unicode extension value.
"
);
assertLocale
(
defaultLocale
,
defaultLocale
,
{
},
"
No options are present and no hc Unicode extension value.
"
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment