testwhat icon indicating copy to clipboard operation
testwhat copied to clipboard

Docs unclear when check_equal can use the eval arg

Open machow opened this issue 7 years ago • 3 comments

In the case below...

check_object('x') %>% check_equal(eval = FALSE)

the first SCT checks the object exists, and the second checks it's value. Because of this, the argument eval is unused (since you can just omit check_equal altogether). However, this may be a source of confusion for CDs, since a common part in check_function -> check_arg -> check_equal(eval = FALSE).

machow avatar Sep 05 '17 15:09 machow

Excerpt of R/check-call.R:

#' @param eval  logical vector indicating whether and how to compare arguments.
#'   If \code{eval} is \code{NA}, student and solution argument are not
#'   compared. If \code{eval} is \code{FALSE}, the string versions of the
#'   arguments are compared. If \code{eval} is \code{TRUE}, the argument in the
#'   student code is evaluated in the student environment and the argument in
#'   the solution code is evaluated in the solution environment, and their
#'   results are compared. Setting this to \code{FALSE} can be useful, e.g., to
#'   test whether the student supplied a large predefined object, or when you're
#'   in a sub-SCT where the environments are not unambiguously available.

The testwhat wiki lists the same info (see this section).

@machow Did I misunderstand something?

You are right that using check_equal(eval = NA) is unnecessary, and this is something I can look into.

filipsch avatar Apr 16 '18 14:04 filipsch

@filipsch I don't think a person who is using check_equal with check_object will think to look in check_call for documentation.

Here are the docs for ?check_object

image

I am not sure about this, but it seems in this case the eval flag has no effect. If so, it might help for the docs to state on this page that eval has no effect (my memory is hazy, but I think I opened this issue because I saw someone using check_object('x') %>% check_equal(eval = FALSE)

machow avatar Apr 17 '18 13:04 machow

Ah, now I see what you mean. In the context of checking function arguments, check_equal with an eval argument makes sense:

check_function('y') %>% check_arg('a') %>% check_equal(eval = FALSE)

In the context of check_object(), it indeed doesn't. You're right. I'll make sure to fix the documentation to reflect this, one way or the other.

filipsch avatar Apr 17 '18 13:04 filipsch