Re: ALU test scripts?
Posted by milythael on Nov 12, 2011; 8:59am
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/ALU-test-scripts-tp3501919p3502015.html
As you have noticed, it is cost prohibitive to exhaustively test every
possible combination of input. This is similar to testing a simple method
in higher level programing languages that takes two numbers as input and is
supposed to output the product of those two numbers. Since the realm of a
single number is theoretically infinite, exhaustively testing this function
would also be infinite. This is what leads us to testing important cases.
Typically, testing valid samples of easy data and then testing edge cases
that need to be right is the way to go. For example, in my example,
testing with both a and b as zero, with either one as zero and then with
various combinations of negative numbers is important.
You can probably consider your ALU well enough tested if you have
determined that individual bits aren't affecting each other
inappropriately, and that several bits are coming up with correct values.
The provided script / compare file should be good enough to identify most
problems and if you pass that test, you can probably move on with
confidence. Also, in later chapters, you should use the built in ALU
because of performance concerns. This means a subtle bug in your code now
won't actually shoot you in the foot later.
I doubt people have much more to offer you for test scripts but if you
still want more, I would be happy to help you develop a more thorough test
script offline.
Sean