Debian Codegraph @

tests/testthat/_snaps/deprecate.md

raw
1 # default deprecations behave as expected
2
3 Code
4 (expect_warning(direct(), class = "lifecycle_warning_deprecated"))
5 Output
6 <warning/lifecycle_warning_deprecated>
7 Warning:
8 `foo()` was deprecated in lifecycle 1.0.0.
9 i Please use `bar()` instead.
10
11 ---
12
13 Code
14 (expect_defunct(deprecate_stop("1.0.0", "foo()")))
15 Output
16 <error/lifecycle_error_deprecated>
17 Error:
18 ! `foo()` was deprecated in lifecycle 1.0.0 and is now defunct.
19
20 # deprecate_warn() only warns repeatedly if always = TRUE
21
22 Code
23 direct()
24 Condition
25 Warning:
26 `foo()` was deprecated in lifecycle 1.0.0.
27 Code
28 direct()
29 indirect()
30 indirect()
31
32 ---
33
34 Code
35 direct(always = TRUE)
36 Condition
37 Warning:
38 `foo()` was deprecated in lifecycle 1.0.0.
39 Code
40 direct(always = TRUE)
41 Condition
42 Warning:
43 `foo()` was deprecated in lifecycle 1.0.0.
44 Code
45 indirect(always = TRUE)
46 indirect(always = TRUE)
47
48 # indirect usage recommends contacting authors
49
50 Code
51 indirect(id = "test_base")
52 Condition
53 Warning:
54 `foo()` was deprecated in lifecycle 1.0.0.
55 i The deprecated feature was likely used in the base package.
56 Please report the issue to the authors.
57 Code
58 indirect_rlang(id = "test_rlang")
59 Condition
60 Warning:
61 `foo()` was deprecated in lifecycle 1.0.0.
62 i The deprecated feature was likely used in the rlang package.
63 Please report the issue at <https://github.com/r-lib/rlang/issues>.
64
65 # what deprecation messages are readable
66
67 Code
68 cat_line(lifecycle_message("1.0.0", "foo()"))
69 Output
70 `foo()` was deprecated in base 1.0.0.
71 Code
72 cat_line(lifecycle_message("1.0.0", "foo()", signaller = "deprecate_stop"))
73 Output
74 `foo()` was deprecated in base 1.0.0 and is now defunct.
75 Code
76 cat_line(lifecycle_message("1.0.0", "foo(arg)"))
77 Output
78 The `arg` argument of `foo()` is deprecated as of base 1.0.0.
79 Code
80 cat_line(lifecycle_message("1.0.0", "foo(arg)", signaller = "deprecate_stop"))
81 Output
82 The `arg` argument of `foo()` was deprecated in base 1.0.0 and is now defunct.
83 Code
84 cat_line(lifecycle_message("1.0.0", I("Use of bananas")))
85 Output
86 Use of bananas was deprecated in base 1.0.0.
87 Code
88 cat_line(lifecycle_message("1.0.0", I("Use of bananas"), signaller = "deprecate_stop"))
89 Output
90 Use of bananas was deprecated in base 1.0.0 and is now defunct.
91
92 # replace deprecation messages are readable
93
94 Code
95 cat_line(lifecycle_message("1.0.0", "foo()", "package::bar()"))
96 Output
97 `foo()` was deprecated in base 1.0.0.
98 Please use `package::bar()` instead.
99 Code
100 cat_line(lifecycle_message("1.0.0", "foo()", "bar()"))
101 Output
102 `foo()` was deprecated in base 1.0.0.
103 Please use `bar()` instead.
104 Code
105 cat_line(lifecycle_message("1.0.0", "foo(arg1)", "foo(arg2)"))
106 Output
107 The `arg1` argument of `foo()` is deprecated as of base 1.0.0.
108 Please use the `arg2` argument instead.
109 Code
110 cat_line(lifecycle_message("1.0.0", "foo(arg)", "bar(arg)"))
111 Output
112 The `arg` argument of `foo()` is deprecated as of base 1.0.0.
113 Please use the `arg` argument of `bar()` instead.
114 Code
115 cat_line(lifecycle_message("1.0.0", I("Use of bananas"), I("apples")))
116 Output
117 Use of bananas was deprecated in base 1.0.0.
118 Please use apples instead.
119
120 # unusual names are handled gracefully
121
122 Code
123 cat_line(lifecycle_message("1.0.0", "`foo-fy`(`qu-ux` = )"))
124 Output
125 The `qu-ux` argument of `foo-fy()` is deprecated as of base 1.0.0.
126 Code
127 cat_line(lifecycle_message("1.0.0", "`foo<-`()"))
128 Output
129 `foo<-()` was deprecated in base 1.0.0.
130 Code
131 cat_line(lifecycle_message("1.0.0", "`+`()"))
132 Output
133 `+()` was deprecated in base 1.0.0.
134
135 # details uses an info bullet by default
136
137 Code
138 deprecate_warn("1.0.0", "foo()", details = "Please do that instead.", id = "test")
139 Condition
140 Warning:
141 `foo()` was deprecated in lifecycle 1.0.0.
142 i Please do that instead.
143 i The deprecated feature was likely used in the base package.
144 Please report the issue to the authors.
145
146 ---
147
148 Code
149 deprecate_warn("1.0.0", "foo()", details = c("Please do that instead.",
150 "Also know that."), id = "test")
151 Condition
152 Warning:
153 `foo()` was deprecated in lifecycle 1.0.0.
154 i Please do that instead.
155 i Also know that.
156 i The deprecated feature was likely used in the base package.
157 Please report the issue to the authors.
158
159 # can use bullets in details
160
161 Code
162 deprecate_warn("1.0.0", "foo()", details = c("Unnamed", i = "Informative", x = "Error"),
163 id = "test")
164 Condition
165 Warning:
166 `foo()` was deprecated in lifecycle 1.0.0.
167 Unnamed
168 i Informative
169 x Error
170 i The deprecated feature was likely used in the base package.
171 Please report the issue to the authors.
172
173 # checks input types
174
175 Code
176 lifecycle_message(1)
177 Condition
178 Error:
179 ! `when` must be a single string, not the number 1.
180
181 ---
182
183 Code
184 lifecycle_message("1", details = 1)
185 Condition
186 Error:
187 ! `details` must be a character vector, not the number 1.
188
189 # lifecycle message is never generated when an `id` is supplied and we've already warned
190
191 Code
192 deprecate_soft(when = stop("when"), what = stop("what"), with = stop("with"),
193 details = stop("details"), env = stop("env"), id = "test")
194
195 ---
196
197 Code
198 deprecate_warn(when = stop("when"), what = stop("what"), with = stop("with"),
199 details = stop("details"), env = stop("env"), id = "test")
200
201 # needs_warning works as expected
202
203 Code
204 needs_warning(1)
205 Condition
206 Error:
207 ! `id` must be a single string, not the number 1.
208