Re: An attack on a mint
Bill Frantz <[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <r02010500-1049-3371944EF11E11DCB7FC0030658F0F64@[192.168.1.5]> |
[email protected] (Karp, Alan H) on Wednesday, March 12, 2008 wrote: >My Python and Java codes have the unit tests in the same source file as the code that does the work. That >makes it hard to lose them and easy to update when you want to add a test. Since I learned to avoid loops >in my object graphs, I only need to go through the tests in the graph once. How much does this increase the memory footprint of the object code? With C, you could put the tests under a pre-processor switch, and not increase the memory footprint for production code. (I'm working on an embedded system, where memory footprint is still somewhat important.) With Java, I don't see where you have a choice, if there is a method test() in the source, it will be in the class file, and loaded into memory at runtime. (A wag might say that Java is so bloated you won't even notice.) With Python, it may only be the increase in size of the source, since presumably any Python JIT won't touch code that isn't executed. Right? [The real-life use case I have in mind is that EROS uses a red-black tree for its in-memory directory. KeyKOS used a hash table. The red-black tree has better worst-case performance, so it is a better choice for CapROS. However, the code is much more complex. A random number based unit test which compares the results from a hash table and the red-black tree may be the ideal unit test. Jonathan wrote in the comments to the EROS code: /* Note: This code adapted from my tree package. Experience suggests * that trying to debug this code in the kernel is lunacy. Debug the * tree package as an application and then re-convert by changing the * function names. I have tried to minimize the name changes. */ So I am thinking of source which, under a compile switch, includes a main and test cases.] Cheers - Bill ----------------------------------------------------------------------- Bill Frantz | gets() remains as a monument | Periwinkle (408)356-8506 | to C's continuing support of | 16345 Englewood Ave www.pwpconsult.com | buffer overruns. | Los Gatos, CA 95032