English subtitles

← 06-23 Code Coverage

Get Embed Code
3 Languages

Showing Revision 1 created 06/10/2012 by Amara Bot.

  1. We've seen a little bit of testing, but let's look at testing from another angle.
  2. Let's say this is the program or the thing that we're considering testing.
  3. We want to test our JavaScript interpreter,
  4. and we're going to feed it this factorial definition and this call to document write.
  5. And by thinking hard about the problem, we know the answer we should get is 120.
  6. 5 times 4 times 3 times 2 times 1--5 factorial.
  7. Here's the quiz.
  8. Let's say this is our test case and that's the input we're comparing against.
  9. I want to know which parts of the program we gain confidence about.
  10. So here I've written 6 important parts of our JavaScript interpreter:
  11. handling function calls; handling environment lookups for variable values;
  12. handling string constants like hello; local variable declarations like var temp = 3;
  13. assignment statements like z = 2; and binary operations like addition.
  14. And what I want to know is, if this is our test input
  15. and we're comparing the answer to 120,
  16. which of these features in our interpreter will be tested?
  17. If something isn't tested, we can't hope to find a bug in it.
  18. As a hint, another way of looking at this problem is to imagine,
  19. let's say, that our code for function calls totally didn't work.
  20. Would we get 120?
  21. If the answer is no, then we're testing function calls.