asList

fun <E> Expect<out Array<out E>>.asList(): Expect<List<E>>(source)

Turns Expect<Array<E>> into Expect<List<E>>.

The transformation as such is not reflected in reporting. Use feature(Array<out E>::asList) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(arrayOf("A", "B"))
    .asList()  // subject is now of type List<String>
    .toEqual(listOf("A", "B"))

fails {
    expect(arrayOf("A", "B"))
        .asList()  // subject is now of type List<String>
        .toContain("C")  // fails
        .toContain("D")  // not evaluated/reported because above `toContain` already fails
    //                      use `.asList { ... }` if you want that all expectations are evaluated
}

@JvmName(name = "byteArrAsList")
fun Expect<ByteArray>.asList(): Expect<List<Byte>>(source)

Turns Expect<CharArray> into Expect<List<Byte>>.

The transformation as such is not reflected in reporting. Use feature(ByteArray::asList) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(byteArrayOf(1, 2, 3))
    .asList() // subject is now of type List<Byte>
    .toEqual(listOf<Byte>(1, 2, 3))

@JvmName(name = "byteArrAsList")
fun Expect<ByteArray>.asList(assertionCreator: Expect<List<Byte>>.() -> Unit): Expect<ByteArray>(source)

Expects that the subject of this expectation holds all assertions the given assertionCreator creates for the subject as List.

The transformation as such is not reflected in reporting. Use feature(ByteArray::asList, assertionCreator) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(byteArrayOf(1, 2, 3))
    .asList { // subject within this expectation-group is of type List<Byte>
        toEqual(listOf<Byte>(1, 2, 3))
    } // subject here is back to type Array<Byte>

fails {
    // all expectations inside an expectation-group are evaluated together; for more details see:
    // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group

    expect(byteArrayOf(1, 2, 3))
        .asList {
            toContain(98)  // fails
            toContain(99)  // still evaluated even though above `toContain` already fails
            //                 use `.asList().` if you want a fail fast behaviour
        }
}

@JvmName(name = "charArrAsList")
fun Expect<CharArray>.asList(): Expect<List<Char>>(source)

Turns Expect<CharArray> into Expect<List<Char>>.

The transformation as such is not reflected in reporting. Use feature(CharArray::asList) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(charArrayOf('A', 'B', 'C'))
    .asList() // subject is now of type List<Char>
    .toEqual(listOf('A', 'B', 'C'))

@JvmName(name = "charArrAsList")
fun Expect<CharArray>.asList(assertionCreator: Expect<List<Char>>.() -> Unit): Expect<CharArray>(source)

Expects that the subject of this expectation holds all assertions the given assertionCreator creates for the subject as List.

The transformation as such is not reflected in reporting. Use feature(CharArray::asList, assertionCreator) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(charArrayOf('A', 'B', 'C'))
    .asList { // subject within this expectation-group is of type List<Char>
        toEqual(listOf('A', 'B', 'C'))
    } // subject here is back to type Array<Char>

fails {
    // all expectations inside an expectation-group are evaluated together; for more details see:
    // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group

    expect(charArrayOf('A', 'B', 'C'))
        .asList {
            toContain('X')  // fails
            toContain('Y')  // still evaluated even though above `toContain` already fails
            //                 use `.asList().` if you want a fail fast behaviour
        }
}

@JvmName(name = "shortArrAsList")
fun Expect<ShortArray>.asList(): Expect<List<Short>>(source)

Turns Expect<ShortArray> into Expect<List<Short>>.

The transformation as such is not reflected in reporting. Use feature(ShortArray::asList) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(shortArrayOf(1, 2, 3))
    .asList() // subject is now of type List<Short>
    .toEqual(listOf<Short>(1, 2, 3))

@JvmName(name = "shortArrAsList")
fun Expect<ShortArray>.asList(assertionCreator: Expect<List<Short>>.() -> Unit): Expect<ShortArray>(source)

Expects that the subject of this expectation holds all assertions the given assertionCreator creates for the subject as List.

The transformation as such is not reflected in reporting. Use feature(ShortArray::asList, assertionCreator) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(shortArrayOf(1, 2, 3))
    .asList { // subject within this expectation-group is of type List<Short>
        toEqual(listOf<Short>(1, 2, 3))
    } // subject here is back to type Array<Short>

fails {
    // all expectations inside an expectation-group are evaluated together; for more details see:
    // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group

    expect(shortArrayOf(1, 2, 3))
        .asList {
            toContain(98)  // fails
            toContain(99)  // still evaluated even though above `toContain` already fails
            //                 use `.asList().` if you want a fail fast behaviour
        }
}

