0

is this a bug in package testthat? I would expect x to be always identical to x... Instead I get an error.

x = structure(logical(0), index = structure(numeric(0), tzone = "", tclass = c("POSIXct", "POSIXt")),
  .indexCLASS = c("POSIXct", "POSIXt"), tclass = c("POSIXct", "POSIXt"), .indexTZ = "", tzone = "",
  class = c("xts", "zoo"), .Dim = c(0L, 4L), .Dimnames = list(NULL, c("F", "G", "H", "J")))
testthat::expect_equivalent(x,x)    
> Error in NextMethod(.Generic) : binary operation on non-conformable arrays

Note that I have testthat version 1.0.2

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
RockScience
  • 17,932
  • 26
  • 89
  • 125

1 Answers1

1

If you expect x to be identical to something, you should use testthat::expect_identical. testthat::expect_equivalent may not work on your x object because it's testing for equivalence between zero-length vectors, and appears to have trouble with that.

That said, I cannot reproduce the error with your code. Here's my sessionInfo output.

R> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] magrittr_1.5   R6_2.0.1       memoise_0.2.1  crayon_1.2.1   digest_0.6.8  
[6] testthat_1.0.2
Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418