1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
local_load_all_quiet()
test_that("data available when lazydata not true", {
load_all("testData")
# a and b are in data/ and shouldn't be available yet
# sysdata_export and sysdata_nonexport are in R/sysdata.rda, and should be available
expect_false(exists("a"))
expect_false(exists("b"))
expect_equal(sysdata_export, 3)
expect_equal(sysdata_nonexport, 4)
# Load the data objects (into the local environment)
data(a, envir = environment())
data(b, envir = environment())
expect_equal(a, 1)
expect_equal(b, 2)
unload("testData")
# Objects loaded with data() should still be available
expect_equal(a, 1)
expect_equal(b, 2)
# Objects loaded in sysdata.rda shouldn't be available
expect_false(exists("sysdata_export"))
expect_false(exists("sysdata_nonexport"))
})
test_that("data available when lazydata is true", {
load_all("testDataLazy")
# a and b are in data/ and should be available because of lazydata
# sysdata_export and sysdata_nonexport are in R/sysdata.rda, and should be available
expect_equal(a, 1)
expect_equal(b, 2)
expect_equal(sysdata_export, 3)
expect_equal(sysdata_nonexport, 4)
unload("testDataLazy")
})
test_that("data available when lazydata not true, and export_all is FALSE", {
load_all("testData", export_all = FALSE)
# a and b are in data/ and shouldn't be available yet
# sysdata_export is exported; sysdata_nonexport isn't
expect_false(exists("a"))
expect_false(exists("b"))
expect_equal(sysdata_export, 3)
expect_false(exists("sysdata_nonexport"))
# Load the data objects (into the local environment)
data(a, envir = environment())
data(b, envir = environment())
expect_equal(a, 1)
expect_equal(b, 2)
# Shouldn't be able to load objects in R/sysdata.rda with data()
expect_warning(data(sysdata_export, envir = environment()))
expect_false(exists("sysdata_nonexport"))
unload("testData")
})
test_that("data available when lazydata is true, and export_all is FALSE", {
load_all("testDataLazy", export_all = FALSE)
# a and b are in data/ and should be available because of lazydata
# sysdata_export is exported; sysdata_nonexport isn't
expect_equal(a, 1)
expect_equal(b, 2)
expect_equal(sysdata_export, 3)
expect_false(exists("sysdata_nonexport"))
# Shouldn't be able to load objects in R/sysdata.rda with data()
expect_warning(data(sysdata_export, envir = environment()))
expect_false(exists("sysdata_nonexport"))
unload("testDataLazy")
})
|