@JvmName(name = "intArrAsList")
fun Expect<IntArray>.asList(): Expect<List<Int>>(source)

Turns Expect<IntArray> into Expect<List<Int>>.

The transformation as such is not reflected in reporting. Use feature(IntArray::asList) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(intArrayOf(1, 2, 3))
    .asList() // subject is now of type List<Int>
    .toEqual(listOf(1, 2, 3))

@JvmName(name = "intArrAsList")
fun Expect<IntArray>.asList(assertionCreator: Expect<List<Int>>.() -> Unit): Expect<IntArray>(source)

Expects that the subject of this expectation holds all assertions the given assertionCreator creates for the subject as List.

The transformation as such is not reflected in reporting. Use feature(IntArray::asList, assertionCreator) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(intArrayOf(1, 2, 3))
    .asList { // subject within this expectation-group is of type List<Int>
        toEqual(listOf(1, 2, 3))
    } // subject here is back to type Array<Int>

fails {
    // all expectations inside an expectation-group are evaluated together; for more details see:
    // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group

    expect(intArrayOf(1, 2, 3))
        .asList {
            toContain(98)  // fails
            toContain(99)  // still evaluated even though above `toContain` already fails
            //                 use `.asList().` if you want a fail fast behaviour
        }
}

@JvmName(name = "longArrAsList")
fun Expect<LongArray>.asList(): Expect<List<Long>>(source)

Turns Expect<LongArray> into Expect<List<Double>>.

The transformation as such is not reflected in reporting. Use feature(LongArray::asList) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(longArrayOf(1L, 2L, 3L)) // subject is now of type List<Long>
    .asList()
    .toEqual(listOf(1L, 2L, 3L))

@JvmName(name = "longArrAsList")
fun Expect<LongArray>.asList(assertionCreator: Expect<List<Long>>.() -> Unit): Expect<LongArray>(source)

Expects that the subject of this expectation holds all assertions the given assertionCreator creates for the subject as List.

The transformation as such is not reflected in reporting. Use feature(LongArray::asList, assertionCreator) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(longArrayOf(1L, 2L, 3L))
    .asList { // subject within this expectation-group is of type List<Long>
        toEqual(listOf(1L, 2L, 3L))
    } // subject here is back to type Array<Long>

fails {
    // all expectations inside an expectation-group are evaluated together; for more details see:
    // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group

    expect(longArrayOf(1L, 2L, 3L))
        .asList {
            toContain(98L)  // fails
            toContain(99L)  // still evaluated even though above `toContain` already fails
            //                 use `.asList().` if you want a fail fast behaviour
        }
}

@JvmName(name = "floatArrAsList")
fun Expect<FloatArray>.asList(): Expect<List<Float>>(source)

Turns Expect<FloatArray> into Expect<List<Float>>.

The transformation as such is not reflected in reporting. Use feature(FloatArray::asList) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(floatArrayOf(1f, 2f, 3f))
    .asList() // subject is now of type List<Float>
    .toEqual(listOf(1f, 2f, 3f))

@JvmName(name = "floatArrAsList")
fun Expect<FloatArray>.asList(assertionCreator: Expect<List<Float>>.() -> Unit): Expect<FloatArray>(source)

Expects that the subject of this expectation holds all assertions the given assertionCreator creates for the subject as List.

The transformation as such is not reflected in reporting. Use feature(FloatArray::asList, assertionCreator) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(floatArrayOf(1f, 2f, 3f))
    .asList { // subject within this expectation-group is of type List<Float>
        toEqual(listOf(1f, 2f, 3f))
    } // subject here is back to type Array<Float>

fails {
    // all expectations inside an expectation-group are evaluated together; for more details see:
    // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group

    expect(floatArrayOf(1f, 2f, 3f))
        .asList {
            toContain(98f)  // fails
            toContain(99f)  // still evaluated even though above `toContain` already fails
            //                 use `.asList().` if you want a fail fast behaviour
        }
}

@JvmName(name = "doubleArrAsList")
fun Expect<DoubleArray>.asList(): Expect<List<Double>>(source)

Turns Expect<DoubleArray> into Expect<List<Double>>.

The transformation as such is not reflected in reporting. Use feature(DoubleArray::asList) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(doubleArrayOf(1.1, 2.2, 3.3))
    .asList() // subject is now of type List<Double>
    .toEqual(listOf(1.1, 2.2, 3.3))

@JvmName(name = "doubleArrAsList")
fun Expect<DoubleArray>.asList(assertionCreator: Expect<List<Double>>.() -> Unit): Expect<DoubleArray>(source)

