I think Brad Cox, Ph.D. wrote:
> 
> In pidgin Jess (all I'm capable of right now), I'd imagine something
> like this
> 
>       (isImplementationOf ?thisImplementation "MilitaryEquipment" &&
>               (compareWeights (?thisImplementation.getWeight()) computeWeight())
>               =>
>               ... print ?thisImplementation "passes" mumble
> 


I think you'd want to have a deftemplate for generic objects under
test (it would probably have more slots, but I don't know what they
are, yet)

        (deftemplate test-subject (slot object))

And then you'd tell Jess about a testable object like this

        (assert (test-subject (object (new Helmet))))

Then the rule we're talking about might look like

(defrule test-get-weight
        (test-subject (object ?o))
        (test (instanceof ?o MilitaryEquipment))
        (test (compareWeights (?o getWeight) (computeWeight ?o)))
        =>      
        (printout "Subject passes getWeight test" crlf))

Here instanceof is a Jess built-in, and compareWeights and
computeWeight are unique to your application. compareWeights might
look like


(deffunction compareWeights (?n1 ?n2)
  (return (< (call Math abs (- ?n1 ?n2)) 0.000001)))


Now, I'm not really sure where JUnit fits in. JUnit is based pretty
fundamentally on the idea of throwing an exception if something fails,
which doesn't fit well with the way Jess operates. Jess wants Boolean
tests.

---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to