diff -uNr dmd-0.140/dmd/html/d/abi.html dmd-0.141/dmd/html/d/abi.html --- dmd-0.140/dmd/html/d/abi.html 2005-11-24 17:13:14.000000000 +0100 +++ dmd-0.141/dmd/html/d/abi.html 2005-11-29 01:35:32.000000000 +0100 @@ -25,7 +25,7 @@ | Comments -
+ +
|
+
+
+
+
+ + + · Overview + + + · D for Win32 + + + · Win32 DLLs in D + + + · C .h to D Modules + + + · FAQ + + + · Style Guide + + + · Example: wc + + + · Future + + + · D Change Log + + + · Tech Tips + + + · Rationale + + + · Glossary + + + · Acknowledgements + + + + Tools + + · DMD D Compiler + + + · GDC D Compiler + + + · Linker + + + · Profiler + + + · Code Coverage + + + + Community + + · News Digest + + + · News + + + · Forum + + + · Announcements + + + · Learn + + + · D links + + + + Archives + + · digitalmars.D + + + · digitalmars.D.dtl + + + · digitalmars.D.announce + + + · digitalmars.D.learn + + + · digitalmars.D.bugs + + + · D.gnu + + + · Old D + + + + + |
+
+Code Coverage Analysis+ +A major part of the engineering of a professional software project +is creating a test suite for it. Without some sort of test suite, +it is impossible to know if the software works at all. +The D language has +many features to aid in the creation of test suites, such as +unit tests and +contract programming. +But there's the issue of how thoroughly the test suite tests +the code. +The profiler +can give valuable information on which functions were called, and +by whom. But to look inside a function, and determine which statements +were executed and which were not, requires a code coverage analyzer. + + +A code coverage analyzer will help in these ways: + +
Experience with code coverage analyzers show that they dramatically +reduce the number of bugs in shipping code. +But it isn't a panacea, a code coverage analyzer won't help with: + +
Code coverage analysers are available for many popular languages +such as C++, but they are often third party products that integrate +poorly with the compiler, and are often very expensive. +A big problem with third party products is, in order to instrument +the source code, they must include what is essentially a full blown +compiler front end for the same language. Not only is this an expensive +proposition, it often winds up out of step with the various compiler +vendors as their implementations change and as they evolve various extensions. +(gcov, +the Gnu coverage analyzer, is an exception as it is both free +and is integrated into gcc.) + + +The D code coverage analyser is built in as part of the D compiler. +Therefore, it is always in perfect synchronization with the language +implementation. It's implemented by establishing a counter for each +line in each module compiled with the -cov switch. Code is inserted +at the beginning of each statement to increment the corresponding counter. +When the program finishes, a static destructor for std.cover collects all +the counters, merges it with the source files, and writes the reports out +to listing (.lst) files. + +For example, consider the Sieve program: +/* Eratosthenes Sieve prime number calculation. */ + +bit flags[8191]; + +int main() +{ int i, prime, k, count, iter; + + printf("10 iterations\n"); + for (iter = 1; iter <= 10; iter++) + { count = 0; + flags[] = true; + for (i = 0; i < flags.length; i++) + { if (flags[i]) + { prime = i + i + 3; + k = i + prime; + while (k < flags.length) + { + flags[k] = false; + k += prime; + } + count += 1; + } + } + } + printf ("\n%d primes\n", count); + return 0; +} ++ + Compile and run it with: + +dmd sieve -cov +sieve ++ + The output file will be created called sieve.lst, the contents of +which are: + + |/* Eratosthenes Sieve prime number calculation. */
+ |
+ |bit flags[8191];
+ |
+ |int main()
+ 5|{ int i, prime, k, count, iter;
+ |
+ 1| printf("10 iterations\n");
+ 22| for (iter = 1; iter <= 10; iter++)
+ 10| { count = 0;
+ 10| flags[] = true;
+ 163840| for (i = 0; i < flags.length; i++)
+ 81910| { if (flags[i])
+ 18990| { prime = i + i + 3;
+ 18990| k = i + prime;
+ 168980| while (k < flags.length)
+ | {
+ 149990| flags[k] = false;
+ 149990| k += prime;
+ | }
+ 18990| count += 1;
+ | }
+ | }
+ | }
+ 1| printf ("\n%d primes\n", count);
+ 1| return 0;
+ |}
+sieve.d is 100% covered
+
+
+The numbers to the left of the | are the execution counts for that +line. Lines that have no executable code are left blank. +Lines that have executable code, but were not executed, have a "0000000" +as the execution count. +At the end of the .lst file, the percent coverage is given. + + +There are 3 lines with an exection count +of 1, these were each executed once. The declaration line for i, prime, +etc., has 5 because there are 5 declarations, and the initialization of +each declaration counts as one statement. + +The first for loop shows 22. This is the sum of the 3 parts +of the for header. If the for header is broken up into 3 lines, the +data is similarly divided: + +1| for (iter = 1; + 11| iter <= 10; + 10| iter++) ++ + which adds up to 22. + +e1&&e2 and e1||e2 expressions conditionally +execute the rvalue e2. +Therefore, the rvalue is treated as a separate statement with its own +counter: + + |void foo(int a, int b)
+ |{
+ 5| bar(a);
+ 8| if (a && b)
+ 1| bar(b);
+ |}
+
+
+By putting the rvalue on a separate line, this illuminates things: + + |void foo(int a, int b)
+ |{
+ 5| bar(a);
+ 5| if (a &&
+ 3| b)
+ 1| bar(b);
+ |}
+
+
+Similarly, for the e?e1:e2 expressions, e1 and +e2 are treated as separate statements. + +Controlling the Coverage Analyser+ +The behavior of the coverage analyser can be controlled through +the std.cover module. + +When the -cov switch is thrown, the version identifier +D_Coverage is defined. + +References+ +Wikipedia + + + |
|
- - -object - - -std - std.base64 - std.boxer - std.compiler - std.conv - std.ctype - std.date - std.file - std.format - std.gc - std.intrinsic - std.math - std.md5 - std.mmfile - std.openrj - std.outbuffer - std.path - std.process - std.random - std.recls - std.regexp - std.socket - std.socketstream - std.stdint - std.stdio - std.cstream - std.stream - std.string - std.system - std.thread - std.uri - std.utf - std.zip - std.zlib - -std.windows - -std.linux - -std.c - std.c.stdio - -std.c.windows - -std.c.linux - - - |
-
-
-
-std.uri- - Encode and decode Uniform Resource Identifiers (URIs). - URIs are used in internet transfer protocols. - Valid URI characters consist of letters, digits, and - the characters ;/?:@&=+$,-_.!~*'(). Escape sequences - consist of '%' followed by two hex digits. - -
|
|
+ + +object + + +std + std.base64 + std.boxer + std.compiler + std.conv + std.cover + std.ctype + std.date + std.demangle + std.file + std.format + std.gc + std.intrinsic + std.math + std.md5 + std.mmfile + std.openrj + std.outbuffer + std.path + std.process + std.random + std.recls + std.regexp + std.socket + std.socketstream + std.stdint + std.stdio + std.cstream + std.stream + std.string + std.system + std.thread + std.uri + std.utf + std.zip + std.zlib + std.windows.charset + +std.windows + +std.linux + +std.c + std.c.stdio + +std.c.windows + +std.c.linux + + + |
+
+
+
+std.uri+ + +Encode and decode Uniform Resource Identifiers (URIs). + URIs are used in internet transfer protocols. + Valid URI characters consist of letters, digits, + and the characters ;/?:@&=+$,-.!~*'(). Escape sequences consist of '%' + followed by two hex digits. ++See Also: +RFC 3986 + Wikipedia + + + +
|
-.init initializer (0) +.init initializer .sizeof size in bytes (equivalent to C's sizeof(type)) .alignof alignment size +.mangleof string representing the 'mangled' representation of the type ++ +
+.init initializer (0) .max maximum value .min minimum value@@ -180,8 +188,6 @@
.init initializer (NaN) -.sizeof size in bytes (equivalent to C's sizeof(type)) -.alignof alignment size .infinity infinity value .nan NaN value .dig number of decimal digits of precision @@ -193,6 +199,8 @@ .min_exp minimum exponent as power of 2 .max largest representable value that's not infinity .min smallest representable value that's not 0 +.re real part +.im imaginary part
version (InlineAsm) +version (D_InlineAsm_X86) { asm { diff -uNr dmd-0.140/dmd/html/d/struct.html dmd-0.141/dmd/html/d/struct.html --- dmd-0.140/dmd/html/d/struct.html 2005-10-20 19:00:04.000000000 +0200 +++ dmd-0.141/dmd/html/d/struct.html 2005-11-29 01:35:30.000000000 +0100 @@ -25,7 +25,7 @@ | Comments -Last update Thu Oct 20 20:00:04 2005 +diff -uNr dmd-0.140/dmd/html/d/template.html dmd-0.141/dmd/html/d/template.html --- dmd-0.140/dmd/html/d/template.html 2005-11-22 00:30:54.000000000 +0100 +++ dmd-0.141/dmd/html/d/template.html 2005-11-29 01:35:30.000000000 +0100 @@ -25,7 +25,7 @@ | Comments -Last update Tue Nov 29 01:35:29 2005Last update Tue Nov 22 00:30:53 2005 +diff -uNr dmd-0.140/dmd/html/d/type.html dmd-0.141/dmd/html/d/type.html --- dmd-0.140/dmd/html/d/type.html 2005-10-20 00:45:20.000000000 +0200 +++ dmd-0.141/dmd/html/d/type.html 2005-11-29 01:35:30.000000000 +0100 @@ -25,7 +25,7 @@ | Comments -Last update Tue Nov 29 01:35:29 2005Last update Thu Oct 20 01:45:19 2005 +diff -uNr dmd-0.140/dmd/html/d/version.html dmd-0.141/dmd/html/d/version.html --- dmd-0.140/dmd/html/d/version.html 2005-10-24 13:11:10.000000000 +0200 +++ dmd-0.141/dmd/html/d/version.html 2005-11-29 09:37:04.000000000 +0100 @@ -25,7 +25,7 @@ | Comments -Last update Tue Nov 29 01:35:29 2005Last update Mon Oct 24 14:11:09 2005 +@@ -365,7 +365,8 @@Last update Tue Nov 29 09:37:02 2005