Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions R/lsDS.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ nfilter.string<-as.numeric(thr$nfilter.string) #
#datashield.privacyLevel<-as.numeric(thr$datashield.privacyLevel) #
#########################################################################

envir.text<-".GlobalEnv"

if(env.to.search==1L)
{
envir.2.search<-eval(parse(text=envir.text))
envir.2.search<-parent.frame()
}else{
envir.2.search<-as.environment(env.to.search)
}
Expand All @@ -51,7 +49,7 @@ j<-0

if(is.null(search.filter))
{
outobj<-ls(pos=env.to.search)
outobj<-ls(envir=envir.2.search)

outlist<-list(environment.searched=environmentName(envir.2.search),objects.found=outobj)

Expand Down Expand Up @@ -92,10 +90,10 @@ return(outlist)

search.filter.final<-paste(search.filter.temp1,collapse="")

outobj<-ls(pos=env.to.search,pattern=utils::glob2rx(search.filter.final))
outobj<-ls(envir=envir.2.search,pattern=utils::glob2rx(search.filter.final))
}else{

outobj<-ls(pos=env.to.search,pattern=utils::glob2rx(search.filter))
outobj<-ls(envir=envir.2.search,pattern=utils::glob2rx(search.filter))
search.filter.final<-search.filter
}

Expand Down
13 changes: 11 additions & 2 deletions tests/testthat/test-smk-lsDS.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test_that("simple lsDS", {
search.filter <- NULL
env.to.search <- 1L

res <- lsDS(search.filter, env.to.search)
res <- eval(call("lsDS", search.filter, env.to.search), envir = .GlobalEnv)

expect_equal(class(res), "list")
expect_length(res, 2)
Expand All @@ -44,7 +44,7 @@ test_that("simple lsDS", {
search.filter <- "_:A:_"
env.to.search <- 1L

res <- lsDS(search.filter, env.to.search)
res <- eval(call("lsDS", search.filter, env.to.search), envir = .GlobalEnv)

expect_equal(class(res), "list")
expect_length(res, 3)
Expand All @@ -55,6 +55,15 @@ test_that("simple lsDS", {
expect_equal(res$search.filter.final, "*")
})

# context("lsDS::smk::calling environment")
test_that("lsDS lists the environment it is called from", {
local.obj <- "value"

res <- lsDS(NULL, 1L)

expect_true("local.obj" %in% res$objects.found)
})

#
# Done
#
Expand Down
Loading