tests/testthat/test_restore.R

library(polmineR)
testthat::context("restore")
use(pkg = "RcppCWB", corpus = "REUTERS")


test_that(
  "restore RData object",
  {
    k <- kwic("REUTERS", query = "oil")
    rdata_file <- tempfile(fileext = ".RData")
    save(k, file = rdata_file)
    rm(k)
    
    load(rdata_file)
    k <- cp(k) # now it is possible to columns by reference
    enrich(k, s_attribute = "id")
    expect_true("id" %in% colnames(k))
  }
)

test_that(
  "restore rds object",
  {
    k <- kwic("REUTERS", query = "oil")
    kwicfile <- tempfile(fileext = ".rds")
    saveRDS(k, file = kwicfile)
    k2 <- restore(kwicfile)
    enrich(k2, s_attribute = "id")
    expect_true("id" %in% colnames(k2))
  }
)

Try the polmineR package in your browser

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

polmineR documentation built on Nov. 2, 2023, 5:52 p.m.