doc / ch.tutteli.atrium.api.infix.en_GB / asList

asList

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

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

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

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

Return
The newly created Expect for the transformed subject.

Since
0.12.0

infix fun <E> Expect<Array<E>>.asList(assertionCreator: Expect<List<E>>.() -> Unit): Expect<Array<E>> (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::asList) }, assertionCreator) if you want to show the transformation in reporting.

expect(arrayOf("A", "B"))
    .asList { // subject within this block is of type List<String>
        it toEqual listOf("A", "B")
    } // subject here is back to type Array<String>

fails {
    // all assertions are evaluated inside an assertion group block; for more details:
    // https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
    expect(arrayOf("A", "B"))
        .asList {
            it contains "C"  // fails
            it contains "D"  // still evaluated even though `contains "C"` already fails
            //                  use `asList o` if you want a fail fast behaviour
        }
}

Return
The newly created Expect for the transformed subject.

Since
0.12.0

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

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

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

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

Return
The newly created Expect for the transformed subject.

Since
0.12.0

@JvmName("byteArrAsList") infix 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 of({ f(it::asList) }, assertionCreator) if you want to show the transformation in reporting.

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

fails {
    // all assertions are evaluated inside an assertion group block; for more details:
    // https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
    expect(byteArrayOf(1, 2, 3))
        .asList {
            it contains 98  // fails
            it contains 99  // still evaluated even though `contains 98` already fails
            //                 use `asList o` if you want a fail fast behaviour
        }
}

Return
The newly created Expect for the transformed subject.

Since
0.12.0

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

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

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

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

Return
The newly created Expect for the transformed subject.

Since
0.12.0

@JvmName("charArrAsList") infix 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 of({ f(it::asList) }, assertionCreator) if you want to show the transformation in reporting.

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

fails {
    // all assertions are evaluated inside an assertion group block; for more details:
    // https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
    expect(charArrayOf('A', 'B', 'C'))
        .asList {
            it contains 'X'  // fails
            it contains 'Y'  // still evaluated even though `contains 'X'` already fails
            //                  use `asList o` if you want a fail fast behaviour
        }
}

Return
The newly created Expect for the transformed subject.

Since
0.12.0

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

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

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

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

Return
The newly created Expect for the transformed subject.

Since
0.12.0

@JvmName("shortArrAsList") infix 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 of({ f(it::asList) }, assertionCreator) if you want to show the transformation in reporting.

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

fails {
    // all assertions are evaluated inside an assertion group block; for more details:
    // https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
    expect(shortArrayOf(1, 2, 3))
        .asList {
            it contains 98  // fails
            it contains 99  // still evaluated even though `contains 98` already fails
            //                 use `asList o` if you want a fail fast behaviour
        }
}

Return
The newly created Expect for the transformed subject.

Since
0.12.0

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

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

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

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

Return
The newly created Expect for the transformed subject.

Since
0.12.0

@JvmName("intArrAsList") infix 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 of({ f(it::asList) }, assertionCreator) if you want to show the transformation in reporting.

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

fails {
    // all assertions are evaluated inside an assertion group block; for more details:
    // https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
    expect(intArrayOf(1, 2, 3))
        .asList {
            it contains 98  // fails
            it contains 99  // still evaluated even though `contains 98` already fails
            //                 use `asList o` if you want a fail fast behaviour
        }
}

Return
The newly created Expect for the transformed subject.

Since
0.12.0

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

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

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

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

Return
The newly created Expect for the transformed subject.

Since
0.12.0

@JvmName("longArrAsList") infix 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 of({ f(it::asList) }, assertionCreator) if you want to show the transformation in reporting.

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

fails {
    // all assertions are evaluated inside an assertion group block; for more details:
    // https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
    expect(longArrayOf(1L, 2L, 3L))
        .asList {
            it contains 98L  // fails
            it contains 99L  // still evaluated even though `contains 98L` already fails
            //                  use `asList o` if you want a fail fast behaviour
        }
}

Return
The newly created Expect for the transformed subject.

Since
0.12.0

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

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

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

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

Return
The newly created Expect for the transformed subject.

Since
0.12.0

@JvmName("floatArrAsList") infix 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 of({ f(it::asList) }, assertionCreator) if you want to show the transformation in reporting.

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

fails {
    // all assertions are evaluated inside an assertion group block; for more details:
    // https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
    expect(floatArrayOf(1f, 2f, 3f))
        .asList {
            it contains 98f  // fails
            it contains 99f  // still evaluated even though `contains 98f` already fails
            //                  use `asList o` if you want a fail fast behaviour
        }
}

Return
The newly created Expect for the transformed subject.

Since
0.12.0

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

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

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

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

Return
The newly created Expect for the transformed subject.

Since
0.12.0

@JvmName("doubleArrAsList") infix 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 of({ f(it::asList) }, assertionCreator) if you want to show the transformation in reporting.

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

fails {
    // all assertions are evaluated inside an assertion group block; for more details:
    // https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
    expect(doubleArrayOf(1.1, 2.2, 3.3))
        .asList {
            it contains 98.1  // fails
            it contains 99.2  // still evaluated even though `contains 98.1` already fails
            //                   use `asList o` if you want a fail fast behaviour
        }
}

Return
The newly created Expect for the transformed subject.

Since
0.12.0

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

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

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

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

Return
The newly created Expect for the transformed subject.

Since
0.12.0

@JvmName("boolArrAsList") infix 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 of({ f(it::asList) }, assertionCreator) if you want to show the transformation in reporting.

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

fails {
    // all assertions are evaluated inside an assertion group block; for more details:
    // https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
    expect(booleanArrayOf(true, true))
        .asList {
            it contains false  //                              fails
            it contains o inAny order atLeast 3 value true  // still evaluated even though `contains false` already fails
            //                                                 use `asList o` if you want a fail fast behaviour
        }
}

Return
The newly created Expect for the transformed subject.

Since
0.12.0

infix fun <E, T : Iterable<E>> Expect<T>.asList(o: o): Expect<List<E>> (source)

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

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

Return
The newly created Expect for the transformed subject.

Since
0.14.0

infix 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::asList) }, assertionCreator) if you want to show the transformation in reporting.

Return
an Expect for the subject of this expectation.

Since
0.14.0