tests/testthat/test-coercion.R

test_that("coercing tbl_time to tibble works", {
  df <- as_tbl_time(FANG, date)
  x <- as_tibble(df)

  expect_s3_class(x, c("tbl_df", "tbl", "data.frame"), exact = TRUE)

  # Ensure attributes are dropped
  expect_null(attr(x, "index_quo"))
  expect_null(attr(x, "index_time_zone"))
})

test_that("coercing grouped_tbl_time to tibble drops groupedness", {
  df <- as_tbl_time(FANG, date)
  gdf <- group_by(df, symbol)
  x <- as_tibble(gdf)

  expect_s3_class(x, c("tbl_df", "tbl", "data.frame"), exact = TRUE)
})

Try the tibbletime package in your browser

Any scripts or data that you put into this service are public.

tibbletime documentation built on Feb. 16, 2023, 7:09 p.m.