Skip to content

Commit 4dde531

Browse files
authored
Use test_that() everywhere (#701)
Fixes #629
1 parent 363f08a commit 4dde531

16 files changed

Lines changed: 1292 additions & 1300 deletions

tests/testthat/_snaps/S4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# S4_register / errors on unsupported inputs
1+
# S4_register errors on unsupported inputs
22

33
Code
44
S4_register(1)

tests/testthat/_snaps/class.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# S7 classes / print nicely
1+
# S7 classes print nicely
22

33
Code
44
foo2
@@ -41,7 +41,7 @@
4141
List of 1
4242
$ : <foo2/foo1/S7_object> constructor
4343

44-
# S7 classes / prints @package and @abstract details
44+
# S7 classes print @package and @abstract details
4545

4646
Code
4747
foo
@@ -52,7 +52,7 @@
5252
@ validator : <NULL>
5353
@ properties :
5454

55-
# S7 classes / shows property defaults and read-only annotations
55+
# S7 classes show property defaults and read-only annotations
5656

5757
Code
5858
Person
@@ -69,7 +69,7 @@
6969
$ default_expr: S3<Date> = Sys.Date()
7070
$ read_only: <ANY> [read-only]
7171

72-
# S7 classes / checks inputs
72+
# S7 classes check inputs
7373

7474
Code
7575
new_class(1)
@@ -107,7 +107,7 @@
107107
Error in `new_class()`:
108108
! `validator` must be function(self), not function().
109109

110-
# S7 classes / can't inherit from S4 or class unions
110+
# S7 classes can't inherit from S4 or class unions
111111

112112
Code
113113
new_class("test", parent = parentS4)
@@ -125,7 +125,7 @@
125125
* An S4 class object
126126
* A base class
127127

128-
# inheritance / child properties can't widen or change the parent's type
128+
# inheritance doesn't let child properties widen or change the parent's type
129129

130130
Code
131131
new_class("foo2", foo1, properties = list(x = class_character))
@@ -149,7 +149,7 @@
149149
- <foo1>@x is <integer>.
150150
- <foo4>@x is <ANY>.
151151

152-
# abstract classes / can't be instantiated
152+
# abstract classes can't be instantiated
153153

154154
Code
155155
foo := new_class(abstract = TRUE)
@@ -158,7 +158,7 @@
158158
Error in `S7::new_object()`:
159159
! Can't construct an object from abstract class <foo>.
160160

161-
# abstract classes / can't inherit from concrete class
161+
# abstract classes can't inherit from concrete class
162162

163163
Code
164164
foo1 := new_class()
@@ -167,7 +167,7 @@
167167
Error in `new_class()`:
168168
! Abstract classes must have abstract parents.
169169

170-
# abstract classes / can use inherited validator from abstract class
170+
# abstract classes can use inherited validator from abstract class
171171

172172
Code
173173
foo2(x = 2)
@@ -176,15 +176,15 @@
176176
! <foo2> object is invalid:
177177
- @x has bad value
178178

179-
# new_object() / gives useful error if called directly
179+
# new_object() gives useful error if called directly
180180

181181
Code
182182
new_object()
183183
Condition
184184
Error in `new_object()`:
185185
! `new_object()` must be called from within a constructor.
186186

187-
# new_object() / errors if `_parent` doesn't inherit from the parent class (#409)
187+
# new_object() errors if `_parent` doesn't inherit from the parent class (#409)
188188

189189
Code
190190
Foo()
@@ -197,15 +197,15 @@
197197
Error in `new_object()`:
198198
! `_parent` must be an instance of <integer>, not <character>.
199199

200-
# new_object() / errors if `_parent` is supplied but class has no parent
200+
# new_object() errors if `_parent` is supplied but class has no parent
201201

202202
Code
203203
NoParent()
204204
Condition
205205
Error in `new_object()`:
206206
! `_parent` must not be supplied when class has no parent.
207207

208-
# new_object() / validates object
208+
# new_object() validates object
209209

210210
Code
211211
foo("x")
@@ -220,7 +220,7 @@
220220
! <foo> object is invalid:
221221
- x must be positive
222222

223-
# new_object() / runs each parent validator exactly once
223+
# new_object() runs each parent validator exactly once
224224

225225
Code
226226
. <- A()
@@ -235,7 +235,7 @@
235235
Output
236236
A B C
237237

238-
# S7 object / displays nicely
238+
# S7 object displays nicely
239239

240240
Code
241241
foo := new_class(properties = list(x = class_double, y = class_double),
@@ -253,7 +253,7 @@
253253
..@ x: num(0)
254254
..@ y: num(0)
255255

256-
# S7 object / displays objects with data nicely
256+
# S7 object displays objects with data nicely
257257

258258
Code
259259
text := new_class(class_character, package = NULL)
@@ -266,7 +266,7 @@
266266
List of 1
267267
$ : <text> chr "x"
268268

269-
# S7 object / displays data.frame subclasses without error (#494)
269+
# S7 object displays data.frame subclasses without error (#494)
270270

271271
Code
272272
str(mydf(data.frame(a = 1:2, b = 1:2)))
@@ -276,7 +276,7 @@
276276
$ a: int 1 2
277277
$ b: int 1 2
278278

279-
# S7 object / displays list objects nicely
279+
# S7 object displays list objects nicely
280280

281281
Code
282282
foo1(list(x = 1, y = list(a = 21, b = 22)), x = 3, y = list(a = 41, b = 42))

tests/testthat/_snaps/method-introspect.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# method introspection / errors on invalid inputs
1+
# method introspection errors on invalid inputs
22

33
Code
44
method(print, 1)
@@ -33,7 +33,7 @@
3333
Error in `method()`:
3434
! `object` must be length 2.
3535

36-
# method introspection / errors if no method found
36+
# method introspection errors if no method found
3737

3838
Code
3939
method(foo, class = class_integer)
@@ -60,7 +60,7 @@
6060
- x: <integer>
6161
- y: <double>
6262

63-
# method explanation / shows all possible methods along with matches
63+
# method explanation shows all possible methods along with matches
6464

6565
add([foo2], [foo2])
6666
-> add([foo2], [foo1])

tests/testthat/_snaps/method-register.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# method registration / adds messages when overwriting
1+
# method registration adds messages when overwriting
22

33
Code
44
method(foo, class_character) <- (function(x) "c")
55
method(foo, class_character) <- (function(x) "c")
66
Message
77
Overwriting method foo(<character>)
88

9-
# method registration / checks argument types
9+
# method registration checks argument types
1010

1111
Code
1212
x <- 10
@@ -25,15 +25,15 @@
2525
* An S4 class object
2626
* A base class
2727

28-
# method unregistration / removes S7 method via NULL assignment
28+
# method unregistration removes an S7 method via NULL assignment
2929

3030
Code
3131
foo("x")
3232
Condition
3333
Error:
3434
! Can't find method for `foo(<character>)`.
3535

36-
# method unregistration / removes method with multi-dispatch signature
36+
# method unregistration removes a method with a multi-dispatch signature
3737

3838
Code
3939
foo(A(), B())
@@ -43,7 +43,7 @@
4343
- x: <S7::A>
4444
- y: <S7::B>
4545

46-
# as_signature() / accepts a length-1 list for single dispatch (#555)
46+
# as_signature() accepts a length-1 list for single dispatch (#555)
4747

4848
Code
4949
as_signature(list(1), foo)
@@ -56,7 +56,7 @@
5656
* An S4 class object
5757
* A base class
5858

59-
# as_signature() / requires a list of the correct length for multiple dispatch
59+
# as_signature() requires a list of the correct length for multiple dispatch
6060

6161
Code
6262
as_signature(class_character, foo)

tests/testthat/_snaps/property.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# property retrieval / retrieves the properties that exist & errors otherwise
1+
# property retrieval retrieves the properties that exist & errors otherwise
22

33
Code
44
prop(obj, "x")
@@ -11,15 +11,15 @@
1111
Error in `<foo>@x`:
1212
! Property not found.
1313

14-
# prop setting / can't set read-only properties
14+
# prop setting can't set read-only properties
1515

1616
Code
1717
obj@x <- 1
1818
Condition
1919
Error in `<foo>@x`:
2020
! Can't set read-only property.
2121

22-
# prop setting / errors if the property doesn't exist or is wrong class
22+
# prop setting errors if the property doesn't exist or is wrong class
2323

2424
Code
2525
obj <- foo(123)
@@ -33,7 +33,7 @@
3333
Error in `<foo>@x`:
3434
! <foo>@x must be <double>, not <character>
3535

36-
# prop setting / validates all attributes if custom setter
36+
# prop setting validates all attributes if custom setter
3737

3838
Code
3939
obj <- foo(y = 123, x = 123)
@@ -42,15 +42,15 @@
4242
Error in `<foo>@y`:
4343
! <foo>@y must be <double>, not <character>
4444

45-
# prop setting / gives informative error if setter doesn't return an S7 object (#416)
45+
# prop setting gives informative error if setter doesn't return an S7 object (#416)
4646

4747
Code
4848
foo(x = 1.1)
4949
Condition
5050
Error in `<foo>@x`:
5151
! Custom setter must return an <S7_object>, not <integer>.
5252

53-
# props<- / `check = FALSE` skip validation
53+
# props<- with `check = FALSE` skips validation
5454

5555
Code
5656
validate(obj)
@@ -59,7 +59,7 @@
5959
! <S7::foo> object is invalid:
6060
- bad
6161

62-
# props<- / set_props() skip validation with `.check = FALSE`
62+
# props<- set_props() skips validation with `.check = FALSE`
6363

6464
Code
6565
validate(obj2)
@@ -68,7 +68,7 @@
6868
! <S7::foo> object is invalid:
6969
- bad
7070

71-
# new_property() / validates getter and settor
71+
# new_property() validates getter and setter
7272

7373
Code
7474
new_property(getter = function(x) { })
@@ -81,15 +81,15 @@
8181
Error in `new_property()`:
8282
! `setter` must be function(self, value) or function(self, name, value), not function(x, y, z).
8383

84-
# new_property() / validates default
84+
# new_property() validates default
8585

8686
Code
8787
new_property(class_integer, default = "x")
8888
Condition
8989
Error in `new_property()`:
9090
! `default` must be an instance of <integer>, not a <character>.
9191

92-
# new_property() / displays nicely
92+
# new_property() displays nicely
9393

9494
Code
9595
print(x)

tests/testthat/_snaps/super.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# super() / checks to
1+
# super() checks to
22

33
Code
44
foo := new_class(package = NULL)
@@ -17,7 +17,7 @@
1717
Error in `super()`:
1818
! `to` must be an S7, S3, S4, or base class, not NULL.
1919

20-
# super() / displays nicely
20+
# super() displays nicely
2121

2222
Code
2323
f1 <- super(foo2(), foo1)

0 commit comments

Comments
 (0)