Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilovemane committed Aug 15, 2024
1 parent 722271c commit 8a55490
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions R/attr.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,15 @@ detect_void_name <- function(x) {
is_dictionaryish <- function(x) {
# 2022-01: Used in many packages. Don't deprecate without a
# replacement.
if (!length(x)) {
return(!is.null(x))
}
if (is.null(names(x))) {
if (is.null(x)) {
TRUE
} else {
if (!length(x)) {
return(!is.null(x))
}

is_named(x) && !any(duplicated(names(x)))

}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-attr.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ test_that("zap_srcref() works on calls", {
expect_true("srcref" %in% names(attributes(call)))
})

test_that("is_dictionaryish return true if names(x) is NULL", {
x <- "x"
expect_true(is_dictionaryish(x))
test_that("is_dictionaryish return true if is NULL", {

expect_true(is_dictionaryish(NULL))
})

0 comments on commit 8a55490

Please sign in to comment.