@@ -4,7 +4,7 @@ local_edition(2)
44
55test_that(" uses specified width" , {
66 old <- options(width = 20 )
7- on.exit (options(old ), add = TRUE )
7+ withr :: defer (options(old ))
88
99 x <- 1 : 100
1010 expect_known_output(print(x ), " width-80.txt" )
@@ -51,7 +51,7 @@ test_that("Warning for non-UTF-8 reference files", {
5151 Encoding(x ) <- " latin1"
5252
5353 tmp <- tempfile()
54- on.exit (unlink(tmp ), add = TRUE )
54+ withr :: defer (unlink(tmp ))
5555 writeBin(x , tmp )
5656
5757 suppressWarnings(
@@ -81,7 +81,7 @@ test_that("first run is successful", {
8181
8282test_that(" equal_to_ref does not overwrite existing" , {
8383 tmp_rds <- tempfile(fileext = " .rds" )
84- on.exit (unlink(tmp_rds ))
84+ withr :: defer (unlink(tmp_rds ))
8585 ref_obj1 <- 1 : 3
8686 ref_obj2 <- 2 : 4
8787 saveRDS(ref_obj1 , tmp_rds )
@@ -99,7 +99,7 @@ test_that("equal_to_ref does not overwrite existing", {
9999
100100test_that(" serializes to version 2 by default" , {
101101 tmp_rds <- tempfile(fileext = " .rds" )
102- on.exit (unlink(tmp_rds ))
102+ withr :: defer (unlink(tmp_rds ))
103103
104104 expect_warning(
105105 expect_known_value(" a" , tmp_rds ),
@@ -111,7 +111,7 @@ test_that("serializes to version 2 by default", {
111111
112112test_that(" version 3 is possible" , {
113113 tmp_rds <- tempfile(fileext = " .rds" )
114- on.exit (unlink(tmp_rds ))
114+ withr :: defer (unlink(tmp_rds ))
115115
116116 expect_warning(
117117 expect_known_value(" a" , tmp_rds , version = 3 ),
0 commit comments