Skip to content
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

Fix mutation coverage #485

Merged
merged 2 commits into from
Sep 3, 2024
Merged

Fix mutation coverage #485

merged 2 commits into from
Sep 3, 2024

Conversation

veewee
Copy link
Collaborator

@veewee veewee commented Aug 30, 2024

This PR fixes the infection errors in CI (related to the DateTime component)

@veewee veewee force-pushed the mutation-coverage branch 4 times, most recently from 8cb2355 to 701f013 Compare August 30, 2024 13:18
@coveralls
Copy link

coveralls commented Aug 30, 2024

Pull Request Test Coverage Report for Build 10633692680

Details

  • 15 of 15 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.6%) to 98.717%

Totals Coverage Status
Change from base Build 9977367388: 1.6%
Covered Lines: 5311
Relevant Lines: 5380

💛 - Coveralls

@veewee veewee force-pushed the mutation-coverage branch from 701f013 to e526235 Compare August 30, 2024 13:23
@veewee veewee force-pushed the mutation-coverage branch from e526235 to 59cddb9 Compare August 30, 2024 13:37
@@ -32,7 +32,8 @@
},
"DecrementInteger": {
"ignore": [
"Psl\\DataStructure\\PriorityQueue::peek"
"Psl\\DataStructure\\PriorityQueue::peek",
"Psl\\DateTime\\TemporalConvenienceMethodsTrait::since"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> Altering since() causes timeouts in the async component.

@@ -58,6 +60,7 @@
},
"Throw_": {
"ignore": [
"Psl\\DateTime\\DateTime::__construct",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> It's impossible to test the InvalidArgumentExceptions that are being thrown. I'm wondering if it would make more sense to use the same checks from fromParts in the constructor directly.

The constructor does a range check, the fromParts does a calendar (intl) check.
Both result in different type of exceptions with different messages.

Would it make sense to always go for the fromParts() checks instead?

* @psalm-suppress ImpureMethodCall
*/
return Internal\create_intl_date_formatter($date_style, $time_style, null, $timezone ?? $this->getTimezone(), $locale)
->format($timestamp->getSeconds() + ($timestamp->getNanoseconds() / NANOSECONDS_PER_SECOND));
->format($timestamp->getSeconds());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default pattern does not represent nanoseconds.
it is not possible (to my knowledge) to get a timestamp to contain nanoseconds > NANOSECONDS_PER_SECOND - 1.

I did not find a case to cover this calculation


// $end is the sizeof($values), use static value for better performance.
$end = 3;
while ($end > 0 && $values[$end - 1][0] === '0') {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mutating the while's results in timeouts. I decided to go for a couple of simple if statements instead that results in the same behaviour.

@veewee veewee requested a review from azjezz August 30, 2024 13:43
@veewee veewee added this to the 3.0.0 milestone Sep 3, 2024
@veewee veewee merged commit 8e8ca30 into azjezz:next Sep 3, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants