fun_make <- function() {
    a <- matrix(1:9, 3)
    tpl <- matrix(numeric(), 3)
    function(x) {
        vetr(tpl)
        TRUE
    }
}

# Make sure we can access defined templates in lexical parents

local({
    NULL
    a <- character()
    fun(a)
})

For argument `x`, `a` should be "matrix" (is "character")

Error in fun(x = a) : 
  For argument `x`, `a` should be "matrix" (is "character")

local({
    b <- character()
    fun(b)
})

For argument `x`, `b` should be "matrix" (is "character")

Error in fun(x = b) : 
  For argument `x`, `b` should be "matrix" (is "character")

fun8b <- function(x) vetr(x = length(.) > 0 && integer())

# make sure we can access variables that are not in fun lexical scope

# should fail, using try b/c of new objectNotFoundError

Error in get("zfqwefkj") : object 'zfqwefkj' not found

local({
    zfqwefkj <- 200L
    fun8b(zfqwefkj)
})

fun <- function(x) {
    a <- quote(all(. > 0))
    b <- quote(is.vector(.))
    vetr(a && b)
    TRUE
}

For argument `x`, `all(-(1:3) > 0)` is not TRUE (FALSE)

Error in fun(x = -(1:3)) : 
  For argument `x`, `all(-(1:3) > 0)` is not TRUE (FALSE)

fun8 <- function(x = "hello", y = TRUE, z) vetr(x = integer(), 
    z = integer(2L))

For argument `z`, `NULL` should be type "integer-like" (is "NULL")

Error in fun8(x = 1L, y = 1:2, z = NULL) : 
  For argument `z`, `NULL` should be type "integer-like" (is "NULL")

argument `z` is missing, with no default

Error in fun8(x = 1L, y = 1:2) : argument `z` is missing, with no default

Error in fun8(x = 1L) : argument `z` is missing, with no default

For argument `x`, `"hello"` should be type "integer-like" (is "character")

Error in fun8(z = 1:2) : 
  For argument `x`, `"hello"` should be type "integer-like" (is "character")

fun1 <- function(x, y) vetr(x > 0, . < 3)

vet/vetr usage error: found symbol `x` in vetting token for object with the same symbol.  Please use `.` to reference the object being checked by the vetting token (e.g. use `vet(. > 0, x)` instead of `vet(x > 0, x)`)

Error in vetr(x > 0, . < 3) : 
  vet/vetr usage error: found symbol `x` in vetting token for object with the same symbol.  Please use `.` to reference the object being checked by the vetting token (e.g. use `vet(. > 0, x)` instead of `vet(x > 0, x)`)