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

Random class and method mutant selection strategies #102

Conversation

DurieuxPol
Copy link
Collaborator

Fixes #44, fixes #45

Durieux Pol added 2 commits March 20, 2024 15:56
…tract superclass random grouped selection & tests
@DurieuxPol DurieuxPol requested a review from guillep March 20, 2024 15:03
Copy link
Contributor

@guillep guillep left a comment

Choose a reason for hiding this comment

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

It would be nice that new tests come with the new features :)

MTRandomClassMutantSelectionStrategyTest >> classToTest [

^ MTRandomClassMutantSelectionStrategy
]
Copy link
Contributor

Choose a reason for hiding this comment

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

This class do not define new tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree, but I struggle a bit to see what kind of tests I could do, given the random nature of the selection.
I guess I could create an auxiliar class for each one, like a class with let's say 4 methods, which produce enough mutants to be able to have around 25% of mutants from each method with the random method mutant selection.

Copy link
Collaborator Author

@DurieuxPol DurieuxPol Mar 21, 2024

Choose a reason for hiding this comment

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

Or else I could create a set of auxiliar classes for all random selections, and given a seed (or maybe even not), I check that I get a different mutant selection with each strategy

Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally, we can see if we can parametrise the random selector with a seed, and use a same fixed seed always in the test, to guarantee we have the same results.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would combine both your ideas: (1) a class with a list of selectors that we control easily, and (2) the seed. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok thanks !

@DurieuxPol
Copy link
Collaborator Author

I see, the tests are failing in previous versions of Pharo because the seed doesn't seem to produce the same things as in Pharo 12.
I'll change the assertions then

Durieux Pol added 2 commits March 21, 2024 16:59
precision: 0.1 ].

self assert:
(mutationsDic values fold: [ :bool1 :bool2 | bool1 and: bool2 ])
Copy link
Contributor

Choose a reason for hiding this comment

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

So you are testing that the results are evenly distributed by the grouping condition?
It's a fun way to test it ^^.

I understand you did this because the default random generator changed in Pharo11 or Pharo12, making tests not compatible, right?

Alternative solution: have a set of tests for Pharo<11 and a set of tests for Pharo>=11

Also, I see that Pharo9 is breaking because truncateTo: is not defined in collections.
Maybe we can (should?) drop Pharo9 support?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At first I checked that the results matched exactly the expected distribution (like #( 30 31 39 ) ), but yes in previous pharo versions the expected distributions are not the same because, even with the same seed, the random generator don't give the same results.

Yes I guess it could be a good (maybe even better) solution to have a set for pharo >= 12 and a set for pharo <= 11.

Given the fact that pharo 9 is in deprecated distributions in the pharo launcher, I think it's acceptable to drop pharo 9 support.

Copy link
Collaborator Author

@DurieuxPol DurieuxPol Mar 22, 2024

Choose a reason for hiding this comment

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

Just, I don't know how to make tests for specific versions of Pharo :') But I guess it's not that hard

Durieux Pol added 5 commits March 22, 2024 15:59
Copy link
Contributor

@guillep guillep left a comment

Choose a reason for hiding this comment

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

Very nice! And all green in addition!

@guillep guillep merged commit 14a1ba4 into pharo-contributions:master Mar 25, 2024
4 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.

Implement method random mutant selection Implement class random mutant selection
2 participants