datacamp / testwhat

Write Submission Correctness Tests for R exercises
https://datacamp.github.io/testwhat
GNU Affero General Public License v3.0
33 stars 24 forks source link

check_arg("formula") does not flag incorrect formulas for models that are S4 objects #222

Open amy-datacamp opened 5 years ago

amy-datacamp commented 5 years ago

In Longitudinal Analysis in R, in exercises with models that are S4 objects, check_arg("formula") does not flag incorrect formulas and the SCT passes with an incorrect entry.

Here is an example from Chapter 4. The following SCT does not highlight mistakes in the formula.

ex() %>% check_correct(
  check_object(., "uncond_ri") %>% check_equal(), 
  check_function(., "glmer") %>% {
    check_arg(., "formula") %>% check_equal(eval = FALSE) 
    check_arg(., "data") %>% check_equal(eval = FALSE)
    check_arg(., "family") %>% check_equal(eval = FALSE)
  } 
)

The following code needs to be included to flag incorrect formula entries:

ex() %>% check_expr("uncond_ri@call$formula") %>% check_result() %>% check_equal(incorrect_msg = "Did you correctly define `uncond_ri`?", append = FALSE)

cc: @sumedh10