Expects that the subject of this expectation holds all assertions the given assertionCreator creates for the subject as List.

The transformation as such is not reflected in reporting. Use feature(DoubleArray::asList, assertionCreator) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(doubleArrayOf(1.1, 2.2, 3.3))
    .asList { // subject within this expectation-group is of type List<Double>
        toEqual(listOf(1.1, 2.2, 3.3))
    } // subject here is back to type Array<Double>

fails {
    // all expectations inside an expectation-group are evaluated together; for more details see:
    // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group

    expect(doubleArrayOf(1.1, 2.2, 3.3))
        .asList {
            toContain(98.1)  // fails
            toContain(99.2)  // still evaluated even though above `toContain` already fails
            //                 use `.asList().` if you want a fail fast behaviour
        }
}

@JvmName(name = "boolArrAsList")
fun Expect<BooleanArray>.asList(): Expect<List<Boolean>>(source)

Turns Expect<BooleanArray> into Expect<List<Boolean>>.

The transformation as such is not reflected in reporting. Use feature(BooleanArray::asList) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(booleanArrayOf(true, false))
    .asList() // subject is now of type List<Boolean>
    .toEqual(listOf(true, false))

@JvmName(name = "boolArrAsList")
fun Expect<BooleanArray>.asList(assertionCreator: Expect<List<Boolean>>.() -> Unit): Expect<BooleanArray>(source)

Expects that the subject of this expectation holds all assertions the given assertionCreator creates for the subject as List.

The transformation as such is not reflected in reporting. Use feature(BooleanArray::asList, assertionCreator) if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.9.0

Samples

expect(booleanArrayOf(true, false))
    .asList { // subject within this expectation-group is of type List<Boolean>
        toEqual(listOf(true, false))
    } // subject here is back to type Array<Boolean>

fails {
    // all expectations inside an expectation-group are evaluated together; for more details see:
    // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group

    expect(booleanArrayOf(true, true))
        .asList {
            // fails
            toContain(false)

            // still evaluated even though above `toContain` already fails
            // use `.asList().` if you want a fail fast behaviour
            toContain.inAnyOrder.atLeast(3).value(true)
        }
}

Turns Expect<E, T : Iterable<E>> into Expect<List<E>.

The transformation as such is not reflected in reporting. Use feature { f(it::toList) } if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.14.0

Samples

expect(0..2)
    .asList()  // subject is now of type List<Int>
    .toEqual(listOf(0, 1, 2))

fails {
    expect(0..2)
        .asList()  // subject is now of type List<Int>
        .toContain(3)  // fails
        .toContain(4)  // not evaluated/reported because above `toContain` already fails
    //                    use `.asList { ... }` if you want that all expectations are evaluated
}

fun <E, T : Iterable<E>> Expect<T>.asList(assertionCreator: Expect<List<E>>.() -> Unit): Expect<T>(source)

Expects that the subject of this expectation holds all assertions the given assertionCreator creates for the subject as List.

The transformation as such is not reflected in reporting. Use feature of({ f(it::toList) }, assertionCreator) if you want to show the transformation in reporting.

Return

an Expect for the subject of this expectation.

Since

0.14.0

Samples

expect(0..2)  // subject within this expectation-group is of type List<Int>
    .asList {
        toEqual(listOf(0, 1, 2))
    }  // subject here is back to type IntRange

fails {
    // all expectations inside an expectation-group are evaluated together; for more details see:
    // https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group

    expect(0..2)
        .asList {
            toContain(3)  // fails
            toContain(4)  // still evaluated even though above `toContain` already fails
            //               use `.asList().` if you want a fail fast behaviour
        }
}

Turns Expect<E, T : Sequence<E>> into Expect<List<E>.

The transformation as such is not reflected in reporting. Use feature { f(it::toList) } if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Since

0.14.0

Samples

expect(sequenceOf(1, 2, 3))
    .asList() // subject is now of type List<Int>
    .toEqual(listOf(1, 2, 3))

fun <E, T : Sequence<E>> Expect<T>.asList(assertionCreator: Expect<List<E>>.() -> Unit): Expect<T>(source)

Expects that the subject of this expectation holds all assertions the given assertionCreator creates for the subject as List.

The transformation as such is not reflected in reporting. Use feature of({ f(it::toList) }, assertionCreator) if you want to show the transformation in reporting.

Return

an Expect for the subject of this expectation.

Since

0.14.0

Samples

expect(sequenceOf(1, 2, 3))
    .asList { // subject within this expectation-group is of type List<Int>
        toEqual(listOf(1, 2, 3))
    } // subject here is back to type Sequence<Int>