[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

regression test improvements



You thought you had changed one little thing at the beginning of your
program, but your regression tests barfs heaps of differences at you!
Ah ha!  All those pointer addresses changed (horrors).  What you need
is to go right out and build this new design for improved regression
tests.  Step right up....

Make a class containing (or inheriting from) a stream, a Table, and an
object count.  The table maps from objects to the count at the time
the object was first encountered.  Everytime you encounter an object
(print it), look in the table for the index associated with it.  If
you find one, print it as an identifier.  Otherwise, add the
association from the Object to the current count and increment the
count.  Then print the object (recursively).  

Now the numbers coming out from a regression test represent the order
in which the objects get encountered in the data-structure, rather
than the memory location at which they are allocated.  All cycles are
broken, and the IDs are perfectly cononical.

Note that a normal table gives abstract distinction in your printout:
two pointers to different integers with the same value will appear the
same (perfectly reasonable).  The stream-thing could instead be
parameterized by a Table that uses identities for all objects to give
full distinctions.  (This IdentityTable should only be used for
debugging!).  (Thank MarkM for this idea).

I originated the idea so that I can make regression tests that produce
identical results in Smalltalk and in C++.  This will be very
important for testing the Ent!  


I expect the work involved is minimal, but....  Any volunteers?

dean