Code Generator
Greg Wilson · 2022
How much code does a set of tests actually test? One way to find out is to use a code coverage tool that watches a program while it executes and keeps track of which lines have run and which haven&s;t. Making sure that each line is tested at least once doesn&s;t guarantee that the code is bug-free, but any code that isn&s;t run shouldn&s;t be trusted. Rather than rewriting JavaScript to keep track of this information, this chapter builds a tool to modify the functions themselves by parsing the code, inserting the extra instructions that coverage requires into the resulting tree, and then turning that tree back into code.