7.11.1 ttst, ftst, and etst

Prev Up Next Page 226 of 800 Search internet

A statement like

ttst 2 + 3 = 5 end test

tests that 2 + 3 = 5 evaluates to true.

Likewise, a statement like

ftst 2 + 3 = 7 end test

tests that 2 + 3 = 7 evaluates to false.

A statement like

etst 2 div 0 ; 2 + true end test

tests that 2 div 0 and 2 + true are equal, which they are because they both throw the standard exception exception. The value of 2 div 0 = 2 + true is exception, but etst x ; y end test is special in that equal exceptions compare as equal rather than causing another exception.

If a test case fails, the diagnose is set to the parse tree of the test case.

Execution of test cases is done by lgc(1) during compilation of a page. Lgc not only executes test cases of the page being defined. It also executes test cases of pages it cannot find in the cache and thus have to load from vector format.

Note that as far as lgc is concerned, failure of a test case is no error. Lgc just reports that the page is incorrect and continues rendering the page. Lgc does not even consider it an error if your page references an incorrect page. But the proof checker described later will complain if you use a lemma from an incorrect page.

Just before each test case is going to be executed, the 'spy' variable is set to the parse tree of the test case. That is done using the spy ( x ) construct which returns the string 'spy' but which also sets the spy variable to x as a side effect. Recall that Logiweb is pure functional in the sense of being univocal: the return value of a function only depends on the values of the arguments. But Logiweb still has functions which produce side effects for the sake of debugging. Only use side-effects for debugging since side-effects are not portable. Side-effects can only transport information from inside to outside Logiweb, not the other way.

If a test case loops indefinitely (or - rather - if you run out of patience) you may kill lgc using ctrl-C. When killed, lgc prints a death-report which includes the value of the spy variable.

Actually, lgc always prints a death-report when it terminates, but in most cases the death-report is empty. As an example, lgc only prints the value of the spy-variable when the spy-variable differs from true.

Prev Up Next Page 226 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05