Skip to content

Commit 8240395

Browse files
author
Junlue Zhao
committed
Merge branch '1260_warning_when_nothing_appended' into 1104_mutate_delayed
2 parents 5faa07d + 16b9e27 commit 8240395

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

R/CodeClass.R

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ CodeClass <- R6::R6Class( # nolint
8585
private$set_code_single(code_i)
8686
}
8787
if (identical(prior, self$code)) {
88-
warning("Code is not added because it is identical to previously added code.", call. = FALSE)
88+
warning("Code is not appended because it is identical to previously added code.", call. = FALSE)
8989
}
9090
return(invisible(self))
9191
}
@@ -107,13 +107,9 @@ CodeClass <- R6::R6Class( # nolint
107107

108108
code <- pretty_code_string(code)
109109

110-
prior <- self$code
111110
for (code_single in code) {
112111
private$set_code_single(code_single, dataname, deps)
113112
}
114-
if (identical(prior, self$code)) {
115-
warning("Code is not added because it is identical to previously added code.", call. = FALSE)
116-
}
117113

118114
return(invisible(self))
119115
},

tests/testthat/test-CodeClass.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ test_that("Duplicated code is appended if it doesn't have a dataname", {
158158
test_that("Duplicated code is not appended if its dataname is duplicated", {
159159
cc1 <- CodeClass$new(code = "print('test')", dataname = "test")
160160
cc2 <- CodeClass$new(code = "print('test')", dataname = "test")
161-
cc1$append(cc2)
161+
expect_warning(
162+
cc1$append(cc2),
163+
regexp = "Code is not appended because it is identical to previously added code."
164+
)
162165
expect_equal(
163166
cc1$get_code(),
164167
"print(\"test\")")

0 commit comments

Comments
 (0)