Skip to content

Commit

Permalink
Merge pull request #1137 from robstoll/rename-assertion-to-expectation
Browse files Browse the repository at this point in the history
#746 rename assertion to expectation in README and samples
  • Loading branch information
robstoll authored May 4, 2022
2 parents adb8fa9 + 9bf42cf commit 812af7e
Show file tree
Hide file tree
Showing 71 changed files with 719 additions and 724 deletions.
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ By participating, you are expected to uphold this code. Please report unacceptab
- Missing a feature?
[Create a feature request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]).

- You would like to write an assertion function but you're having trouble starting?
- You would like to write an expectation function but you are having trouble starting?
Please read the section [Your First Code Contribution](#your-first-code-contribution).
If you still have trouble starting, then contact us on
[slack](https://kotlinlang.slack.com/messages/D3CL4DDLG/)
([Invite yourself](https://slack.kotlinlang.org/) in case you do not have an account yet)
and we will try to give you some additional hints.

- You do not have a particular assertion function in mind but would like to contribute with code?
- You do not have a particular expectation function in mind but would like to contribute with code?
Please have a look at the [help wanted issues](https://github.com/robstoll/atrium/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
-- ping us on
[Slack](https://kotlinlang.slack.com/messages/C887ZKGCQ)
Expand All @@ -54,7 +54,7 @@ By participating, you are expected to uphold this code. Please report unacceptab
- Found spelling mistakes?
Nice catch :mag: Please fix it and create a pull request.

- You wrote an assertion function and would like to contribute it to Atrium?
- You wrote an expectation function and would like to contribute it to Atrium?
Awesome :+1: please review the [pull request checklist](#pull-request-checklist) and create a pull request

- You would like to support the project financially?
Expand Down
572 changes: 286 additions & 286 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import ch.tutteli.atrium.logic.*
* Expects that the property [Map.Entry.key] of the subject of `this` expectation
* is equal to the given [key] and the property [Map.Entry.value] is equal to the given [value].
*
* Kind of a shortcut for `and { key { toEqual(key) }; value { toEqual(value) } }` where `and` denotes an
* expectation group block.
* Yet, the actual behaviour depends on implementation - could also be fail fast for instance or augment reporting etc.
* Shortcut for `and { key { toEqual(key) }; value { toEqual(value) } }` where `and` denotes an
* expectation-group.
*
* @return an [Expect] for the subject of `this` expectation.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun <T, R> Expect<T>.its(extractor: T.() -> R): FeatureExpect<T, R> =
/**
* Extracts a feature out of the current subject of `this` expectation with the help of the given [extractor],
* creates a new [Expect] for it,
* applies an assertion group based on the given [assertionCreator] for the feature and
* applies an expectation-group based on the given [assertionCreator] for the feature and
* returns the initial [Expect] with the current subject.
*
* @return an [Expect] for the subject of `this` expectation.
Expand Down Expand Up @@ -63,7 +63,7 @@ fun <T, R> Expect<T>.feature(property: KProperty1<in T, R>): FeatureExpect<T, R>
/**
* Extracts the [property] out of the current subject of `this` expectation,
* creates a new [Expect] for it,
* applies an assertion group based on the given [assertionCreator] for the feature and
* applies an expectation-group based on the given [assertionCreator] for the feature and
* returns the initial [Expect] with the current subject.
*
* @return an [Expect] for the subject of `this` expectation.
Expand Down Expand Up @@ -96,7 +96,7 @@ fun <T, R> Expect<T>.feature(f: KFunction1<T, R>): FeatureExpect<T, R> =
/**
* Extracts the value which is returned when calling [f] on the current subject of `this` expectation,
* creates a new [Expect] for it,
* applies an assertion group based on the given [assertionCreator] for the feature and
* applies an expectation-group based on the given [assertionCreator] for the feature and
* returns the initial [Expect] with the current subject.
*
* @return an [Expect] for the subject of `this` expectation.
Expand Down Expand Up @@ -133,7 +133,7 @@ fun <T, A1, R> Expect<T>.feature(
* Extracts the value which is returned when calling [f] with argument [a1]
* on the current subject of `this` expectation,
* creates a new [Expect] for it,
* applies an assertion group based on the given [assertionCreator] for the feature and
* applies an expectation-group based on the given [assertionCreator] for the feature and
* returns the initial [Expect] with the current subject.
*
* @return an [Expect] for the subject of `this` expectation.
Expand Down Expand Up @@ -171,7 +171,7 @@ fun <T, A1, A2, R> Expect<T>.feature(
* Extracts the value which is returned when calling [f] with argument [a1], [a2]
* on the current subject of `this` expectation,
* creates a new [Expect] for it,
* applies an assertion group based on the given [assertionCreator] for the feature and
* applies an expectation-group based on the given [assertionCreator] for the feature and
* returns the initial [Expect] with the current subject.
*
* @return an [Expect] for the subject of `this` expectation.
Expand Down Expand Up @@ -209,7 +209,7 @@ fun <T, A1, A2, A3, R> Expect<T>.feature(
* Extracts the value which is returned when calling [f] with argument [a1], [a2], [a3]
* on the current subject of `this` expectation,
* creates a new [Expect] for it,
* applies an assertion group based on the given [assertionCreator] for the feature and
* applies an expectation-group based on the given [assertionCreator] for the feature and
* returns the initial [Expect] with the current subject.
*
* @return an [Expect] for the subject of `this` expectation.
Expand Down Expand Up @@ -247,7 +247,7 @@ fun <T, A1, A2, A3, A4, R> Expect<T>.feature(
* Extracts the value which is returned when calling [f] with argument [a1], [a2], [a3], [a4]
* on the current subject of `this` expectation,
* creates a new [Expect] for it,
* applies an assertion group based on the given [assertionCreator] for the feature and
* applies an expectation-group based on the given [assertionCreator] for the feature and
* returns the initial [Expect] with the current subject.
*
* @return an [Expect] for the subject of `this` expectation.
Expand Down Expand Up @@ -284,7 +284,7 @@ fun <T, A1, A2, A3, A4, A5, R> Expect<T>.feature(
* Extracts the value which is returned when calling [f] with argument [a1], [a2], [a3], [a4], [a5]
* on the current subject of `this` expectation,
* creates a new [Expect] for it,
* applies an assertion group based on the given [assertionCreator] for the feature and
* applies an expectation-group based on the given [assertionCreator] for the feature and
* returns the initial [Expect] with the current subject.
*
* @return an [Expect] for the subject of `this` expectation.
Expand Down Expand Up @@ -322,7 +322,7 @@ fun <T, R> Expect<T>.feature(description: String, provider: T.() -> R): FeatureE
* Extracts a feature out of the current subject of `this` expectation
* based on the given [provider] and using the given [description],
* creates a new [Expect] for it,
* applies an assertion group based on the given [assertionCreator] for the feature and
* applies an expectation-group based on the given [assertionCreator] for the feature and
* returns the initial [Expect] with the current subject.
*
* @param provider Extracts the feature where the subject of `this` expectation is available via
Expand Down Expand Up @@ -364,7 +364,7 @@ fun <T, R> Expect<T>.feature(provider: MetaFeatureOption<T>.(T) -> MetaFeature<R
* Extracts a feature out of the current subject of `this` expectation,
* based on the given [provider],
* creates a new [Expect] for it,
* applies an assertion group based on the given [assertionCreator] for the feature and
* applies an expectation-group based on the given [assertionCreator] for the feature and
* returns the initial [Expect] with the current subject.
*
* @param provider You need to create a [MetaFeature] where the subject of `this` expectation is available via
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class AnyExpectationSamples {
expect<Int?>(1).toEqualNullIfNullGivenElse(null)
}

expect<Int?>(1).toEqualNullIfNullGivenElse { // subject inside this block is of type Int
expect<Int?>(1).toEqualNullIfNullGivenElse { // subject inside this expectation-group is of type Int
toBeLessThan(2)
} // subject here is back to type Int?

Expand Down Expand Up @@ -97,10 +97,10 @@ class AnyExpectationSamples {
.notToEqualNull { // subject is now of type Int
toBeGreaterThan(0)
toBeLessThan(10)
} // subject remains type Int also after the block
} // subject remains type Int also after the expectation-group
.toEqual(1)

fails { // because subject is null, but since we use a block...
fails { // because subject is null, but since we use an expectation-group...
expect<Int?>(null).notToEqualNull {
toBeGreaterThan(2) // ...reporting mentions that subject was expected `to be greater than: 2`
}
Expand All @@ -115,7 +115,7 @@ class AnyExpectationSamples {
}

fails {
// because you forgot to define an expectation in the expectation group block
// because you forgot to define an expectation in the expectation-group block
// use `.notToEqualNull()` if this is all you expect
expect<Int?>(1).notToEqualNull { }
}
Expand All @@ -142,10 +142,10 @@ class AnyExpectationSamples {
expect(n)
.toBeAnInstanceOf<Int> { // subject is now of type Int
toBeGreaterThanOrEqualTo(15)
} // subject remains type Int also after the block
} // subject remains type Int also after the expectation-group
.toBeLessThan(20)

fails { // because wrong type expected (Long instead of String), but since we use a block...
fails { // because wrong type expected (Long instead of String), but since we use an expectation-group...
expect("A").toBeAnInstanceOf<Long> {
toEqual(43) // ...reporting mentions that subject was expected `to equal: 43`
}
Expand All @@ -160,7 +160,7 @@ class AnyExpectationSamples {
}

fails {
// because you forgot to define an expectation in the expectation group block
// because you forgot to define an expectation in the expectation-group block
// use `.toBeAnInstanceOf<Int>()` if this is all you expect
expect<Number>(1).toBeAnInstanceOf<Int> { }
}
Expand Down Expand Up @@ -202,8 +202,8 @@ class AnyExpectationSamples {

fails {
expect(13).toBeAnInstanceOf<Int>().and {
// introduces an expectation group block
// all expectations are evaluated inside an expectation group block; for more details:
// introduces an expectation-group block where all expectations inside
// are evaluated together; for more details see:
// https://github.com/robstoll/atrium#define-single-expectations-or-expectation-groups
// use `.and.` if you want fail fast behaviour

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ class ArraySubjectChangerSamples {
@Test
fun asList() {
expect(arrayOf("A", "B"))
.asList { // subject within this block is of type List<String>
.asList { // subject within this expectation-group is of type List<String>
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
// 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(arrayOf("A", "B"))
.asList {
Expand All @@ -44,13 +44,13 @@ class ArraySubjectChangerSamples {
@Test
fun asListEOut() {
expect<Array<out String>>(arrayOf("A", "B"))
.asList { // subject within this block is of type List<String>
.asList { // subject within this expectation-group is of type List<String>
toEqual(listOf("A", "B"))
} // subject here is back to type Array<out 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
// 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<Array<out String>>(arrayOf("A", "B"))
.asList {
Expand All @@ -71,13 +71,13 @@ class ArraySubjectChangerSamples {
@Test
fun byteArrAsList() {
expect(byteArrayOf(1, 2, 3))
.asList { // subject within this block is of type List<Byte>
.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 assertions are evaluated inside an assertion group block; for more details:
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
// 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 {
Expand All @@ -98,13 +98,13 @@ class ArraySubjectChangerSamples {
@Test
fun charArrAsList() {
expect(charArrayOf('A', 'B', 'C'))
.asList { // subject within this block is of type List<Char>
.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 assertions are evaluated inside an assertion group block; for more details:
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
// 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 {
Expand All @@ -125,13 +125,13 @@ class ArraySubjectChangerSamples {
@Test
fun shortArrAsList() {
expect(shortArrayOf(1, 2, 3))
.asList { // subject within this block is of type List<Short>
.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 assertions are evaluated inside an assertion group block; for more details:
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
// 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 {
Expand All @@ -152,13 +152,13 @@ class ArraySubjectChangerSamples {
@Test
fun intArrAsList() {
expect(intArrayOf(1, 2, 3))
.asList { // subject within this block is of type List<Int>
.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 assertions are evaluated inside an assertion group block; for more details:
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
// 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 {
Expand All @@ -179,13 +179,13 @@ class ArraySubjectChangerSamples {
@Test
fun longArrAsList() {
expect(longArrayOf(1L, 2L, 3L))
.asList { // subject within this block is of type List<Long>
.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 assertions are evaluated inside an assertion group block; for more details:
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
// 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 {
Expand All @@ -206,13 +206,13 @@ class ArraySubjectChangerSamples {
@Test
fun floatArrAsList() {
expect(floatArrayOf(1f, 2f, 3f))
.asList { // subject within this block is of type List<Float>
.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 assertions are evaluated inside an assertion group block; for more details:
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
// 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 {
Expand All @@ -233,13 +233,13 @@ class ArraySubjectChangerSamples {
@Test
fun doubleArrAsList() {
expect(doubleArrayOf(1.1, 2.2, 3.3))
.asList { // subject within this block is of type List<Double>
.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 assertions are evaluated inside an assertion group block; for more details:
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
// 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 {
Expand All @@ -260,13 +260,13 @@ class ArraySubjectChangerSamples {
@Test
fun booleanArrAsList() {
expect(booleanArrayOf(true, false))
.asList { // subject within this block is of type List<Boolean>
.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 assertions are evaluated inside an assertion group block; for more details:
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
// 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 {
Expand Down
Loading

0 comments on commit 812af7e

Please sign in to comment.