TypeInfo (version 1.38.0)

NamedTypeTest-class: Class "NamedTypeTest" and sub-classes for tests on class of an object.

Description

These classes are for specifying a test on the type of an object using the class of that object and comparing it to target class names. The tests can be either for x inherits from class name (or is(x, "className")) or x is an instance of class name (i.e. class(x) == "className"). The first of these is represented by InheritsTypeTest and the second by StrictTypeTest.

Arguments

Objects from the NamedTypeTest class

Objects can be created for the non-virtual classes using new("InheritsTypeTest",...) and new("StrictIsTypeTest",...) or the convenience functions InheritsTypeTest(...), StrictIsTypeTest(...) Additionally, where appropriate, a character vector is coerced to InheritsTypeTest.

Slots

.Data:
Object of class "character". This is an internal data type to represent the class names. It is not to be used directly. It is inherited from the “character” class.

Extends

Class "character", from data part. Class "ClassNameOrExpression", directly. Class "vector", by class "character".

Methods

coerce
signature(from = "character", to = "NamedTypeTest"): converts a character vector into a InheritsTypeTest.

See Also

TypedSignature TypeSpecification-class DynamicTypeTest-class

Examples

Run this code
  new("InheritsTypeTest",  c("A", "B"))

  m = array(1:60, c(3, 4, 5))
  tt = new("StrictIsTypeTest",  c("matrix"))
  TypeInfo:::checkType(m, tt)

  tt = new("StrictIsTypeTest",  c("array"))
  TypeInfo:::checkType(m, tt)

Run the code above in your browser using DataCamp Workspace