-
-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADD: samples of iterableSubjectChangers in api-infix and api-fluent #1155
Merged
robstoll
merged 6 commits into
robstoll:main
from
simonNozaki:feature/add-iterableSubjectChangers-samples
Jun 18, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
75b9152
ADD: samples for iterableSubjectChangers in api-infix and api-fluent
simonNozaki d5a4ca4
MOD: rename sample files and add comments
simonNozaki 1ab92c5
MOD: rename method paths of @sample tag
simonNozaki cefaf85
MOD: align spaces
simonNozaki bb2cb9e
MOD: align spaces
simonNozaki a1e3fab
move the comment
simonNozaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
} | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move comment one line below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this.