Open boretti opened 1 month ago
This sounds like a great addition and is right in the spirit of what the method expression mutator is supposed to do. However, I don't see why we should stop at these four. For some use cases, people might be more interested in smaller or larger units of time.
This would be my suggestion.
What do you think?
I think this is a good idea to have all these methods supported. I would also support both the get
and the set
version of the method.
I'm personally less in favor of getxxx
mutations. Could you provide an example where it would be useful and is not covered by a setXxx
mutation?
I have the following example for get
mutation, which are mostly business rules based on the date or the time :
get
:
if(currentDate.getFullYear() === 2025 && sex === 'F' && birthDate.getFullYear() === 1961) {
// Retirement age is
} else ...
getHours()
and getMinutes()
to implements this logic.Thanks for the examples. I these particular examples are already tackled by the equality operator group of mutants, correct?
The problem with adding mutants for all methods is that they often overlap with other mutants that we already have. You probably call getHours()
to calculate something or call setHours
on another Date. The calculations are already covered by existing mutators. Your PR will cover the setHours
.
Can you agree with this?
I see your point.
The equality operator should cover these case. I will update the PR according.
Is your feature request related to a problem? Please describe. It would be interesting to have mutation produced for operation on Date.
Expression like :
will produce interesting mutation based on the +1. It would also be interesting to have mutation changing the
setDate
orgetDate
operation (as updating month and not the day of month).Describe the solution you'd like I propose to add the following mutation (to
method-expression-mutator
) :getDate
to/fromgetMonth
setDate
to/fromsetMonth
getHours
to/fromgetMinutes
setHours
to/fromsetMinutes
Describe alternatives you've considered
Maybe other method are interesting to be mutated, but I think, a first set to start with is enough
Additional context
I will also create a PR with the proposal and link it with this Feature Request.