This quiz can easily be answered if you recall our initial state diagram.
Initially, we were in the state no quote, no tag.
If we see a beginning of a tag, we go into the no quote and tag mode.
And in this mode, we can go into quote and tag mode, from which we exit
again by seeing a closely quote, and when we see the closing tag,
we go back into the non-quote, non-tag mode.
These are the three states that a program can be in. Which state is missing?
The state that is missing is the state in which we would have quotes,
but we are outside of tags.
This is exactly the problem we would be handling in our program.
We would take care of quotes, even outside of tags.
This state should not be reached.
So how can we express this with our assert statement?
What we want to make sure of is that this state can never be reached.
So this is quote and not tag. The inversion of this is tag or not quote.
You can see that either we are in non-quote mode, or if we are in quote mode
then we are in tag mode, and the assertion that actually checks this is this one.
This is, therefore, the correct answer.
Questo quiz puo' essere facilmente risolto se ti ricordi il nostro diagramma di stato iniziale.
Inizialmente, eravamo nello stato no virgolette, no tag.
Se vediamo l'inizio di un tag, entriamo in modo no virgolette, si' tag
e da questo modo possiamo entrare nel modo si' quote si' tag, dal quale ne usciremo di nuovo
vedendo virgolette di chiusura. E quando vedremo un tag di chiusura,
ritorneremo nel modo ne' virgolette ne' tag.
Questi sono i tre stati in cui puo' trovarsi il nostro programma. Qual'e' lo stato mancante?
Lo stato che manca e' lo stato in cui ci sarebbero le virgolette
ma al di fuori dei tag.
Questo e' esattamente il problema che abbiamo avuto nel nostro programma.
Eliminavamo le virgolette anche al di fuori dei tag.
Questo stato non dovra' essere raggiunto.
Allora come lo possiamo esprimere con i nostri comandi assert?
Cio' di cui vogliamo essere sicuri e' che questo stato non dovra' mai essere raggiunto.
Quindi questo sara' quote AND NOT tag. Il suo inverso e' tag OR NOT quote.
Lo puoi trovare sia che siamo in modo non virgolette che se siamo il modo virgolette
e in modo tag e l'asserzione che verifica cio' e' questa qui.
Questa e' percio' la risposta esatta.
最初の状態図を思い出せば簡単に答えられます
最初はno quote and no tagモードでした
そして次の状態はno quote and tagモードです
こちらはquote and tagモードです
再びクォーテーションがあるとこの状態を抜け
タグがあるとこちらに移ります
no quote and no tagモードに戻りました
これがプログラムの3つの状態ですが
どの状態が欠けているでしょうか?
その状態とはquote and no tag モードです
これがまさにプログラムで
対処しなければならない問題です
no tagモードでもクォーテーションへの対処が必要です
この状態にはなり得ません
ではこれをassert文で
どう表すことができるでしょうか?
この状態には決して達しません
これはquote and not tagですので
tag and not quoteを反転させたものです
not quote モードなのか
またはquote and tagモードかの判定には
このアサーションが使えそうですね
したがってこれが正解です
这个测试很简单,如果你记得最初的状态图。
起初,我们处于非quote非tag的状态。
如果看到一个标签的开始符,我们进入到非quote,tag状态。
在这个状态中,我们可以进quote,tag状态,从这个状态退出
条件是看到结束的引号,等我们看到标签的结束符时,
我们回到非quote非tag状态。
这个状态有三个可能的状态。哪个状态不见了?
有个遗漏的状态,就是有引号,
但不在标签内的状态。
这就是我们在程序里要处理的问题。
我们要注意引号的情况,即使是在标签外。
所以这个状态不应该出现。
那么,我们如何用断言声明来表达呢?
其实可以保证这个状态永远不可达。
所以就用 quote and not tag,与之相反的状态是tag or 非quote状态。
你看到,不管我们是在非quote还是quote状态下,
只要是在tag状态下,这个断言就会检查条件是否成立。
所以这个就是正确答案。