Skip to content

Commit

Permalink
Merge pull request #101 from tidyverse/fix-testthat-breaking-change
Browse files Browse the repository at this point in the history
- Establish compatibility with development version of testthat (#101, @lionel-).
  • Loading branch information
krlmlr committed Sep 26, 2021
2 parents d3f4b40 + 037d4ce commit ca3f4f5
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions tests/testthat/test-coercion-deprecated.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
test_that("coercion in", {
expect_identical(expect_deprecated(as.hms(0.5 * 86400)), hms(hours = 12))
expect_identical(expect_deprecated(as.hms(-0.25 * 86400)), hms(hours = -6))
expect_hms_equal(expect_deprecated(as.hms("12:34:56")), hms(56, 34, 12))
expect_hms_equal(
expect_deprecated(as.hms(strptime("12:34:56", format = "%H:%M:%S", tz = "UTC"), tz = "UTC")),
hms(56, 34, 12)
expect_deprecated(
expect_identical(as.hms(0.5 * 86400), hms(hours = 12))
)
expect_hms_equal(
expect_deprecated(as.hms(strptime("12:34:56", format = "%H:%M:%S", tz = "CEST"), tz = "CEST")),
hms(56, 34, 12)
expect_deprecated(
expect_identical(as.hms(-0.25 * 86400), hms(hours = -6))
)
expect_hms_equal(
expect_deprecated(as.hms(strptime("12:34:56", format = "%H:%M:%S", tz = "PST8PDT"), tz = "PST8PDT")),
hms(56, 34, 12)
expect_deprecated(
expect_hms_equal(as.hms("12:34:56"), hms(56, 34, 12))
)
expect_deprecated(
expect_hms_equal(
as.hms(strptime("12:34:56", format = "%H:%M:%S", tz = "UTC"), tz = "UTC"),
hms(56, 34, 12)
)
)
expect_deprecated(
expect_hms_equal(
as.hms(strptime("12:34:56", format = "%H:%M:%S", tz = "CEST"), tz = "CEST"),
hms(56, 34, 12)
)
)
expect_deprecated(
expect_hms_equal(
as.hms(strptime("12:34:56", format = "%H:%M:%S", tz = "PST8PDT"), tz = "PST8PDT"),
hms(56, 34, 12)
)
)

now <- Sys.time()
now_lt <- as.POSIXlt(now)
expect_hms_equal(expect_deprecated(as.hms(now)), hms(now_lt$sec, now_lt$min, now_lt$hour))
expect_hms_equal(expect_deprecated(as.hms(now_lt)), as_hms(now))
expect_deprecated(
expect_hms_equal(as.hms(now), hms(now_lt$sec, now_lt$min, now_lt$hour))
)
expect_deprecated(
expect_hms_equal(as.hms(now_lt), as_hms(now))
)

expect_error(expect_deprecated(as.hms(FALSE)))
})
Expand Down

0 comments on commit ca3f4f5

Please sign in to comment.