11 files changed +34
-29
lines changed Original file line number Diff line number Diff line change 1
- arglist_is_empty <- function () {
2
- function (x ) {
3
- expect_true(
4
- is.null(formals(x )),
5
- " has empty argument list"
6
- )
7
- }
1
+ expect_arglist_is_empty <- function (object ) {
2
+ act <- quasi_label(rlang :: enquo(object ), arg = " object" )
3
+ act $ formals <- formals(act $ val )
4
+ expect(
5
+ is.null(act $ formals ),
6
+ sprintf(" %s has an empty argument list." , act $ lab )
7
+ )
8
+
9
+ invisible (act $ val )
8
10
}
9
11
10
- all_args_have_default_values <- function () {
11
- function (x ) {
12
- args <- formals(x )
13
- args <- args [names(args ) != " ..." ]
14
- expect_true(
15
- all(vapply(args , function (x ) if (is.null(x )) " NULL" else as.character(x ), character (1L )) != " " ),
16
- " has arguments without default values"
17
- )
18
- }
12
+ expect_all_args_have_default_values <- function (object ) {
13
+ act <- quasi_label(rlang :: enquo(object ), arg = " object" )
14
+ act $ args <- formals(act $ val )
15
+ act $ args <- act $ args [names(act $ args ) != " ..." ]
16
+ act $ char_args <- vapply(act $ args , as.character , character (1L ))
17
+ expect(
18
+ all(nzchar(act $ char_args , keepNA = FALSE )),
19
+ sprintf(" %s has arguments without default values" , act $ lab )
20
+ )
21
+
22
+ invisible (act $ val )
19
23
}
20
24
21
25
has_method <- function (method_name ) {
Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ s4_methods <- function(env, pkg_fun = NULL) {
24
24
}
25
25
26
26
s4_real_argument_names <- function (s4_method ) {
27
- expect_is(s4_method , c(" function" , " MethodDefinition" , " derivedDefaultMethod" ))
27
+ expect_s4_class(s4_method , " function" )
28
+ expect_s4_class(s4_method , " MethodDefinition" )
28
29
unwrapped <- s4_unwrap(s4_method )
29
30
names(formals(unwrapped ))
30
31
}
Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ spec_driver_constructor <- list(
30
30
constructor <- get(constructor_name , mode = " function" , pkg_env )
31
31
32
32
# ' that is callable without arguments.
33
- expect_that (constructor , all_args_have_default_values() )
33
+ expect_all_args_have_default_values (constructor )
34
34
# ' DBI recommends to define a constructor with an empty argument list.
35
35
if (! isTRUE(ctx $ tweaks $ constructor_relax_args )) {
36
- expect_that (constructor , arglist_is_empty() )
36
+ expect_arglist_is_empty (constructor )
37
37
}
38
38
},
39
39
#
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ test_data_type <- function(ctx, dbObj) {
34
34
# ' is returned.
35
35
expect_equal(length(dbDataType(dbObj , value )), .(ncol(value )))
36
36
}
37
- expect_is (dbDataType(dbObj , .(value )), " character" )
37
+ expect_type (dbDataType(dbObj , .(value )), " character" )
38
38
expect_visible(dbDataType(dbObj , .(value )))
39
39
}))
40
40
}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ spec_meta_column_info <- list(
19
19
{
20
20
fields <- dbColumnInfo(res )
21
21
# ' returns a data frame
22
- expect_is (fields , " data.frame" )
22
+ expect_s3_class (fields , " data.frame" )
23
23
# ' with at least two columns `"name"` and `"type"` (in that order)
24
24
expect_equal(names(fields )[1 : 2 ], c(" name" , " type" ))
25
25
# ' (and optional columns that start with a dot).
@@ -30,7 +30,7 @@ spec_meta_column_info <- list(
30
30
iris_ret <- dbFetch(res )
31
31
expect_identical(fields $ name , names(iris_ret ))
32
32
# ' The `"type"` column is of type `character` and only for information.
33
- expect_is (fields $ type , " character" )
33
+ expect_type (fields $ type , " character" )
34
34
# ' Do not compute on the `"type"` column, instead use `dbFetch(res, n = 0)`
35
35
# ' to create a zero-row data frame initialized with the correct data types.
36
36
}
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ spec_meta_get_statement <- list(
17
17
dbSendQuery(con , query ),
18
18
{
19
19
s <- dbGetStatement(res )
20
- expect_is (s , " character" )
20
+ expect_type (s , " character" )
21
21
expect_identical(s , query )
22
22
}
23
23
)
@@ -30,7 +30,7 @@ spec_meta_get_statement <- list(
30
30
dbSendStatement(con , query ),
31
31
{
32
32
s <- dbGetStatement(res )
33
- expect_is (s , " character" )
33
+ expect_type (s , " character" )
34
34
expect_identical(s , query )
35
35
}
36
36
)
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ spec_sql_list_tables <- list(
13
13
list_tables = function (ctx , con , table_name = " dbit07" ) {
14
14
tables <- dbListTables(con )
15
15
# ' returns a character vector
16
- expect_is (tables , " character" )
16
+ expect_type (tables , " character" )
17
17
# ' that enumerates all tables
18
18
expect_false(table_name %in% tables )
19
19
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ spec_sql_quote_identifier <- list(
13
13
# ' `dbQuoteIdentifier()` returns an object that can be coerced to [character],
14
14
simple_out <- dbQuoteIdentifier(con , " simple" )
15
15
expect_error(as.character(simple_out ), NA )
16
- expect_is (as.character(simple_out ), " character" )
16
+ expect_type (as.character(simple_out ), " character" )
17
17
},
18
18
#
19
19
quote_identifier_vectorized = function (ctx , con ) {
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ spec_sql_quote_string <- list(
14
14
simple <- " simple"
15
15
simple_out <- dbQuoteString(con , simple )
16
16
expect_error(as.character(simple_out ), NA )
17
- expect_is (as.character(simple_out ), " character" )
17
+ expect_type (as.character(simple_out ), " character" )
18
18
expect_equal(length(simple_out ), 1L )
19
19
},
20
20
#
Original file line number Diff line number Diff line change @@ -441,7 +441,7 @@ spec_sql_write_table <- list(
441
441
test_table_roundtrip(
442
442
con , tbl_in ,
443
443
transform = function (tbl_out ) {
444
- expect_is (unclass(tbl_out $ a ), " numeric " )
444
+ expect_type (unclass(tbl_out $ a ), " double " )
445
445
tbl_out
446
446
}
447
447
)
Original file line number Diff line number Diff line change 2
2
3
3
get_pkg_path <- function (ctx ) {
4
4
pkg_name <- package_name(ctx )
5
- expect_is (pkg_name , " character" )
5
+ expect_type (pkg_name , " character" )
6
6
7
7
pkg_path <- find.package(pkg_name )
8
8
pkg_path
0 commit comments