TestSuite 2.0

I've made some more changes, in particular I'm changing tests to be  
self-checking as much as possible (not always possible, because sometimes  
you have to visually check the results).

For example, go to the Functions chapter, and click through the examples.  
You will see a few with a big green PASS.

These have a generic form. The instance contains a number of <test>  
elements. The content of the test elements are the parameters to the  
function being tested.
Each test element has a @req attribute, which is what the result should  
be, and a @res attribute which is calculated with a bind. For instance,  
for boolean-from-string:

         <instance>
   <tests xmlns="">
     <test res="" req="true">true</test>
     <test res="" req="true">TRUE</test>
     <test res="" req="true">tRue</test>
     <test res="" req="true">1</test>
     <test res="" req="false">false</test>
     <test res="" req="false">FALSE</test>
     <test res="" req="false">faLse</test>
     <test res="" req="false">0</test>
     <test res="" req="false">test</test>
     <test res="" req="false"></test>
     <pass/>
           </tests>
         </instance>
 <bind ref="test/@res" calculate="boolean-from-string(..)"/>

Then there is a <pass/> element that is bound via a calculate, and it  
checks that the count of the elements where @res=@req is the same as the  
count of all elements.

 <bind ref="pass" calculate="if(count(../test[@res = @req])=count(../test),
        'PASS', 'FAIL')"/>

The body of the form just displays the req and res attributes.

       <output class="{pass}" ref="pass"/>
       <repeat ref="test">
 <output ref="."/> → <output value="@res"/><output class="wrong"  
value="if(@res != @req, ', WRONG', '')"/>
       </repeat>

This means:
1. it is really easy to add extra tests (add a new <test> element to the  
instance).
2. the file is generic: you only have to change the <test> elements, and  
the calculate on the test/res bind.
3. It is REALLY easy to see if a test passes or fails, and if it fails,  
why.

(Not all tests have been updated to this style, but I'm working on it).

Steven

Received on Monday, 6 November 2017 09:30:25 UTC