datacamp / testwhat

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

Weird behavior for check_output_expr() #199

Open filipsch opened 6 years ago

filipsch commented 6 years ago

@beccarobins brought some weird behavior of check_output_expr() to my attention related to some exotic R objects. The following local simulation of an exercise fails, while it shouldn't:

pec <- '
library(readr)
co_counties <- read_rds(gzcon(url("https://assets.datacamp.com/production/repositories/2059/datasets/7e54320199c0894a3d517507362a8dc3abf8fcaf/ch3_co_counties.rds")))
'

code <- 'co_counties@proj4string'

library(testwhat)
setup_state(pec = pec, sol_code = sol_code, stu_code = stu_code)

# This doesn't work
ex() %>% check_output_expr(., "co_counties@proj4string")

# This works:
ex() %>% check_output_expr(., "print(co_counties@proj4string)")

It seems that the co_counties object behaves differently whether or not you're using print, and check_output_expr can't handle it:

> co_counties@proj4string
An object of class "CRS"
Slot "projargs":
[1] "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0"

> print(co_counties@proj4string)
CRS arguments:
 +proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0

Not sure what's going on.