-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADD: samples of iterableSubjectChangers in api-infix and api-fluent (#…
…1155) * ADD: samples for iterableSubjectChangers in api-infix and api-fluent * MOD: rename sample files and add comments * MOD: rename method paths of @sample tag * MOD: align spaces * MOD: align spaces * move the comment
- Loading branch information
1 parent
d9a6fd3
commit 0797d3b
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...onTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/IterableSubjectChangerSamples.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package ch.tutteli.atrium.api.fluent.en_GB.samples | ||
|
||
import ch.tutteli.atrium.api.fluent.en_GB.asList | ||
import ch.tutteli.atrium.api.fluent.en_GB.toContain | ||
import ch.tutteli.atrium.api.fluent.en_GB.toEqual | ||
import ch.tutteli.atrium.api.verbs.internal.expect | ||
import kotlin.test.Test | ||
|
||
class IterableSubjectChangerSamples { | ||
@Test | ||
fun asListFeature() { | ||
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 | ||
} | ||
} | ||
|
||
@Test | ||
fun asList() { | ||
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 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...monTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/IterableSubjectChangerSamples.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package ch.tutteli.atrium.api.infix.en_GB.samples | ||
|
||
import ch.tutteli.atrium.api.infix.en_GB.asList | ||
import ch.tutteli.atrium.api.infix.en_GB.it | ||
import ch.tutteli.atrium.api.infix.en_GB.o | ||
import ch.tutteli.atrium.api.infix.en_GB.toContain | ||
import ch.tutteli.atrium.api.infix.en_GB.toEqual | ||
import ch.tutteli.atrium.api.verbs.internal.expect | ||
import kotlin.test.Test | ||
|
||
class IterableSubjectChangerSamples { | ||
@Test | ||
fun asListFeature() { | ||
expect(0..2) asList o toEqual listOf(0, 1, 2) | ||
// | subject is now of type List<Int> | ||
|
||
fails { | ||
expect(0..2) asList o toContain 3 toContain 4 | ||
} | ||
} | ||
|
||
@Test | ||
fun asList() { | ||
expect(0..2) | ||
.asList { // subject within this expectation-group is of type List<Int> | ||
it 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 { | ||
it toContain 3 // fails | ||
it toContain 4 // still evaluated even though above `toContain` already fails | ||
// use `asList o` if you want a fail fast behaviour | ||
} | ||
} | ||
} | ||
} |