Skip to content

Commit c8752d3

Browse files
committed
Use test_that() everywhere
Fixes #629
1 parent bf78cd3 commit c8752d3

16 files changed

Lines changed: 1175 additions & 1190 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: 17 additions & 17 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-
# abstract classes / can't be instantiated
128+
# abstract classes can't be instantiated
129129

130130
Code
131131
foo := new_class(abstract = TRUE)
@@ -134,7 +134,7 @@
134134
Error in `S7::new_object()`:
135135
! Can't construct an object from abstract class <foo>.
136136

137-
# abstract classes / can't inherit from concrete class
137+
# abstract classes can't inherit from concrete class
138138

139139
Code
140140
foo1 := new_class()
@@ -143,7 +143,7 @@
143143
Error in `new_class()`:
144144
! Abstract classes must have abstract parents.
145145

146-
# abstract classes / can use inherited validator from abstract class
146+
# abstract classes can use inherited validator from abstract class
147147

148148
Code
149149
foo2(x = 2)
@@ -152,15 +152,15 @@
152152
! <foo2> object is invalid:
153153
- @x has bad value
154154

155-
# new_object() / gives useful error if called directly
155+
# new_object() gives useful error if called directly
156156

157157
Code
158158
new_object()
159159
Condition
160160
Error in `new_object()`:
161161
! `new_object()` must be called from within a constructor.
162162

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

165165
Code
166166
Foo()
@@ -173,15 +173,15 @@
173173
Error in `new_object()`:
174174
! `_parent` must be an instance of <integer>, not <character>.
175175

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

178178
Code
179179
NoParent()
180180
Condition
181181
Error in `new_object()`:
182182
! `_parent` must not be supplied when class has no parent.
183183

184-
# new_object() / validates object
184+
# new_object() validates object
185185

186186
Code
187187
foo("x")
@@ -196,7 +196,7 @@
196196
! <foo> object is invalid:
197197
- x must be positive
198198

199-
# new_object() / runs each parent validator exactly once
199+
# new_object() runs each parent validator exactly once
200200

201201
Code
202202
. <- A()
@@ -211,7 +211,7 @@
211211
Output
212212
A B C
213213

214-
# S7 object / displays nicely
214+
# S7 object displays nicely
215215

216216
Code
217217
foo := new_class(properties = list(x = class_double, y = class_double),
@@ -229,7 +229,7 @@
229229
..@ x: num(0)
230230
..@ y: num(0)
231231

232-
# S7 object / displays objects with data nicely
232+
# S7 object displays objects with data nicely
233233

234234
Code
235235
text := new_class(class_character, package = NULL)
@@ -242,7 +242,7 @@
242242
List of 1
243243
$ : <text> chr "x"
244244

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

247247
Code
248248
str(mydf(data.frame(a = 1:2, b = 1:2)))
@@ -252,7 +252,7 @@
252252
$ a: int 1 2
253253
$ b: int 1 2
254254

255-
# S7 object / displays list objects nicely
255+
# S7 object displays list objects nicely
256256

257257
Code
258258
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)