Skip to content

Commit

Permalink
Add test for removing labels
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Dec 5, 2023
1 parent 819476d commit 6863f3b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions R/piping-ini.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,21 +321,24 @@
#'
#' @inheritParams .iniHandleLine
#' @return Nothing, called for side effects
#' @author Bill Denney & Matthew Fidler
#' @keywords internal
#' @noRd
.iniHandleLabel <- function(expr, rxui, envir) {
lhs <- as.character(expr[[2]])
newLabel <- expr[[3]][[2]]
ini <- rxui$ini
.w <- which(ini$name == lhs)
.lhs <- as.character(expr[[2]])
.newLabel <- expr[[3]][[2]]
.ini <- rxui$ini
.w <- which(.ini$name == .lhs)
if (length(.w) != 1) {
stop("cannot find parameter '", lhs, "'", call.=FALSE)
} else if (!is.character(newLabel) || !(length(newLabel) == 1)) {
stop("the new label for '", lhs, "' must be a character string",
stop("cannot find parameter '", .lhs, "'", call.=FALSE)
} else if (is.null(.newLabel)) {
.newLabel <- NA_character_
} else if (!is.character(.newLabel) || !(length(.newLabel) == 1)) {
stop("the new label for '", .lhs, "' must be a character string",
call.=FALSE)
}
ini$label[.w] <- newLabel
assign("iniDf", ini, envir=rxui)
.ini$label[.w] <- .newLabel
assign("iniDf", .ini, envir=rxui)
invisible()
}

Expand Down

0 comments on commit 6863f3b

Please sign in to comment.