is_testing: Test an object for several properties.

Description Usage Arguments Details Value

View source: R/is_testing.R

Description

This function can be used if you would like to test if an object satisfies a bunch of criteria.

Usage

1
2
3
is_testing(obj, .is = NULL, .is_criteria = c("any", "all"),
  .is_not = NULL, .length = NULL, .env = parent.frame(),
  .loop = FALSE)

Arguments

obj

The object to be tested

.is

A vector with the specification of what to test. Note that this should be the part after the . in the tests you would like to try, e.g.\ c("character", "vector")) will trigger the tests is.character and is.vector. The default value NULL will trigger that no tests are performed.

.is_criteria

One of the values c("any", "all") that will decide whether or not any or all will be used when testing the criteria given in .is. The default for this argument is "any".

.is_not

Similar to .is, but used to specify properties we don't want obj to have. The default value NULL will trigger that no such negative tests are performed. Note that all the negative tests must be passed in order for this function to return TRUE.

.length

An integer that can be used to specify the length obj should have. The default value NULL will allow obj to have any length. Use "!0" if it's a requirement that obj should have positive length.

.env

The environment in which the testing should be done. The default value is parent.frame(), but other arguments might be needed during the investigation.

.loop

A logical argument, default FALSE that can be used if it's of interest to investigate all the elements of a given vector/list. Note that it's quite likely that if symbols are included in a list/vector, then it's hard to use any of the apply-functions to loop over it.

Details

WARNING: This function, in it's present incarnation, might need some of its arguments quoted if it's going to be used together with e.g. 'vapply'. It might thus be preferable to adjust the setup so it can investigate vectors and lists itself. I think that task should be feasible, but it might require an additional argument to do this (that is to say, an argument that can be used when the function calls itself iteratively).

Value

The result will be TRUE or FALSE depending on whether or not the specified criteria turned out to be satisfied or not. Diagnostic attributes will be added to the result in order to produce error-messages if that should be of interest.


LAJordanger/leanRcoding documentation built on Feb. 27, 2020, 4:42 p.m.