doc / ch.tutteli.atrium.api.cc.infix.en_GB / isA

isA

inline infix fun <reified TSub : Any> Assert<Any>.isA(noinline assertionCreator: AssertionPlant<TSub>.() -> Unit): Unit
Deprecated: Switch from Assert to Expect; will be removed with 1.0.0 -- see https://github.com/robstoll/atrium/releases/tag/v0.12.0#migration for migration hints and scripts.

Makes the assertion that the Assert.subject is a TSub (the same type or a sub-type) and if so, uses assertionCreator which could create further assertions which are added as a group.

Notice, that asserting a function type is flawed. The actual types are ignored as function types erase to Function0, Function1 etc. on byte code level, which means the assertion holds as long as the Assert.subject is a function and has the same amount of arguments regardless if the types differ. For instance assert({x: Int -> "hello"}).isA<String -> Unit>{} holds, even though (Int) -> String is clearly not a (String) -> Unit.

More generally speaking, the flaw applies to all generic types. For instance isA<List<String>> would only check if the Assert.subject is a List without checking if the element type is actually String. Or in other words assert(listOf(1, 2)).isA<List<String>>{} holds, even though List<Int> is clearly not a List<String>.

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
Notice, that this assertion function cannot provide a fluent API because it depends on whether the first assertion (Assert.subject is a TSub) holds or not. Define subsequent assertions via the assertionCreator lambda.