tests/getGlobalsSkipCalls.R

# what about calls to until with calls to substitute
# need a predicate function on the call object.

library(CodeAnalysis)

foo =
function(x)
{
    until(x, quote( length(driver$findElements(value = "//foo")) > 0))
}

bar =
function(x)
{
    cur = 1
    until(x, substitute( as.integer(xpathSapply(doc, "//bar", xmlValue)) > num, list(num = cur)))
}

bar2 =
function(x)
{
    cur = 1
    until(other, substitute( as.integer(xpathSapply(doc, "//bar", xmlValue)) > num, list(num = cur)))
}

bar3 =
function(x, y)    
{
    x == Back
}

bar4 =
function(x)    
{
    x == pkg::abc
}

a = getGlobals(foo)
stopifnot(a$variables == "driver")

b = getGlobals(bar, skip = "until")
stopifnot(length(b$variables) == 0)

c = getGlobals(bar2, skip = "substitute")
stopifnot(c$variables == "other")

c = getGlobals(bar2, skip = "substitute", availableVars = c("other"))
stopifnot(length(c$variables) == 0)

d = getGlobals(bar3, availableVars = c("Back"))
stopifnot(length(d$variables) == 0)
duncantl/CodeAnalysis documentation built on March 1, 2025, 9:54 p.m.