English subtitles

← Which Assertion Solution - Software Debugging

Get Embed Code
4 Languages

Showing Revision 3 created 05/25/2016 by Udacity Robot.

  1. This quiz can easily be answered if you recall our initial state diagram.
  2. Initially, we were in the state no quote, no tag.
  3. If we see a beginning of a tag, we go into the no quote and tag mode.
  4. And in this mode, we can go into quote and tag mode, from which we exit
  5. again by seeing a closely quote, and when we see the closing tag,
  6. we go back into the non-quote, non-tag mode.
  7. These are the three states that a program can be in. Which state is missing?
  8. The state that is missing is the state in which we would have quotes,
  9. but we are outside of tags.
  10. This is exactly the problem we would be handling in our program.
  11. We would take care of quotes, even outside of tags.
  12. This state should not be reached.
  13. So how can we express this with our assert statement?
  14. What we want to make sure of is that this state can never be reached.
  15. So this is quote and not tag. The inversion of this is tag or not quote.
  16. You can see that either we are in non-quote mode, or if we are in quote mode
  17. then we are in tag mode, and the assertion that actually checks this is this one.
  18. This is, therefore, the correct answer.