@@ -110,25 +110,25 @@ test_that("enlist works",{
110110})
111111
112112test_that(" assert_sufficient_f_args alerts if the provided f doesn't take enough args" , {
113- f_xg = function (x , g ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
114- f_xg_dots = function (x , g , ... ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
113+ f_xgt = function (x , g , t ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
114+ f_xgt_dots = function (x , g , t , ... ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
115115
116116 # If `regexp` is NA, asserts that there should be no errors/messages.
117- expect_error(assert_sufficient_f_args(f_xg ), regexp = NA )
118- expect_warning(assert_sufficient_f_args(f_xg ), regexp = NA )
119- expect_error(assert_sufficient_f_args(f_xg_dots ), regexp = NA )
120- expect_warning(assert_sufficient_f_args(f_xg_dots ), regexp = NA )
117+ expect_error(assert_sufficient_f_args(f_xgt ), regexp = NA )
118+ expect_warning(assert_sufficient_f_args(f_xgt ), regexp = NA )
119+ expect_error(assert_sufficient_f_args(f_xgt_dots ), regexp = NA )
120+ expect_warning(assert_sufficient_f_args(f_xgt_dots ), regexp = NA )
121121
122122 f_x_dots = function (x , ... ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
123123 f_dots = function (... ) dplyr :: tibble(value = c(5 ), count = c(2 ))
124124 f_x = function (x ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
125125 f = function () dplyr :: tibble(value = c(5 ), count = c(2 ))
126126
127127 expect_warning(assert_sufficient_f_args(f_x_dots ),
128- regexp = " , the group key will be included" ,
128+ regexp = " , the group key and reference time value will be included" ,
129129 class = " epiprocess__assert_sufficient_f_args__mandatory_f_args_passed_to_f_dots" )
130130 expect_warning(assert_sufficient_f_args(f_dots ),
131- regexp = " , the window data and group key will be included" ,
131+ regexp = " , the window data, group key, and reference time value will be included" ,
132132 class = " epiprocess__assert_sufficient_f_args__mandatory_f_args_passed_to_f_dots" )
133133 expect_error(assert_sufficient_f_args(f_x ),
134134 class = " epiprocess__assert_sufficient_f_args__f_needs_min_args" )
@@ -142,46 +142,42 @@ test_that("assert_sufficient_f_args alerts if the provided f doesn't take enough
142142 expect_error(assert_sufficient_f_args(f_xs , setting = " b" ),
143143 class = " epiprocess__assert_sufficient_f_args__f_needs_min_args_plus_forwarded" )
144144
145- expect_error(assert_sufficient_f_args(f_xg , " b" ),
145+ expect_error(assert_sufficient_f_args(f_xgt , " b" ),
146146 class = " epiprocess__assert_sufficient_f_args__f_needs_min_args_plus_forwarded" )
147147})
148148
149149test_that(" assert_sufficient_f_args alerts if the provided f has defaults for the required args" , {
150- f_xg = function (x , g = 1 ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
151- f_xg_dots = function (x = 1 , g , ... ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
150+ f_xgt = function (x , g = 1 , t ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
151+ f_xgt_dots = function (x = 1 , g , t , ... ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
152152 f_x_dots = function (x = 1 , ... ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
153153
154- expect_error(assert_sufficient_f_args(f_xg ),
154+ expect_error(assert_sufficient_f_args(f_xgt ),
155155 regexp = " pass the group key to `f`'s g argument," ,
156156 class = " epiprocess__assert_sufficient_f_args__required_args_contain_defaults" )
157- expect_error(assert_sufficient_f_args(f_xg_dots ),
157+ expect_error(assert_sufficient_f_args(f_xgt_dots ),
158158 regexp = " pass the window data to `f`'s x argument," ,
159159 class = " epiprocess__assert_sufficient_f_args__required_args_contain_defaults" )
160160 expect_error(suppressWarnings(assert_sufficient_f_args(f_x_dots )),
161161 class = " epiprocess__assert_sufficient_f_args__required_args_contain_defaults" )
162162
163- f_xsg = function (x , setting = " a" , g ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
164- f_xsg_dots = function (x , setting = " a" , g , ... ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
163+ f_xsgt = function (x , setting = " a" , g , t ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
164+ f_xsgt_dots = function (x , setting = " a" , g , t , ... ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
165165 f_xs_dots = function (x = 1 , setting = " a" , ... ) dplyr :: tibble(value = mean(x $ binary ), count = length(x $ binary ))
166166
167167 # forwarding named dots should prevent some complaints:
168- expect_no_error(assert_sufficient_f_args(f_xsg , setting = " b" ))
169- expect_no_error(assert_sufficient_f_args(f_xsg_dots , setting = " b" ))
168+ expect_no_error(assert_sufficient_f_args(f_xsgt , setting = " b" ))
169+ expect_no_error(assert_sufficient_f_args(f_xsgt_dots , setting = " b" ))
170170 expect_error(suppressWarnings(assert_sufficient_f_args(f_xs_dots , setting = " b" )),
171- regexp = " window data to `f`'s x argument" ,
171+ regexp = " pass the window data to `f`'s x argument" ,
172172 class = " epiprocess__assert_sufficient_f_args__required_args_contain_defaults" )
173173
174174 # forwarding unnamed dots should not:
175- expect_error(assert_sufficient_f_args(f_xsg , " b" ),
175+ expect_error(assert_sufficient_f_args(f_xsgt , " b" ),
176176 class = " epiprocess__assert_sufficient_f_args__required_args_contain_defaults" )
177- expect_error(assert_sufficient_f_args(f_xsg_dots , " b" ),
177+ expect_error(assert_sufficient_f_args(f_xsgt_dots , " b" ),
178178 class = " epiprocess__assert_sufficient_f_args__required_args_contain_defaults" )
179- expect_error(assert_sufficient_f_args(f_xs_dots , " b" ),
180- class = " epiprocess__assert_sufficient_f_args__required_args_contain_defaults" )
181-
182- # forwarding no dots should produce a different error message in some cases:
183- expect_error(assert_sufficient_f_args(f_xs_dots ),
184- regexp = " window data and group key to `f`'s x and setting argument" ,
179+ expect_error(suppressWarnings(assert_sufficient_f_args(f_xs_dots , " b" )),
180+ regexp = " pass the window data and group key to `f`'s x and setting argument" ,
185181 class = " epiprocess__assert_sufficient_f_args__required_args_contain_defaults" )
186182})
187183
0 commit comments