Skip to content

Commit 164ce42

Browse files
committed
Fix check_arg_type()
1 parent 01558a5 commit 164ce42

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: qualifyr
22
Type: Package
33
Title: Validate Relational Data Structures
4-
Version: 0.1.0.9000
4+
Version: 0.1.0.9002
55
Authors@R: c(
66
person(
77
"Ian", "Farm",

R/utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ format_indices <- function(x, max_len = Inf) {
116116
# Miscellaneous ================================================================
117117

118118
check_arg_type <- function(arg, type, predicate = \(x) inherits(x, type)) {
119-
arg_name <- rlang::ensym(arg)
119+
arg_name <- rlang::as_string(rlang::ensym(arg))
120120
if (!(predicate)(arg))
121121
stop(sprintf("'%s' must be a %s, not %s", arg_name, type, typeof(arg)))
122122
}

tests/testthat/test-qf_table.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@ test_that("print() output is correct", {
6262
dset <- example_dataset()
6363
expect_snapshot_output(print(dset$planes))
6464
})
65+
66+
test_that("argument type checking works", {
67+
dset <- example_dataset()
68+
expect_error(regexp = "'x' must be a qf_table, not NULL", {
69+
constraints(dset$planez) <-
70+
cstr_primary_key(tailnum)
71+
})
72+
})

0 commit comments

Comments
 (0)