-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add str literal mutation #189
Conversation
This seems like a really good implementation of a new mutation, thank you. Documentation and tests are well done. One potential issue in particular: Does this implementation break code like this (because the owned String is only a temp variable)? fn a() -> usize {let x = ""; x.len()} I suggest using a return value of |
Thanks for the feedback, that makes sense. I made the update, although I had to remove the appending and prepending mutations. I also added a test case for the example you provided and it doesn't break it (and it didn't break before changing to |
Indeed, for some reason fn a() -> &'static str {""} This code should not break as well (which is now fixed). I really liked the string-dependent mutations. My idea is changing the signature of fn run(
mutator_id: usize,
original_lit: &'static str,
mutations: &[&'statc str],
runtime: &impl Deref<Target = MutagenRuntimeConfig>,
) -> &'static str {...} This allows you to create the mutated strings at compile-time and have them available at run-time as |
Yeah, the new example would have broken the original version. I updated to the signature you suggested and that example works (and I've added it as a test case). |
Great. One last comment: could you revert the documentation to your original proposal? |
I forgot to leave a comment but that should be done. |
Thank you! I didn't have the time to look at this until now, but Samuel has already given all the feedback needed. Thanks to both of you! |
If you're open to new mutations, I created a mutator for string literals. It replaces empty strings with a single character string and for non-empty strings it does a few things: append and prepend a single character as well as replacing the string with an empty string. I'd welcome any feedback. Thanks!