-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DurationFormat Coverage #3592
Merged
Ms2ger
merged 9 commits into
tc39:main
from
romulocintra:update-duration-format-coverage-methods
Jul 13, 2022
Merged
DurationFormat Coverage #3592
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
89ab2fd
increase coverage Intl.DurationFormat
romulocintra ce16ee7
Merge branch 'update-duration-format-coverage-methods' of github.com:…
romulocintra 22bc8a1
Update test/intl402/DurationFormat/prototype/format/length.js
romulocintra 8ff3ba6
Update test/intl402/DurationFormat/prototype/format/length.js
romulocintra a5e5530
Update test/intl402/DurationFormat/prototype/format/throw-invoked-as-…
romulocintra eb1429f
Update test/intl402/DurationFormat/prototype/formatToParts/not-a-cons…
romulocintra c34a8f6
Update test/intl402/DurationFormat/prototype/formatToParts/not-a-cons…
romulocintra 0025aab
address reviews
romulocintra b1404df
Update branding tests
romulocintra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-Intl.DurationFormat.prototype.format | ||
description: Verifies the branding check for the "format" function of the DurationFormat prototype object. | ||
features: [Intl.DurationFormat] | ||
---*/ | ||
|
||
const format = Intl.DurationFormat.prototype.format; | ||
|
||
assert.sameValue(typeof format, "function"); | ||
|
||
assert.throws(TypeError, () => format.call(undefined), "undefined"); | ||
assert.throws(TypeError, () => format.call(null), "null"); | ||
assert.throws(TypeError, () => format.call(true), "true"); | ||
assert.throws(TypeError, () => format.call(""), "empty string"); | ||
assert.throws(TypeError, () => format.call(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => format.call(1), "1"); | ||
assert.throws(TypeError, () => format.call({}), "plain object"); | ||
assert.throws(TypeError, () => format.call(Intl.DurationFormat), "Intl.DurationFormat"); | ||
assert.throws(TypeError, () => format.call(Intl.DurationFormat.prototype), "Intl.DurationFormat.prototype"); |
25 changes: 25 additions & 0 deletions
25
test/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-Intl.DurationFormat.prototype.format | ||
description: > | ||
"format" basic tests for invalid arguments that should throw TypeError exception. | ||
info: | | ||
Intl.DurationFormat.prototype.format(duration) | ||
(...) | ||
3. Let record be ? ToDurationRecord(duration) | ||
---*/ | ||
|
||
const df = new Intl.DurationFormat(); | ||
|
||
assert.throws(TypeError, () => { df.format(undefined) }, "undefined" ); | ||
assert.throws(TypeError, () => { df.format(null) }, "null"); | ||
assert.throws(TypeError, () => { df.format(true) }, "true"); | ||
assert.throws(TypeError, () => { df.format(-12) }, "-12"); | ||
assert.throws(TypeError, () => { df.format(-12n) }, "-12n"); | ||
assert.throws(TypeError, () => { df.format(1) }, "1"); | ||
assert.throws(TypeError, () => { df.format(2n) }, "2n"); | ||
assert.throws(TypeError, () => { df.format({}) }, "plain object"); | ||
Ms2ger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert.throws(TypeError, () => { df.format(Symbol())}, "symbol"); | ||
assert.throws(TypeError, () => { df.format("bad string")}, "bad string"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/intl402/DurationFormat/prototype/format/not-a-constructor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-Intl.DurationFormat.prototype.format | ||
description: > | ||
Intl.DurationFormat.prototype.format does not implement [[Construct]], is not new-able | ||
info: | | ||
Built-in function objects that are not identified as constructors do not implement the | ||
[[Construct]] internal method unless otherwise specified in the description of a particular | ||
function. | ||
includes: [isConstructor.js] | ||
features: [Reflect.construct, Intl.DurationFormat] | ||
---*/ | ||
|
||
assert.throws(TypeError, () => { | ||
new Intl.DurationFormat.prototype.format(); | ||
}, "Calling as constructor"); | ||
|
||
assert.sameValue(isConstructor(Intl.DurationFormat.prototype.format), false, | ||
"isConstructor(Intl.DurationFormat.prototype.format)"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
test/intl402/DurationFormat/prototype/formatToParts/branding.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-Intl.DurationFormat.prototype.formatToParts | ||
description: Verifies the branding check for the "formatToParts" function of the DurationFormat prototype object. | ||
features: [Intl.DurationFormat] | ||
---*/ | ||
|
||
const formatToParts = Intl.DurationFormat.prototype.formatToParts; | ||
|
||
assert.sameValue(typeof formatToParts, "function"); | ||
|
||
assert.throws(TypeError, () => formatToParts.call(undefined), "undefined"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as with |
||
assert.throws(TypeError, () => formatToParts.call(null), "null"); | ||
assert.throws(TypeError, () => formatToParts.call(true), "true"); | ||
assert.throws(TypeError, () => formatToParts.call(""), "empty string"); | ||
assert.throws(TypeError, () => formatToParts.call(Symbol()), "symbol"); | ||
assert.throws(TypeError, () => formatToParts.call(1), "1"); | ||
assert.throws(TypeError, () => formatToParts.call({}), "plain object"); | ||
assert.throws(TypeError, () => formatToParts.call(Intl.DurationFormat), "Intl.DurationFormat"); | ||
assert.throws(TypeError, () => formatToParts.call(Intl.DurationFormat.prototype), "Intl.DurationFormat.prototype"); |
25 changes: 25 additions & 0 deletions
25
test/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-Intl.DurationFormat.prototype.formatToParts | ||
description: > | ||
"formatToParts" basic tests for invalid arguments that should throw TypeError exception. | ||
info: | | ||
Intl.DurationFormat.prototype.formatToParts(duration) | ||
(...) | ||
3. Let record be ? ToDurationRecord(duration) | ||
---*/ | ||
|
||
const df = new Intl.DurationFormat(); | ||
|
||
assert.throws(TypeError, () => { df.formatToParts(undefined) }, "undefined" ); | ||
assert.throws(TypeError, () => { df.formatToParts(null) }, "null"); | ||
assert.throws(TypeError, () => { df.formatToParts(true) }, "true"); | ||
assert.throws(TypeError, () => { df.formatToParts(-12) }, "-12"); | ||
assert.throws(TypeError, () => { df.formatToParts(-12n) }, "-12n"); | ||
assert.throws(TypeError, () => { df.formatToParts(1) }, "1"); | ||
assert.throws(TypeError, () => { df.formatToParts(2n) }, "2n"); | ||
assert.throws(TypeError, () => { df.formatToParts({}) }, "plain object"); | ||
Ms2ger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert.throws(TypeError, () => { df.formatToParts(Symbol())}, "symbol"); | ||
assert.throws(TypeError, () => { df.formatToParts("bad string")}, "bad string"); |
21 changes: 21 additions & 0 deletions
21
test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-Intl.DurationFormat.prototype.format | ||
romulocintra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: > | ||
Intl.DurationFormat.prototype.format does not implement [[Construct]], is not new-able | ||
romulocintra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
info: | | ||
Built-in function objects that are not identified as constructors do not implement the | ||
[[Construct]] internal method unless otherwise specified in the description of a particular | ||
function. | ||
includes: [isConstructor.js] | ||
features: [Reflect.construct, Intl.DurationFormat] | ||
---*/ | ||
|
||
assert.throws(TypeError, () => { | ||
new Intl.DurationFormat.prototype.formatToParts(); | ||
}, "Calling as constructor"); | ||
|
||
assert.sameValue(isConstructor(Intl.DurationFormat.prototype.formatToParts), false, | ||
"isConstructor(Intl.DurationFormat.prototype.formatToParts)"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are gonna throw anyway even if there's no brand check, because you're not passing a valid object as the duration argument. Compare 9762bc9.