[racket] get-uncovered-expressions

From: Nadeem Abdul Hamid (nadeem at acm.org)
Date: Thu Jul 22 17:31:09 EDT 2010

Apparently the coverage thing only works if the evaluator is given a
(byte) string (as opposed to an input port or anything else), so using
port->bytes when reading from a file produces the expected result:

 (define Ev
  (call-with-input-file* "test.rkt"
    (λ(inp)
      (parameterize ([sandbox-coverage-enabled #t])
        (make-evaluator 'racket
                        (port->bytes inp)
                        )))))
 (get-uncovered-expressions Ev)

Thanks for the help,

--- nadeem


On Wed, Jul 21, 2010 at 6:39 PM, Nadeem Abdul Hamid <nadeem at acm.org> wrote:
>> I can't produce a more thorough answer now, but in general the whole
>> uncovered expressions feature relies on expressions with a source
>> indication.  For example, this works as you expect:
>> ...
>> and it should also work for a sandbox that is created from a file.
>
>
> OK, thanks, that sort of makes sense. But still, if I put the text of the program in a file and do the following it still produces '()...
>
>  (define Ev
>   (call-with-input-file* "test.rkt"
>     (λ(inp)
>       (parameterize ([sandbox-coverage-enabled #t])
>         (make-evaluator 'lang/htdp-intermediate
>                         inp
>                         )))))
>  (get-uncovered-expressions Ev)
>
> And so does this:
>
> (define Ev
>  (parameterize ([sandbox-coverage-enabled #t])
>    (make-evaluator 'lang/htdp-intermediate
>                    (open-input-string
>                     "(define (f x)
>                        (if (zero? x) \"zero\" \"non-zero\"))
>                      (f 4)")
>                    )))
> (get-uncovered-expressions Ev)
>
>
> --- nadeem
>
>
> On Jul 21, 2010, at 6:19 PM, Eli Barzilay wrote:
>
>> On Jul 21, Nadeem Abdul Hamid wrote:
>>> Sorry if I am missing something obvious, by why does the following
>>> produce '() ?
>>>
>>> (define Ev
>>>  (parameterize ([sandbox-coverage-enabled #t])
>>>    (make-evaluator 'lang/htdp-intermediate
>>>                    `(define (f x)
>>>                       (if (zero? x) "zero" "non-zero"))
>>>                    `(f 4)
>>>                    )))
>>> (get-uncovered-expressions Ev)
>>>
>>>
>>> I would have expected it to indicate somehow that the "zero" case is
>>> not covered?
>>
>> I can't produce a more thorough answer now, but in general the whole
>> uncovered expressions feature relies on expressions with a source
>> indication.  For example, this works as you expect:
>>
>>  (define Ev
>>    (parameterize ([sandbox-coverage-enabled #t])
>>      (make-evaluator 'lang/htdp-intermediate
>>                      "(define (f x)
>>                          (if (zero? x) \"zero\" \"non-zero\"))
>>                       (f 4)"
>>                      )))
>>  (get-uncovered-expressions Ev)
>>
>> and it should also work for a sandbox that is created from a file.
>>
>> --
>>          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>>                    http://barzilay.org/                   Maze is Life!
>
>


Posted on the users mailing list.