@@ -3,8 +3,8 @@ nc <- st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)
33
44test_that(" select works" , {
55 skip_if_not_installed(" dplyr" )
6- expect_true (nc %> % select_ (" AREA" , attr(. , " sf_column" )) % > % inherits( " sf" ) )
7- expect_true (nc %> % select(AREA ) % > % inherits( " sf" ) )
6+ expect_s3_class (nc %> % select (" AREA" , attr(. , " sf_column" )), " sf" )
7+ expect_s3_class (nc %> % select(AREA ), " sf" )
88})
99
1010test_that(" filter to sfc works" , {
@@ -24,9 +24,9 @@ suppressMessages(require(tidyr, quietly = TRUE))
2424test_that(" separate and unite work" , {
2525 skip_if_not_installed(" dplyr" )
2626 skip_if_not_installed(" tidyr" )
27- expect_true (nc %> % separate(CNTY_ID , c(" a" , " b" ), sep = 2 ) % > % inherits( " sf" ) )
28- expect_true (nc %> % separate(CNTY_ID , c(" a" , " b" ), sep = 2 ) %> %
29- unite(CNTY_ID_NEW , c(" a" , " b" ), sep = " " ) % > % inherits( " sf" ) )
27+ expect_s3_class (nc %> % separate(CNTY_ID , c(" a" , " b" ), sep = 2 ), " sf" )
28+ expect_s3_class (nc %> % separate(CNTY_ID , c(" a" , " b" ), sep = 2 ) %> %
29+ unite(CNTY_ID_NEW , c(" a" , " b" ), sep = " " ), " sf" )
3030})
3131
3232test_that(" separate_rows work" , {
@@ -39,9 +39,7 @@ test_that("separate_rows work", {
3939 st_point(c(2 , 2 )),
4040 st_point(c(3 , 3 ))),
4141 stringsAsFactors = FALSE ))
42- expect_true(d %> %
43- separate_rows(y , convert = TRUE ) %> %
44- inherits(" sf" ))
42+ expect_s3_class(separate_rows(d , y , convert = TRUE ), " sf" )
4543 expect_identical(d %> %
4644 separate_rows(y , convert = TRUE ) %> %
4745 st_geometry(),
@@ -57,7 +55,7 @@ test_that("group/ungroup works", {
5755 skip_if_not_installed(" dplyr" )
5856 tbl = tibble(a = c(1 ,1 ,2 ,2 ), g = st_sfc(st_point(0 : 1 ), st_point(1 : 2 ), st_point(2 : 3 ), st_point(3 : 4 )))
5957 d = st_sf(tbl )
60- e <- d %> % group_by(a ) %> % ungroup
58+ e <- d %> % group_by(a ) %> % ungroup()
6159 expect_equal(as.data.frame(d ), as.data.frame(e ))
6260})
6361
@@ -67,10 +65,10 @@ test_that("sample_n etc work", {
6765 d = st_sf(tbl )
6866
6967 expect_sampled <- function (x ) {
70- expect_true(inherits( x , c(" sf" , " tbl_df" ) ))
68+ expect_s3_class( x , c(" sf" , " tbl_df" ))
7169 expect_named(x , c(" a" , " g" ))
7270 expect_equal(nrow(x ), 2 )
73- expect_true(inherits( x $ g , " sfc_POINT" ) )
71+ expect_s3_class( x $ g , " sfc_POINT" )
7472 }
7573
7674 expect_sampled(sample_n(d , 2 ))
@@ -86,16 +84,8 @@ test_that("nest() works", {
8684
8785 exp_data = list (d [1 : 2 , " g" ], d [3 : 4 , " g" ])
8886
89- # Work around issues of tibble comparison in dplyr 0.8.5 (faulty
90- # all.equal.tbl_df() method)
91- if (utils :: packageVersion(" dplyr" ) < " 0.8.99" ) {
92- dfs = lapply(out $ data , function (x ) st_sf(as.data.frame(x )))
93- exp_data = lapply(exp_data , function (x ) st_sf(as.data.frame(x )))
94- expect_identical(dfs , exp_data )
95- } else {
96- exp = tibble(a = c(1 , 2 ), data = exp_data ) %> % group_by(a )
97- expect_identical(out , exp )
98- }
87+ exp = tibble(a = c(1 , 2 ), data = exp_data ) %> % group_by(a )
88+ expect_identical(out , exp )
9989})
10090
10191test_that(" st_intersection of tbl returns tbl" , {
@@ -286,17 +276,17 @@ test_that("`select()` and `transmute()` observe back-stickiness of geometry colu
286276
287277test_that(" rowwise_df class is retained on row slice" , {
288278 skip_if_not_installed(" dplyr" )
289- expect_true( nc % > % rowwise() % > % slice( 1 ) % > % inherits( " rowwise_df" ) )
279+ expect_s3_class(slice( rowwise(nc ), 1 ), " rowwise_df" )
290280})
291281
292282test_that(" grouped_df class is retained on row slice" , {
293283 skip_if_not_installed(" dplyr" )
294- expect_true (nc %> % group_by(PERIMETER > 2 ) %> % slice(1 ) % > % inherits( " grouped_df" ) )
284+ expect_s3_class (nc %> % group_by(PERIMETER > 2 ) %> % slice(1 ), " grouped_df" )
295285})
296286
297287test_that(" rowwise_df class is retained on filtered rows" , {
298288 skip_if_not_installed(" dplyr" )
299- expect_true (nc %> % rowwise() %> % filter(AREA > .1 ) % > % inherits( " rowwise_df" ) )
289+ expect_s3_class (nc %> % rowwise() %> % filter(AREA > .1 ), " rowwise_df" )
300290})
301291
302292test_that(" `group_split.sf()` ignores `.keep` for rowwise_df class" , {
0 commit comments