Skip to content

expect_lt* and expect_gt* with dates and times #777

@boshek

Description

@boshek

I would expect that this should work:

library(testthat)
expect_lte(Sys.time()- 1E5, Sys.time())
#> Error in expect_compare("<=", act, exp): is.numeric(act$val) is not TRUE

Instead I have to resort to this:

library(testthat)
expect_true(Sys.time()- 1E5 <= Sys.time())

Possibly one could add inherits(Sys.time(), "POSIXct") to

stopifnot(is.numeric(act$val), length(act$val) == 1)
stopifnot(is.numeric(exp$val), length(exp$val) == 1)

Am I understanding usage properly here? It could be that these were never meant to be used with dates and times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions