albertogoffi / toradocu

Toradocu - automated generation of test oracles from Javadoc documentation
Other
42 stars 21 forks source link

Incorrect condition generation for "if predicate is true" for Predicate object #53

Closed bjkeller closed 7 years ago

bjkeller commented 7 years ago

Running Randoop on org.apache.commons.collections4.ClosureUtils with --export-conditions (on randoop branch) gives the following condition-method

    // org.apache.commons.collections4.Closure org.apache.commons.collections4.ClosureUtils.ifClosure(org.apache.commons.collections4.Predicate predicate,org.apache.commons.collections4.Closure trueClosure,org.apache.commons.collections4.Closure falseClosure)
    public static boolean m12_p1(org.apache.commons.collections4.ClosureUtils target, org.apache.commons.collections4.Predicate predicate, org.apache.commons.collections4.Closure trueClosure, org.apache.commons.collections4.Closure falseClosure) {
        // @param trueClosure the closure called if the predicate is true ==> args[0]==true
        return predicate == true;
    }

where predicate has type org.apache.commons.collections4.Predicate and cannot be converted to boolean. So, translation of "if predicate is true" to predicate == true is incorrect. Similarly, for statement "if predicate is false" for the falseClosure parameter.

If you look at the code these param-tags are not preconditions anyway, they describe the behavior of the Closure object that the method creates.

albertogoffi commented 7 years ago

This does not happen with the latest Toradocu version that produces an empty translation for the comment for which Toradocu was generating a wrong translation. Some time ago, we added checks that try to prevent this situations.

I close this issue.