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
a042cd68
Commit
a042cd68
authored
7 years ago
by
Zibi Braniecki
Committed by
Leo Balter
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Intl.DateTimeFormat hourCycle tests (#1265)
parent
bf8c5751
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/hourCycle.js
+84
-0
84 additions, 0 deletions
...402/DateTimeFormat/prototype/resolvedOptions/hourCycle.js
with
84 additions
and
0 deletions
test/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle.js
0 → 100644
+
84
−
0
View file @
a042cd68
// Copyright 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the license found in the LICENSE file.
/*---
esid: sec-Intl.DateTimeFormat.prototype.resolvedOptions
description: >
Intl.DateTimeFormat.prototype.resolvedOptions properly
reflect hourCycle settings.
info: >
12.4.5 Intl.DateTimeFormat.prototype.resolvedOptions()
includes: [testIntl.js]
---*/
/* Values passed via unicode extension key work */
/**
* Since at the moment of writing, CLDR does not provide data for any locale
* that would allow it to use both 0-based and 1-based hourCycles,
* we can only test if the result is within the pair of h11/h12 or h23/h24.
*/
const
hcValuePairs
=
[
[
"
h11
"
,
"
h12
"
],
[
"
h23
"
,
"
h24
"
]
];
const
hour12Values
=
[
'
h11
'
,
'
h12
'
];
const
hour24Values
=
[
'
h23
'
,
'
h24
'
];
for
(
const
hcValuePair
of
hcValuePairs
)
{
for
(
const
hcValue
of
hcValuePair
)
{
const
resolvedOptions
=
new
Intl
.
DateTimeFormat
(
`de-u-hc-
${
hcValue
}
`
,
{
hour
:
'
numeric
'
}).
resolvedOptions
();
mustHaveProperty
(
resolvedOptions
,
'
hourCycle
'
,
hcValuePair
);
mustHaveProperty
(
resolvedOptions
,
'
hour12
'
,
[
hour12Values
.
includes
(
hcValue
)]);
}
}
/* Values passed via options work */
for
(
const
hcValuePair
of
hcValuePairs
)
{
for
(
const
hcValue
of
hcValuePair
)
{
const
resolvedOptions
=
new
Intl
.
DateTimeFormat
(
`en-US`
,
{
hour
:
'
numeric
'
,
hourCycle
:
hcValue
}).
resolvedOptions
();
mustHaveProperty
(
resolvedOptions
,
'
hourCycle
'
,
hcValuePair
);
mustHaveProperty
(
resolvedOptions
,
'
hour12
'
,
[
hour12Values
.
includes
(
hcValue
)]);
}
}
/* When both extension key and option is passed, option takes precedence */
let
resolvedOptions
=
new
Intl
.
DateTimeFormat
(
`en-US-u-hc-h12`
,
{
hour
:
'
numeric
'
,
hourCycle
:
'
h23
'
}).
resolvedOptions
();
mustHaveProperty
(
resolvedOptions
,
'
hourCycle
'
,
[
'
h23
'
,
'
h24
'
]);
mustHaveProperty
(
resolvedOptions
,
'
hour12
'
,
[
false
]);
/* When hour12 and hourCycle are set, hour12 takes precedence */
resolvedOptions
=
new
Intl
.
DateTimeFormat
(
`fr`
,
{
hour
:
'
numeric
'
,
hour12
:
true
,
hourCycle
:
'
h23
'
}).
resolvedOptions
();
mustHaveProperty
(
resolvedOptions
,
'
hourCycle
'
,
[
'
h11
'
,
'
h12
'
]);
mustHaveProperty
(
resolvedOptions
,
'
hour12
'
,
[
true
]);
/* When hour12 and extension key are set, hour12 takes precedence */
resolvedOptions
=
new
Intl
.
DateTimeFormat
(
`fr-u-hc-h24`
,
{
hour
:
'
numeric
'
,
hour12
:
true
,
}).
resolvedOptions
();
mustHaveProperty
(
resolvedOptions
,
'
hourCycle
'
,
[
'
h11
'
,
'
h12
'
]);
mustHaveProperty
(
resolvedOptions
,
'
hour12
'
,
[
true
]);
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