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

R argument switching mutants are equivalent #26

Closed
tdhock opened this issue May 2, 2024 · 8 comments
Closed

R argument switching mutants are equivalent #26

tdhock opened this issue May 2, 2024 · 8 comments

Comments

@tdhock
Copy link

tdhock commented May 2, 2024

hi @agroce
I'm trying to make PRs based on the R data.table mutants Rdatatable/data.table#6114

And I noticed that many of the mutants involve switching the order of arguments, here are two examples.

setops.R:8 by.y becomes cols in either case.

by.y = colnamesInt(y, by.y, check_dups=TRUE)
by.y = colnamesInt(y, check_dups=TRUE, by.y)

transpose.R:63 type.convert becomes x in either case.

indxs = unlist(type.convert, recursive=FALSE, use.names=FALSE)
indxs = unlist( recursive=FALSE,type.convert, use.names=FALSE)

All of these argument switching mutants in R code are equivalent, because R first matches the named arguments, then assigns the positional arguments.

For future mutation testing of R code, it would be useful to avoid generating such mutants, perhaps by adding a rule that if the argument to switch has an equals sign (name=value, so it is a named argument), then do not try switching.

@agroce
Copy link
Owner

agroce commented May 2, 2024

@debsourav33 @kjain14 you guys are the rule hacking experts now; is this hard? It'd actually be better for Python too, since swapping named args is always equivalent

@debsourav33
Copy link
Contributor

Shouldn't be very hard to achieve.. Just need to find a clever way to skip the arguments with '=' in it.. I will try updating the rules and make a PR

@tdhock
Copy link
Author

tdhock commented May 3, 2024

perhaps an alternative to turning it off would be switching values or names in two named arguments

fun(x=1, y=2)
fun(x=2, y=1)

etc

@debsourav33
Copy link
Contributor

Addressed both issues (skip swapping named arguments and swap their values/names instead) in the PR #27

@agroce
Copy link
Owner

agroce commented May 7, 2024

Closed via #27

@agroce agroce closed this as completed May 7, 2024
@tdhock
Copy link
Author

tdhock commented May 7, 2024

yay thanks

@agroce
Copy link
Owner

agroce commented May 7, 2024

@tdhock not on pip yet, though, note

@agroce
Copy link
Owner

agroce commented May 16, 2024

(on pip now)

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

No branches or pull requests

3 participants