diff options
Diffstat (limited to 'devdocs/elisp/coverage-testing.html')
| -rw-r--r-- | devdocs/elisp/coverage-testing.html | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/devdocs/elisp/coverage-testing.html b/devdocs/elisp/coverage-testing.html new file mode 100644 index 00000000..59589c92 --- /dev/null +++ b/devdocs/elisp/coverage-testing.html @@ -0,0 +1,20 @@ + <h4 class="subsection">Coverage Testing</h4> <p>Edebug provides rudimentary coverage testing and display of execution frequency. </p> <p>Coverage testing works by comparing the result of each expression with the previous result; each form in the program is considered covered if it has returned two different values since you began testing coverage in the current Emacs session. Thus, to do coverage testing on your program, execute it under various conditions and note whether it behaves correctly; Edebug will tell you when you have tried enough different conditions that each form has returned two different values. </p> <p>Coverage testing makes execution slower, so it is only done if <code>edebug-test-coverage</code> is non-<code>nil</code>. Frequency counting is performed for all executions of an instrumented function, even if the execution mode is Go-nonstop, and regardless of whether coverage testing is enabled. </p> <p>Use <kbd>C-x X =</kbd> (<code>edebug-display-freq-count</code>) to display both the coverage information and the frequency counts for a definition. Just <kbd>=</kbd> (<code>edebug-temp-display-freq-count</code>) displays the same information temporarily, only until you type another key. </p> <dl> <dt id="edebug-display-freq-count">Command: <strong>edebug-display-freq-count</strong> +</dt> <dd> +<p>This command displays the frequency count data for each line of the current definition. </p> <p>It inserts frequency counts as comment lines after each line of code. You can undo all insertions with one <code>undo</code> command. The counts appear under the ‘<samp>(</samp>’ before an expression or the ‘<samp>)</samp>’ after an expression, or on the last character of a variable. To simplify the display, a count is not shown if it is equal to the count of an earlier expression on the same line. </p> <p>The character ‘<samp>=</samp>’ following the count for an expression says that the expression has returned the same value each time it was evaluated. In other words, it is not yet covered for coverage testing purposes. </p> <p>To clear the frequency count and coverage data for a definition, simply reinstrument it with <code>eval-defun</code>. </p> +</dd> +</dl> <p>For example, after evaluating <code>(fac 5)</code> with a source breakpoint, and setting <code>edebug-test-coverage</code> to <code>t</code>, when the breakpoint is reached, the frequency data looks like this: </p> <div class="example"> <pre class="example">(defun fac (n) + (if (= n 0) (edebug)) +;#6 1 = =5 + (if (< 0 n) +;#5 = + (* n (fac (1- n))) +;# 5 0 + 1)) +;# 0 +</pre> +</div> <p>The comment lines show that <code>fac</code> was called 6 times. The first <code>if</code> statement returned 5 times with the same result each time; the same is true of the condition on the second <code>if</code>. The recursive call of <code>fac</code> did not return at all. </p><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br> + <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Coverage-Testing.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Coverage-Testing.html</a> + </p> +</div> |
