Water 5-Software Life-cycle-Testing
class test
Contract
Parameter keyDefault valueType
resultreq with ekind of expressiontype.<one_of error wob "ignore"/>
onopt with ekind of expressionwob
pre_codeopt with ekind of expressionwob
post_codeopt with ekind of expressionwob
pre_docnull
nameopt
known_bugfalsetype.<one_of boolean "not_yet_implemented" string/>
do_not_runfalseboolean
result_formatopttype.<one_of opt "htm" "cxs" />
failed_result"system&#32;use"string
examplefalseboolean
language"water"type.<one_of "water" "java"/>
sourcefalse
Parameter kindDefault valueType
Other unkeyed argumentsopt with ekind of stringwob
Water Contract
<class test
  result       =req=<type.one_of error wob "ignore"/>=ekind.expression
  on           =opt=wob=ekind.expression
  pre_code     =opt=wob=ekind.expression
  post_code    =opt=wob=ekind.expression
  pre_doc      =null
  name         =opt
  known_bug    =false=<type.one_of boolean "not_yet_implemented" string/>
  do_not_run   =false
  result_format=opt=<type.one_of opt "htm" "cxs" null/>
  failed_result="system&amp;#32;use"
  example      =false
  language     ="water"=<type.one_of "water" "java"/>
  _other_unkeyed=opt=wob=ekind.string="source"
/>
Calling test creates an instance that contains at least two strings of code. This code is executed and compared with 'equal'. If the values are equal, the success field of the test instance is set to true, otherwise its set to false. The test instance is returned. The to_html method for test prints "Passed Test" if the test succeeded and "Failed Test" plus details if it didn't. The second argument defaults to true so if evaluating your first argument is supposed to return true, you need only pass one argument to "test".
Example: Makes and runs a simple test
<test result=12 
      <set x = 10/>
      x.<plus 2/> 
    />
You can use any expression of the language as arguments to test. If you would like a comparison method other than equal, Stick the call to the comparison method in the source arg along with both expressions to compare and let the result arg default to true. You will find particularly useful calls to the methods: is equal not You can give test additional fields of: To test that executing the source will error, use result=error To execute the source and verify that it runs, but ignore the result, use result=ignore To not run a test at all, use do_not_run=true . This is useful when running the test will cause undesired results. To change the default for all tests, use test.<set do_not_run = true/> Sometimes a test fails, but it can't be fixed immediately and it is helpful to indicate that the test fails. Use known_bug=true . If it is testing a feature that is not yet implemented, use known_bug="not_yet_implemented" In some cases, a test will have several effects. To test for multiple effects, have the test source return a vector where each value is an expression to test. The test result is a vector where each value is the expected result.
<test result=<vector 10 20/>
    thing.<set x = 10/>
    thing.<set y = 20/>
    <vector thing.x thing.y/>  
   />