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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
test_that("print_max", {
value <- 15L
orig <- get_pillar_option_print_max()
expect_identical(orig, pillar_options$print_max())
old <- set_pillar_option_print_max(value)
expect_equal(get_pillar_option_print_max(), value)
expect_equal(expect_invisible(set_pillar_option_print_max(old)), value)
old <- pillar_options$print_max(value)
expect_equal(pillar_options$print_max(), value)
expect_equal(expect_invisible(pillar_options$print_max(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_print_max(value)), old)
expect_equal(get_pillar_option_print_max(), value)
})
expect_equal(get_pillar_option_print_max(), orig)
})
test_that("print_min", {
value <- 5L
orig <- get_pillar_option_print_min()
expect_identical(orig, pillar_options$print_min())
old <- set_pillar_option_print_min(value)
expect_equal(get_pillar_option_print_min(), value)
expect_equal(expect_invisible(set_pillar_option_print_min(old)), value)
old <- pillar_options$print_min(value)
expect_equal(pillar_options$print_min(), value)
expect_equal(expect_invisible(pillar_options$print_min(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_print_min(value)), old)
expect_equal(get_pillar_option_print_min(), value)
})
expect_equal(get_pillar_option_print_min(), orig)
})
test_that("width", {
value <- 160L
orig <- get_pillar_option_width()
expect_identical(orig, pillar_options$width())
old <- set_pillar_option_width(value)
expect_equal(get_pillar_option_width(), value)
expect_equal(expect_invisible(set_pillar_option_width(old)), value)
old <- pillar_options$width(value)
expect_equal(pillar_options$width(), value)
expect_equal(expect_invisible(pillar_options$width(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_width(value)), old)
expect_equal(get_pillar_option_width(), value)
})
expect_equal(get_pillar_option_width(), orig)
})
test_that("max_footer_lines", {
value <- 15L
orig <- get_pillar_option_max_footer_lines()
expect_identical(orig, pillar_options$max_footer_lines())
old <- set_pillar_option_max_footer_lines(value)
expect_equal(get_pillar_option_max_footer_lines(), value)
expect_equal(expect_invisible(set_pillar_option_max_footer_lines(old)), value)
old <- pillar_options$max_footer_lines(value)
expect_equal(pillar_options$max_footer_lines(), value)
expect_equal(expect_invisible(pillar_options$max_footer_lines(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_max_footer_lines(value)), old)
expect_equal(get_pillar_option_max_footer_lines(), value)
})
expect_equal(get_pillar_option_max_footer_lines(), orig)
})
test_that("max_extra_cols", {
value <- 30L
orig <- get_pillar_option_max_extra_cols()
expect_identical(orig, pillar_options$max_extra_cols())
old <- set_pillar_option_max_extra_cols(value)
expect_equal(get_pillar_option_max_extra_cols(), value)
expect_equal(expect_invisible(set_pillar_option_max_extra_cols(old)), value)
old <- pillar_options$max_extra_cols(value)
expect_equal(pillar_options$max_extra_cols(), value)
expect_equal(expect_invisible(pillar_options$max_extra_cols(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_max_extra_cols(value)), old)
expect_equal(get_pillar_option_max_extra_cols(), value)
})
expect_equal(get_pillar_option_max_extra_cols(), orig)
})
test_that("bold", {
value <- 0L
orig <- get_pillar_option_bold()
expect_identical(orig, pillar_options$bold())
old <- set_pillar_option_bold(value)
expect_equal(get_pillar_option_bold(), value)
expect_equal(expect_invisible(set_pillar_option_bold(old)), value)
old <- pillar_options$bold(value)
expect_equal(pillar_options$bold(), value)
expect_equal(expect_invisible(pillar_options$bold(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_bold(value)), old)
expect_equal(get_pillar_option_bold(), value)
})
expect_equal(get_pillar_option_bold(), orig)
})
test_that("subtle", {
value <- 0L
orig <- get_pillar_option_subtle()
expect_identical(orig, pillar_options$subtle())
old <- set_pillar_option_subtle(value)
expect_equal(get_pillar_option_subtle(), value)
expect_equal(expect_invisible(set_pillar_option_subtle(old)), value)
old <- pillar_options$subtle(value)
expect_equal(pillar_options$subtle(), value)
expect_equal(expect_invisible(pillar_options$subtle(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_subtle(value)), old)
expect_equal(get_pillar_option_subtle(), value)
})
expect_equal(get_pillar_option_subtle(), orig)
})
test_that("subtle_num", {
value <- 0L
orig <- get_pillar_option_subtle_num()
expect_identical(orig, pillar_options$subtle_num())
old <- set_pillar_option_subtle_num(value)
expect_equal(get_pillar_option_subtle_num(), value)
expect_equal(expect_invisible(set_pillar_option_subtle_num(old)), value)
old <- pillar_options$subtle_num(value)
expect_equal(pillar_options$subtle_num(), value)
expect_equal(expect_invisible(pillar_options$subtle_num(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_subtle_num(value)), old)
expect_equal(get_pillar_option_subtle_num(), value)
})
expect_equal(get_pillar_option_subtle_num(), orig)
})
test_that("neg", {
value <- 0L
orig <- get_pillar_option_neg()
expect_identical(orig, pillar_options$neg())
old <- set_pillar_option_neg(value)
expect_equal(get_pillar_option_neg(), value)
expect_equal(expect_invisible(set_pillar_option_neg(old)), value)
old <- pillar_options$neg(value)
expect_equal(pillar_options$neg(), value)
expect_equal(expect_invisible(pillar_options$neg(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_neg(value)), old)
expect_equal(get_pillar_option_neg(), value)
})
expect_equal(get_pillar_option_neg(), orig)
})
test_that("sigfig", {
value <- 5L
orig <- get_pillar_option_sigfig()
expect_identical(orig, pillar_options$sigfig())
old <- set_pillar_option_sigfig(value)
expect_equal(get_pillar_option_sigfig(), value)
expect_equal(expect_invisible(set_pillar_option_sigfig(old)), value)
old <- pillar_options$sigfig(value)
expect_equal(pillar_options$sigfig(), value)
expect_equal(expect_invisible(pillar_options$sigfig(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_sigfig(value)), old)
expect_equal(get_pillar_option_sigfig(), value)
})
expect_equal(get_pillar_option_sigfig(), orig)
})
test_that("min_title_chars", {
value <- 12L
orig <- get_pillar_option_min_title_chars()
expect_identical(orig, pillar_options$min_title_chars())
old <- set_pillar_option_min_title_chars(value)
expect_equal(get_pillar_option_min_title_chars(), value)
expect_equal(expect_invisible(set_pillar_option_min_title_chars(old)), value)
old <- pillar_options$min_title_chars(value)
expect_equal(pillar_options$min_title_chars(), value)
expect_equal(expect_invisible(pillar_options$min_title_chars(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_min_title_chars(value)), old)
expect_equal(get_pillar_option_min_title_chars(), value)
})
expect_equal(get_pillar_option_min_title_chars(), orig)
})
test_that("min_chars", {
value <- 5L
orig <- get_pillar_option_min_chars()
expect_identical(orig, pillar_options$min_chars())
old <- set_pillar_option_min_chars(value)
expect_equal(get_pillar_option_min_chars(), value)
expect_equal(expect_invisible(set_pillar_option_min_chars(old)), value)
old <- pillar_options$min_chars(value)
expect_equal(pillar_options$min_chars(), value)
expect_equal(expect_invisible(pillar_options$min_chars(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_min_chars(value)), old)
expect_equal(get_pillar_option_min_chars(), value)
})
expect_equal(get_pillar_option_min_chars(), orig)
})
test_that("max_dec_width", {
value <- 0L
orig <- get_pillar_option_max_dec_width()
expect_identical(orig, pillar_options$max_dec_width())
old <- set_pillar_option_max_dec_width(value)
expect_equal(get_pillar_option_max_dec_width(), value)
expect_equal(expect_invisible(set_pillar_option_max_dec_width(old)), value)
old <- pillar_options$max_dec_width(value)
expect_equal(pillar_options$max_dec_width(), value)
expect_equal(expect_invisible(pillar_options$max_dec_width(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_max_dec_width(value)), old)
expect_equal(get_pillar_option_max_dec_width(), value)
})
expect_equal(get_pillar_option_max_dec_width(), orig)
})
test_that("bidi", {
value <- TRUE
orig <- get_pillar_option_bidi()
expect_identical(orig, pillar_options$bidi())
old <- set_pillar_option_bidi(value)
expect_equal(get_pillar_option_bidi(), value)
expect_equal(expect_invisible(set_pillar_option_bidi(old)), value)
old <- pillar_options$bidi(value)
expect_equal(pillar_options$bidi(), value)
expect_equal(expect_invisible(pillar_options$bidi(old)), value)
local({
expect_equal(expect_invisible(local_pillar_option_bidi(value)), old)
expect_equal(get_pillar_option_bidi(), value)
})
expect_equal(get_pillar_option_bidi(), orig)
})
test_that("print.tbl ignores max.print option", {
trees2 <- as_tbl(trees)
expect_output(
withr::with_options(list(max.print = 3), print(trees2)),
capture_output(print(trees2)),
fixed = TRUE
)
})
test_that("print.tbl uses tibble.width option", {
mtcars2 <- as_tbl(mtcars)
expect_output(
withr::with_options(list(tibble.width = 40, dplyr.width = 50, width = 60), print(mtcars2)),
capture_output(print(mtcars2, width = 40)),
fixed = TRUE
)
expect_output(
withr::with_options(list(dplyr.width = 50, width = 60), print(mtcars2)),
capture_output(print(mtcars2, width = 50)),
fixed = TRUE
)
expect_output(
withr::with_options(list(width = 60), print(mtcars2)),
capture_output(print(mtcars2, width = 60)),
fixed = TRUE
)
})
|