TIL: Mutation Testing. > Mutation testing is used to design new software tests and evaluate the > quality of existing software tests. Mutation testing involves modifying a > program in small ways. Each mutated version is called a mutant and tests > detect and reject mutants by causing the behaviour of the original version to > differ from the mutant.
With that defined, yes it can be done with macros. You have to create an macro that traverse your program AST¹ and change it. I would use patchFile². For patching test³ template from unittest to change tested function AST. Or to change imported files directly with regexp mutated version. * ¹ <https://nim-lang.org/docs/macros.html> * ² <https://nim-lang.org/docs/nimscript.html#patchFile%2Cstring%2Cstring%2Cstring> <https://forum.nim-lang.org/t/10948#72850> * ³ <https://nim-lang.org/docs/unittest.html#test.t%2C%2C>
