Forum OpenACS Q&A: Re: Assertions in OpenACS

Collapse
9: Re: Assertions in OpenACS (response to 1)
Posted by Michael Bryzek on
We modified ad_proc to understand preconditions to method execution through a @pre comment (ala icontract - http://www.reliable-systems.com/tools/iContract/iContract.htm)

This lets us test assertions on entry into a given tcl procedure on our development servers while completely avoiding the assertion in production.

Example:

ad_proc foobar { zip radius } {
  @pre [empty_string_p [vs_validate_zip $zip]] 
  @pre $radius >= 0 
} {
  
}
On our development servers, we parse out the preconditions from the documentation for the procedure and add assertions to the body of the tcl proc itself.
Collapse
10: Re: Assertions in OpenACS (response to 9)
Posted by Jeff Davis on
can you submit a patch for this.  It sounds extremely useful.