Consider helpers for `formatToParts` assertions
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- testing
Research direction
Start in the harness directory and inspect the formatToParts example at test/intl402/DateTimeFormat/prototype/formatToParts/dayPeriod-long-en.js. Compare the listed existing assertion helpers across the relevant tests and determine whether a shared helper API fits. Done means the helper scope and usage are consistent for the targeted formatToParts assertions.
Written by the indexing model from the issue text.
Description
(originally posted by @gibson042 in https://github.com/tc39/test262/pull/4447#discussion_r2028896223)
I wonder if a harness file should define some formatToParts assertion helpers:
function assertFormatPart(part, type, value, label) {
var suffix = label ? ', ' + label : '';
assert.sameValue(part.type, type, 'part type' + suffix);
if (value === undefined) return;
assert.sameValue(part.value, value, 'part value' + suffix);
}
function assertFormatParts(parts, expectations, label) {
var suffix = label ? ', ' + label : '';
assert.sameValue(parts.length, expectations.length, 'parts count' + suffix);
for (var i = 0; i < parts.length; i++) {
assertFormatPart(parts[i], expectations[i][0], expectations[i][1],
suffix && (suffix + ' part ' + i));
}
}
for use in files like test/intl402/DateTimeFormat/prototype/formatToParts/dayPeriod-long-en.js:
for (var h = 0; h < 24; h++) {
var parts = long.formatToParts(inputs[h]);
assertFormatParts(parts, [['dayPeriod']], 'hour ' + h + ' long dayPeriod');
…
var partsNumeric = longNumeric.formatToParts(inputs[h]);
assertFormatParts(partsNumeric,
[['hour', String((h % 12) || 12)], ['literal'], ['dayPeriod']],
'numeric hour ' + h + ' must precede long dayPeriod');
counts[i]++;
prevDayPeriod = dayPeriod;
}
Similar functions already exist in various files, with names like
assertPartsassertSamePartscomparecompareFormatToPartsSnapshotformatAsStringpartsEqualsreduceserializeTypesAndLiteralverifyFormatParts- etc.
- Dominant language
- JavaScript
- Stars
- 2.9k
- Forks
- 571
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 13
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tc39/test262
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tc39/test262#5190 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
tc39/test262#5185 · 7 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
tc39/test262#5159 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tc39/test262#5133 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 Under an hour Newbie friendliness 82/100
Leonxlnx/taste-skill#216 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
all-contributors/cli#690 ·
Maintainers usually reply within 1 day
-
area: ui Bug Payload OSS
Difficulty 1/5 Under an hour Newbie friendliness 88/100
payloadcms/payload#19839 ·
Maintainers usually reply within 1 day