Dart API ReferenceunittestisInstanceOf<T>

isInstanceOf<T> Class

Returns a matcher that matches if an object is an instance of type (or a subtype).

As types are not first class objects in Dart we can only approximate this test by using a generic wrapper class.

For example, to test whether 'bar' is an instance of type 'Foo', we would write:

expect(bar, new isInstanceOf<Foo>());

To get better error message, supply a name when creating the Type wrapper; e.g.:

expect(bar, new isInstanceOf<Foo>('Foo'));

Extends

BaseMatcher > isInstanceOf<T>

Constructors

Code const isInstanceOf([name = 'specified type']) #

const isInstanceOf([name = 'specified type']) : this._name = name;

Methods

Code Description describe(Description description) #

Description describe(Description description) =>
    description.add('an instance of ${_name}');

Code bool matches(obj, MatchState matchState) #

bool matches(obj, MatchState matchState) => obj is T;