mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
rename toHaveNext to toHaveElements
same same notToHaveNext as well as for toHaveNextAndAll/Any/None
This commit is contained in:
116
README.md
116
README.md
@@ -290,7 +290,7 @@ The next section shows how you can define multiple assertions for the same subje
|
||||
// two single assertions, only first evaluated
|
||||
expect(4 + 6).toBeLessThan(5).toBeGreaterThan(10)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L25)</sub> ↓ <sub>[Output](#ex-single)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L24)</sub> ↓ <sub>[Output](#ex-single)</sub>
|
||||
<a name="ex-single"></a>
|
||||
```text
|
||||
expected that subject: 10 (kotlin.Int <1234789>)
|
||||
@@ -327,7 +327,7 @@ expect(4 + 6) {
|
||||
toBeGreaterThan(10)
|
||||
}
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L41)</sub> ↓ <sub>[Output](#ex-group)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L40)</sub> ↓ <sub>[Output](#ex-group)</sub>
|
||||
<a name="ex-group"></a>
|
||||
```text
|
||||
expected that subject: 10 (kotlin.Int <1234789>)
|
||||
@@ -363,7 +363,7 @@ expect {
|
||||
throw IllegalArgumentException("name is empty")
|
||||
}.toThrow<IllegalStateException>()
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L65)</sub> ↓ <sub>[Output](#ex-toThrow1)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L64)</sub> ↓ <sub>[Output](#ex-toThrow1)</sub>
|
||||
<a name="ex-toThrow1"></a>
|
||||
```text
|
||||
expected that subject: () -> kotlin.Nothing (readme.examples.MostExamplesSpec$1$7$1 <1234789>)
|
||||
@@ -372,10 +372,10 @@ expected that subject: () -> kotlin.Nothing (readme.examples.MostExamples
|
||||
ℹ Properties of the unexpected IllegalArgumentException
|
||||
» message: "name is empty" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.MostExamplesSpec$1$7$1.invoke(MostExamplesSpec.kt:68)
|
||||
⚬ readme.examples.MostExamplesSpec$1$7$1.invoke(MostExamplesSpec.kt:23)
|
||||
⚬ readme.examples.MostExamplesSpec$1$7.invoke(MostExamplesSpec.kt:273)
|
||||
⚬ readme.examples.MostExamplesSpec$1$7.invoke(MostExamplesSpec.kt:23)
|
||||
⚬ readme.examples.MostExamplesSpec$1$7$1.invoke(MostExamplesSpec.kt:67)
|
||||
⚬ readme.examples.MostExamplesSpec$1$7$1.invoke(MostExamplesSpec.kt:22)
|
||||
⚬ readme.examples.MostExamplesSpec$1$7.invoke(MostExamplesSpec.kt:272)
|
||||
⚬ readme.examples.MostExamplesSpec$1$7.invoke(MostExamplesSpec.kt:22)
|
||||
```
|
||||
</ex-toThrow1>
|
||||
|
||||
@@ -399,7 +399,7 @@ expect {
|
||||
throw IllegalArgumentException()
|
||||
}.toThrow<IllegalArgumentException>().message.toStartWith("firstName")
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L72)</sub> ↓ <sub>[Output](#ex-toThrow2)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L71)</sub> ↓ <sub>[Output](#ex-toThrow2)</sub>
|
||||
<a name="ex-toThrow2"></a>
|
||||
```text
|
||||
expected that subject: () -> kotlin.Nothing (readme.examples.MostExamplesSpec$1$8$1 <1234789>)
|
||||
@@ -420,7 +420,7 @@ expect {
|
||||
message { toStartWith("firstName") }
|
||||
}
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L78)</sub> ↓ <sub>[Output](#ex-toThrow3)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L77)</sub> ↓ <sub>[Output](#ex-toThrow3)</sub>
|
||||
<a name="ex-toThrow3"></a>
|
||||
```text
|
||||
expected that subject: () -> kotlin.Nothing (readme.examples.MostExamplesSpec$1$9$1 <1234789>)
|
||||
@@ -444,7 +444,7 @@ expect {
|
||||
throw IllegalArgumentException("name is empty", RuntimeException("a cause"))
|
||||
}.notToThrow()
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L86)</sub> ↓ <sub>[Output](#ex-notToThrow)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L85)</sub> ↓ <sub>[Output](#ex-notToThrow)</sub>
|
||||
<a name="ex-notToThrow"></a>
|
||||
```text
|
||||
expected that subject: () -> kotlin.Nothing (readme.examples.MostExamplesSpec$1$10$1 <1234789>)
|
||||
@@ -452,14 +452,14 @@ expected that subject: () -> kotlin.Nothing (readme.examples.MostExamples
|
||||
ℹ Properties of the unexpected IllegalArgumentException
|
||||
» message: "name is empty" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.MostExamplesSpec$1$10$1.invoke(MostExamplesSpec.kt:89)
|
||||
⚬ readme.examples.MostExamplesSpec$1$10$1.invoke(MostExamplesSpec.kt:23)
|
||||
⚬ readme.examples.MostExamplesSpec$1$10.invoke(MostExamplesSpec.kt:90)
|
||||
⚬ readme.examples.MostExamplesSpec$1$10.invoke(MostExamplesSpec.kt:23)
|
||||
⚬ readme.examples.MostExamplesSpec$1$10$1.invoke(MostExamplesSpec.kt:88)
|
||||
⚬ readme.examples.MostExamplesSpec$1$10$1.invoke(MostExamplesSpec.kt:22)
|
||||
⚬ readme.examples.MostExamplesSpec$1$10.invoke(MostExamplesSpec.kt:89)
|
||||
⚬ readme.examples.MostExamplesSpec$1$10.invoke(MostExamplesSpec.kt:22)
|
||||
» cause: java.lang.RuntimeException
|
||||
» message: "a cause" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.MostExamplesSpec$1$10$1.invoke(MostExamplesSpec.kt:89)
|
||||
⚬ readme.examples.MostExamplesSpec$1$10$1.invoke(MostExamplesSpec.kt:88)
|
||||
```
|
||||
</ex-notToThrow>
|
||||
|
||||
@@ -851,7 +851,7 @@ expect(x).toBeAnInstanceOf<SubType1>()
|
||||
.feature { f(it::number) }
|
||||
.toEqual(2)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L93)</sub> ↓ <sub>[Output](#ex-type-assertions-1)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L92)</sub> ↓ <sub>[Output](#ex-type-assertions-1)</sub>
|
||||
<a name="ex-type-assertions-1"></a>
|
||||
```text
|
||||
expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>)
|
||||
@@ -873,7 +873,7 @@ expect(x).toBeAnInstanceOf<SubType2> {
|
||||
feature { f(it::flag) }.toEqual(false)
|
||||
}
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L99)</sub> ↓ <sub>[Output](#ex-type-assertions-2)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L98)</sub> ↓ <sub>[Output](#ex-type-assertions-2)</sub>
|
||||
<a name="ex-type-assertions-2"></a>
|
||||
```text
|
||||
expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>)
|
||||
@@ -902,7 +902,7 @@ Let us look at the case where the subject of the assertion has a [nullable type]
|
||||
val slogan1: String? = "postulating assertions made easy"
|
||||
expect(slogan1).toEqual(null)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L107)</sub> ↓ <sub>[Output](#ex-nullable-1)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L106)</sub> ↓ <sub>[Output](#ex-nullable-1)</sub>
|
||||
<a name="ex-nullable-1"></a>
|
||||
```text
|
||||
expected that subject: "postulating assertions made easy" <1234789>
|
||||
@@ -916,7 +916,7 @@ expected that subject: "postulating assertions made easy" <1234789>
|
||||
val slogan2: String? = null
|
||||
expect(slogan2).toEqual("postulating assertions made easy")
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L111)</sub> ↓ <sub>[Output](#ex-nullable-2)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L110)</sub> ↓ <sub>[Output](#ex-nullable-2)</sub>
|
||||
<a name="ex-nullable-2"></a>
|
||||
```text
|
||||
expected that subject: null
|
||||
@@ -937,7 +937,7 @@ expect(slogan2) // subject has type String?
|
||||
.notToEqualNull() // subject is narrowed to String
|
||||
.toStartWith("atrium")
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L116)</sub> ↓ <sub>[Output](#ex-nullable-3)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L115)</sub> ↓ <sub>[Output](#ex-nullable-3)</sub>
|
||||
<a name="ex-nullable-3"></a>
|
||||
```text
|
||||
expected that subject: null
|
||||
@@ -954,7 +954,7 @@ one without (example above) and one with `assertionCreator`-lambda (example belo
|
||||
```kotlin
|
||||
expect(slogan2).notToEqualNull { toStartWith("atrium") }
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L121)</sub> ↓ <sub>[Output](#ex-nullable-4)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L120)</sub> ↓ <sub>[Output](#ex-nullable-4)</sub>
|
||||
<a name="ex-nullable-4"></a>
|
||||
```text
|
||||
expected that subject: null
|
||||
@@ -993,7 +993,7 @@ The following sub sections show both use cases by examples.
|
||||
```kotlin
|
||||
expect(listOf(1, 2, 2, 4)).toContain(2, 3)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L125)</sub> ↓ <sub>[Output](#ex-collection-short-1)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L124)</sub> ↓ <sub>[Output](#ex-collection-short-1)</sub>
|
||||
<a name="ex-collection-short-1"></a>
|
||||
```text
|
||||
expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>)
|
||||
@@ -1032,7 +1032,7 @@ expect(listOf(1, 2, 2, 4)).toContain(
|
||||
{ toBeGreaterThan(2).toBeLessThan(4) }
|
||||
)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L129)</sub> ↓ <sub>[Output](#ex-collection-short-2)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L128)</sub> ↓ <sub>[Output](#ex-collection-short-2)</sub>
|
||||
<a name="ex-collection-short-2"></a>
|
||||
```text
|
||||
expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>)
|
||||
@@ -1074,11 +1074,11 @@ Following each in action:
|
||||
<ex-collection-any>
|
||||
|
||||
```kotlin
|
||||
expect(listOf(1, 2, 3, 4)).toHaveNextAndAny {
|
||||
expect(listOf(1, 2, 3, 4)).toHaveElementsAndAny {
|
||||
toBeLessThan(0)
|
||||
}
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L136)</sub> ↓ <sub>[Output](#ex-collection-any)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L135)</sub> ↓ <sub>[Output](#ex-collection-any)</sub>
|
||||
<a name="ex-collection-any"></a>
|
||||
```text
|
||||
expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>)
|
||||
@@ -1093,11 +1093,11 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>
|
||||
<ex-collection-none>
|
||||
|
||||
```kotlin
|
||||
expect(listOf(1, 2, 3, 4)).toHaveNextAndNone {
|
||||
expect(listOf(1, 2, 3, 4)).toHaveElementsAndNone {
|
||||
toBeGreaterThan(2)
|
||||
}
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L141)</sub> ↓ <sub>[Output](#ex-collection-none)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L140)</sub> ↓ <sub>[Output](#ex-collection-none)</sub>
|
||||
<a name="ex-collection-none"></a>
|
||||
```text
|
||||
expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>)
|
||||
@@ -1114,11 +1114,11 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>
|
||||
<ex-collection-all>
|
||||
|
||||
```kotlin
|
||||
expect(listOf(1, 2, 3, 4)).toHaveNextAndAll {
|
||||
expect(listOf(1, 2, 3, 4)).toHaveElementsAndAll {
|
||||
toBeGreaterThan(2)
|
||||
}
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L146)</sub> ↓ <sub>[Output](#ex-collection-all)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L145)</sub> ↓ <sub>[Output](#ex-collection-all)</sub>
|
||||
<a name="ex-collection-all"></a>
|
||||
```text
|
||||
expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>)
|
||||
@@ -1148,7 +1148,7 @@ Following on the last section we will start with an `inOrder` example:
|
||||
```kotlin
|
||||
expect(listOf(1, 2, 2, 4)).toContain.inOrder.only.entries({ toBeLessThan(3) }, { toBeLessThan(2) })
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L152)</sub> ↓ <sub>[Output](#ex-collection-builder-1)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L151)</sub> ↓ <sub>[Output](#ex-collection-builder-1)</sub>
|
||||
<a name="ex-collection-builder-1"></a>
|
||||
```text
|
||||
expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>)
|
||||
@@ -1196,7 +1196,7 @@ and we happily answer your question there.
|
||||
```kotlin
|
||||
expect(listOf(1, 2, 2, 4)).toContain.inOrder.only.values(1, 2, 2, 3, 4)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L155)</sub> ↓ <sub>[Output](#ex-collection-builder-2)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L154)</sub> ↓ <sub>[Output](#ex-collection-builder-2)</sub>
|
||||
<a name="ex-collection-builder-2"></a>
|
||||
```text
|
||||
expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>)
|
||||
@@ -1221,7 +1221,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>
|
||||
```kotlin
|
||||
expect(listOf(1, 2, 2, 4)).toContain.inAnyOrder.atLeast(1).butAtMost(2).entries({ toBeLessThan(3) })
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L158)</sub> ↓ <sub>[Output](#ex-collection-builder-3)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L157)</sub> ↓ <sub>[Output](#ex-collection-builder-3)</sub>
|
||||
<a name="ex-collection-builder-3"></a>
|
||||
```text
|
||||
expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>)
|
||||
@@ -1238,7 +1238,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>
|
||||
```kotlin
|
||||
expect(listOf(1, 2, 2, 4)).toContain.inAnyOrder.only.values(1, 2, 3, 4)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L161)</sub> ↓ <sub>[Output](#ex-collection-builder-4)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L160)</sub> ↓ <sub>[Output](#ex-collection-builder-4)</sub>
|
||||
<a name="ex-collection-builder-4"></a>
|
||||
```text
|
||||
expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>)
|
||||
@@ -1257,7 +1257,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>
|
||||
```kotlin
|
||||
expect(listOf(1, 2, 2, 4)).toContain.inAnyOrder.only.values(4, 3, 2, 2, 1)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L164)</sub> ↓ <sub>[Output](#ex-collection-builder-5)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L163)</sub> ↓ <sub>[Output](#ex-collection-builder-5)</sub>
|
||||
<a name="ex-collection-builder-5"></a>
|
||||
```text
|
||||
expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>)
|
||||
@@ -1287,7 +1287,7 @@ and more [Sophisticated Assertion Builder](#sophisticated-assertion-builders-1)
|
||||
```kotlin
|
||||
expect(mapOf("a" to 1, "b" to 2)).contains("c" to 2, "a" to 1, "b" to 1)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L168)</sub> ↓ <sub>[Output](#ex-map-1)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L167)</sub> ↓ <sub>[Output](#ex-map-1)</sub>
|
||||
<a name="ex-map-1"></a>
|
||||
```text
|
||||
expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>)
|
||||
@@ -1311,7 +1311,7 @@ expect(mapOf("a" to 1, "b" to 2)).contains(
|
||||
KeyValue("b") { toBeLessThan(2) }
|
||||
)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L171)</sub> ↓ <sub>[Output](#ex-map-2)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L170)</sub> ↓ <sub>[Output](#ex-map-2)</sub>
|
||||
<a name="ex-map-2"></a>
|
||||
```text
|
||||
expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>)
|
||||
@@ -1333,7 +1333,7 @@ Again both overloads are provided, one for key-value `Pair`s:
|
||||
```kotlin
|
||||
expect(mapOf("a" to 1, "b" to 2)).containsOnly("b" to 2)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L179)</sub> ↓ <sub>[Output](#ex-map-only-1)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L178)</sub> ↓ <sub>[Output](#ex-map-only-1)</sub>
|
||||
<a name="ex-map-only-1"></a>
|
||||
```text
|
||||
expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>)
|
||||
@@ -1358,7 +1358,7 @@ expect(mapOf("a" to 1, "b" to 2)).containsOnly(
|
||||
KeyValue("b") { toBeLessThan(2) }
|
||||
)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L182)</sub> ↓ <sub>[Output](#ex-map-only-2)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L181)</sub> ↓ <sub>[Output](#ex-map-only-2)</sub>
|
||||
<a name="ex-map-only-2"></a>
|
||||
```text
|
||||
expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>)
|
||||
@@ -1386,7 +1386,7 @@ again provide two overloads, one expecting key-value `Pair`s:
|
||||
```kotlin
|
||||
expect(mapOf("a" to 1, "b" to 2)).contains.inOrder.only.entries("b" to 2, "a" to 1)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L190)</sub> ↓ <sub>[Output](#ex-map-builder-1)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L189)</sub> ↓ <sub>[Output](#ex-map-builder-1)</sub>
|
||||
<a name="ex-map-builder-1"></a>
|
||||
```text
|
||||
expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>)
|
||||
@@ -1413,7 +1413,7 @@ expect(mapOf("a" to 1, "b" to 2)).contains.inOrder.only.entries(
|
||||
KeyValue("a") { toBeLessThan(2) },
|
||||
KeyValue("b") { toBeLessThan(2) })
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L193)</sub> ↓ <sub>[Output](#ex-map-builder-2)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L192)</sub> ↓ <sub>[Output](#ex-map-builder-2)</sub>
|
||||
<a name="ex-map-builder-2"></a>
|
||||
```text
|
||||
expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>)
|
||||
@@ -1450,7 +1450,7 @@ expect(mapOf("bernstein" to bernstein))
|
||||
feature { f(it::firstName) }.toEqual("Albert")
|
||||
}
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L203)</sub> ↓ <sub>[Output](#ex-map-3)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L202)</sub> ↓ <sub>[Output](#ex-map-3)</sub>
|
||||
<a name="ex-map-3"></a>
|
||||
```text
|
||||
expected that subject: {bernstein=Person(firstName=Leonard, lastName=Bernstein, age=50)} (java.util.Collections.SingletonMap <1234789>)
|
||||
@@ -1466,11 +1466,11 @@ In case you want to make an assertion only about the keys or values of the `Map`
|
||||
|
||||
```kotlin
|
||||
expect(mapOf("a" to 1, "b" to 2)) {
|
||||
keys { toHaveNextAndAll { toStartWith("a") } }
|
||||
values { toHaveNextAndNone { toBeGreaterThan(1) } }
|
||||
keys { toHaveElementsAndAll { toStartWith("a") } }
|
||||
values { toHaveElementsAndNone { toBeGreaterThan(1) } }
|
||||
}
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L215)</sub> ↓ <sub>[Output](#ex-map-4)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L214)</sub> ↓ <sub>[Output](#ex-map-4)</sub>
|
||||
<a name="ex-map-4"></a>
|
||||
```text
|
||||
expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>)
|
||||
@@ -1508,7 +1508,7 @@ expect(linkedMapOf("a" to 1, "b" to 2)).asEntries().toContain.inOrder.only.entri
|
||||
}
|
||||
)
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L221)</sub> ↓ <sub>[Output](#ex-map-5)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L220)</sub> ↓ <sub>[Output](#ex-map-5)</sub>
|
||||
<a name="ex-map-5"></a>
|
||||
```text
|
||||
expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>)
|
||||
@@ -1604,7 +1604,7 @@ expect("filename?")
|
||||
notToContain("?")
|
||||
}
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L231)</sub> ↓ <sub>[Output](#ex-because-1)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L230)</sub> ↓ <sub>[Output](#ex-because-1)</sub>
|
||||
<a name="ex-because-1"></a>
|
||||
```text
|
||||
expected that subject: "filename?" <1234789>
|
||||
@@ -1881,7 +1881,7 @@ expect {
|
||||
}
|
||||
}.toThrow<IllegalStateException> { messageContains("no no no") }
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L244)</sub> ↓ <sub>[Output](#ex-add-info-3)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L243)</sub> ↓ <sub>[Output](#ex-add-info-3)</sub>
|
||||
<a name="ex-add-info-3"></a>
|
||||
```text
|
||||
expected that subject: () -> kotlin.Nothing (readme.examples.MostExamplesSpec$1$39$1 <1234789>)
|
||||
@@ -1896,14 +1896,14 @@ expected that subject: () -> kotlin.Nothing (readme.examples.MostExamples
|
||||
ℹ Properties of the unexpected IllegalArgumentException
|
||||
» message: "no no no..." <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.MostExamplesSpec$1$39$1.invoke(MostExamplesSpec.kt:249)
|
||||
⚬ readme.examples.MostExamplesSpec$1$39$1.invoke(MostExamplesSpec.kt:23)
|
||||
⚬ readme.examples.MostExamplesSpec$1$39.invoke(MostExamplesSpec.kt:273)
|
||||
⚬ readme.examples.MostExamplesSpec$1$39.invoke(MostExamplesSpec.kt:23)
|
||||
⚬ readme.examples.MostExamplesSpec$1$39$1.invoke(MostExamplesSpec.kt:248)
|
||||
⚬ readme.examples.MostExamplesSpec$1$39$1.invoke(MostExamplesSpec.kt:22)
|
||||
⚬ readme.examples.MostExamplesSpec$1$39.invoke(MostExamplesSpec.kt:272)
|
||||
⚬ readme.examples.MostExamplesSpec$1$39.invoke(MostExamplesSpec.kt:22)
|
||||
» cause: java.lang.UnsupportedOperationException
|
||||
» message: "not supported" <1234789>
|
||||
» stacktrace:
|
||||
⚬ readme.examples.MostExamplesSpec$1$39$1.invoke(MostExamplesSpec.kt:247)
|
||||
⚬ readme.examples.MostExamplesSpec$1$39$1.invoke(MostExamplesSpec.kt:246)
|
||||
```
|
||||
</ex-add-info-3>
|
||||
|
||||
@@ -1924,7 +1924,7 @@ then Atrium reminds us of the possible pitfall. For instance:
|
||||
```kotlin
|
||||
expect(BigDecimal.TEN).isEqualIncludingScale(BigDecimal("10.0"))
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L254)</sub> ↓ <sub>[Output](#ex-pitfall-1)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L253)</sub> ↓ <sub>[Output](#ex-pitfall-1)</sub>
|
||||
<a name="ex-pitfall-1"></a>
|
||||
```text
|
||||
expected that subject: 10 (java.math.BigDecimal <1234789>)
|
||||
@@ -1942,7 +1942,7 @@ For instance:
|
||||
```kotlin
|
||||
expect(listOf(1)).get(0) {}
|
||||
```
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L257)</sub> ↓ <sub>[Output](#ex-pitfall-2)</sub>
|
||||
↑ <sub>[Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L256)</sub> ↓ <sub>[Output](#ex-pitfall-2)</sub>
|
||||
<a name="ex-pitfall-2"></a>
|
||||
```text
|
||||
expected that subject: [1] (java.util.Collections.SingletonList <1234789>)
|
||||
@@ -2191,7 +2191,7 @@ Another example: assert the person has children which are all adults (assuming 1
|
||||
```kotlin
|
||||
fun Expect<Person>.hasAdultChildren(): Expect<Person> =
|
||||
feature(Person::children) {
|
||||
toHaveNextAndAll {
|
||||
toHaveElementsAndAll {
|
||||
feature(Person::age).toBeGreaterThanOrEqualTo(18)
|
||||
}
|
||||
}
|
||||
@@ -2241,17 +2241,17 @@ With this, we can write things like:
|
||||
```kotlin
|
||||
expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, listOf()))))
|
||||
.children { // using the fun -> assertion group, ergo sub-assertions don't fail fast
|
||||
toHaveNextAndNone {
|
||||
toHaveElementsAndNone {
|
||||
feature { f(it::firstName) }.toStartWith("Ro")
|
||||
}
|
||||
toHaveNextAndAll {
|
||||
toHaveElementsAndAll {
|
||||
feature { f(it::lastName) }.toEqual("Whitley")
|
||||
}
|
||||
} // subject is still Person here
|
||||
.apply { // only evaluated because the previous assertion group holds
|
||||
children // using the val -> subsequent assertions are about children and fail fast
|
||||
.toHaveSize(2)
|
||||
.toHaveNextAndAny {
|
||||
.toHaveElementsAndAny {
|
||||
feature { f(it::age) }.toBeGreaterThan(18)
|
||||
}
|
||||
} // subject is still Person here due to the `apply`
|
||||
|
||||
@@ -299,8 +299,8 @@ fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.max(assertionCreator: Expect<
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use toHaveNextAndAny; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveNextAndAny<E, T>(assertionCreatorOrNull)")
|
||||
"Use toHaveElementsAndAny; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveElementsAndAny<E, T>(assertionCreatorOrNull)")
|
||||
)
|
||||
fun <E : Any, T : Iterable<E?>> Expect<T>.any(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
toContain.inAnyOrder.atLeast(1).entry(assertionCreatorOrNull)
|
||||
@@ -315,8 +315,8 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.any(assertionCreatorOrNull: (Expect<E>
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use toHaveNextAndNone; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveNextAndNone<E, T>(assertionCreatorOrNull)")
|
||||
"Use toHaveElementsAndNone; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveElementsAndNone<E, T>(assertionCreatorOrNull)")
|
||||
)
|
||||
fun <E : Any, T : Iterable<E?>> Expect<T>.none(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
notToContain.entry(assertionCreatorOrNull)
|
||||
@@ -329,8 +329,8 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.none(assertionCreatorOrNull: (Expect<E
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use toHaveNextAndAll; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveNextAndAll<E, T>(assertionCreatorOrNull)")
|
||||
"Use toHaveElementsAndAll; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveElementsAndAll<E, T>(assertionCreatorOrNull)")
|
||||
)
|
||||
fun <E : Any, T : Iterable<E?>> Expect<T>.all(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
_logicAppend { all(::identity, assertionCreatorOrNull) }
|
||||
@@ -344,8 +344,8 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.all(assertionCreatorOrNull: (Expect<E>
|
||||
* @since 0.9.0
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use toHaveNext; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveNext<E, T>()")
|
||||
"Use toHaveElements; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveElements<E, T>()")
|
||||
)
|
||||
fun <E, T : Iterable<E>> Expect<T>.hasNext(): Expect<T> =
|
||||
_logicAppend { hasNext(::identity) }
|
||||
@@ -358,8 +358,8 @@ fun <E, T : Iterable<E>> Expect<T>.hasNext(): Expect<T> =
|
||||
* @since 0.9.0
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use notToHaveNext; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.notToHaveNext<E, T>()")
|
||||
"Use notToHaveElements; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.notToHaveElements<E, T>()")
|
||||
)
|
||||
fun <E, T : Iterable<E>> Expect<T>.hasNotNext(): Expect<T> =
|
||||
_logicAppend { hasNotNext(::identity) }
|
||||
|
||||
@@ -223,7 +223,7 @@ fun <E, T : Iterable<E>> Expect<T>.notToContain(expected: E, vararg otherExpecte
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndAny(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveElementsAndAny(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
toContain.inAnyOrder.atLeast(1).entry(assertionCreatorOrNull)
|
||||
|
||||
/**
|
||||
@@ -237,7 +237,7 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndAny(assertionCreatorOrNul
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndNone(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveElementsAndNone(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
notToContain.entry(assertionCreatorOrNull)
|
||||
|
||||
/**
|
||||
@@ -249,7 +249,7 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndNone(assertionCreatorOrNu
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndAll(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveElementsAndAll(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
_logicAppend { all(::identity, assertionCreatorOrNull) }
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndAll(assertionCreatorOrNul
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <E, T : Iterable<E>> Expect<T>.toHaveNext(): Expect<T> =
|
||||
fun <E, T : Iterable<E>> Expect<T>.toHaveElements(): Expect<T> =
|
||||
_logicAppend { hasNext(::identity) }
|
||||
|
||||
/**
|
||||
@@ -270,7 +270,7 @@ fun <E, T : Iterable<E>> Expect<T>.toHaveNext(): Expect<T> =
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <E, T : Iterable<E>> Expect<T>.notToHaveNext(): Expect<T> =
|
||||
fun <E, T : Iterable<E>> Expect<T>.notToHaveElements(): Expect<T> =
|
||||
_logicAppend { hasNotNext(::identity) }
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,8 +4,8 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
|
||||
object IterableExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableExpectationsSpec(
|
||||
fun0(Expect<Iterable<Int>>::toHaveNext),
|
||||
fun0(Expect<Iterable<Int>>::notToHaveNext),
|
||||
fun0(Expect<Iterable<Int>>::toHaveElements),
|
||||
fun0(Expect<Iterable<Int>>::notToHaveElements),
|
||||
feature0<Iterable<Int>, Int>(Expect<Iterable<Int>>::min),
|
||||
fun1<Iterable<Int>, Expect<Int>.() -> Unit>(Expect<Iterable<Int>>::min),
|
||||
feature0<Iterable<Int>, Int>(Expect<Iterable<Int>>::max),
|
||||
@@ -19,16 +19,16 @@ object IterableExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableEx
|
||||
var a1b: Expect<Set<Double?>> = notImplemented()
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1.toHaveNext()
|
||||
a1 = a1.notToHaveNext()
|
||||
a1 = a1.toHaveElements()
|
||||
a1 = a1.notToHaveElements()
|
||||
a1 = a1.notToContainDuplicates()
|
||||
|
||||
a1b = a1b.toHaveNext()
|
||||
a1b = a1b.notToHaveNext()
|
||||
a1b = a1b.toHaveElements()
|
||||
a1b = a1b.notToHaveElements()
|
||||
a1b = a1b.notToContainDuplicates()
|
||||
|
||||
star = star.toHaveNext()
|
||||
star = star.notToHaveNext()
|
||||
star = star.toHaveElements()
|
||||
star = star.notToHaveElements()
|
||||
star = star.notToContainDuplicates()
|
||||
|
||||
//nullable not supported by min/max or rather T : Comparable<T> does not exist for T? (one cannot implement an interface for the nullable type)
|
||||
|
||||
@@ -5,9 +5,9 @@ import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
|
||||
object IterableToHaveNextAndAllExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAllExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndAll),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndAll).withNullableSuffix()
|
||||
object IterableToHaveElementsAndAllExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndAllExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveElementsAndAll),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveElementsAndAll).withNullableSuffix()
|
||||
) {
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ object IterableToHaveNextAndAllExpectationsSpec : ch.tutteli.atrium.specs.integr
|
||||
var subList: Expect<ArrayList<out Number>> = notImplemented()
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
list = list.toHaveNextAndAll {}
|
||||
nList = nList.toHaveNextAndAll {}
|
||||
subList = subList.toHaveNextAndAll {}
|
||||
star = star.toHaveNextAndAll {}
|
||||
list = list.toHaveElementsAndAll {}
|
||||
nList = nList.toHaveElementsAndAll {}
|
||||
subList = subList.toHaveElementsAndAll {}
|
||||
star = star.toHaveElementsAndAll {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,21 +7,21 @@ import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.IterableToHaveNextAndAnyExpectationsSpec.Companion as C
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.IterableToHaveElementsAndAnyExpectationsSpec.Companion as C
|
||||
|
||||
class IterableToHaveNextAndAnyExpectationsSpec : Spek({
|
||||
class IterableToHaveElementsAndAnyExpectationsSpec : Spek({
|
||||
include(PredicateSpec)
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
include(SequenceSpec)
|
||||
}) {
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndAny),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndAny).withNullableSuffix(),
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndAnyExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveElementsAndAny),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveElementsAndAny).withNullableSuffix(),
|
||||
"[Atrium][Predicate] "
|
||||
)
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndAnyExpectationsSpec(
|
||||
functionDescription to C::toContainEntry,
|
||||
(functionDescription to C::toContainNullableEntry).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
@@ -29,14 +29,14 @@ class IterableToHaveNextAndAnyExpectationsSpec : Spek({
|
||||
|
||||
// TODO 0.19.0 #722 this will differ once we don't implement the same behaviour for toContain and none
|
||||
// that's fine and we can simply remove this test here
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndAnyExpectationsSpec(
|
||||
shortcutDescription to C::toContainEntryShortcut,
|
||||
(shortcutDescription to C::toContainNullableEntryShortcut).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
// TODO move to own SequenceSpec if we really need this (maybe we can also just delete it?)
|
||||
object SequenceSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
object SequenceSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndAnyExpectationsSpec(
|
||||
getToContainSequencePair(),
|
||||
getToContainNullableSequencePair().withNullableSuffix(),
|
||||
"[Atrium][Sequence] "
|
||||
@@ -87,9 +87,9 @@ class IterableToHaveNextAndAnyExpectationsSpec : Spek({
|
||||
var subList: Expect<ArrayList<out Number>> = notImplemented()
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
list = list.toHaveNextAndAny {}
|
||||
nList = nList.toHaveNextAndAny {}
|
||||
subList = subList.toHaveNextAndAny {}
|
||||
star = star.toHaveNextAndAny {}
|
||||
list = list.toHaveElementsAndAny {}
|
||||
nList = nList.toHaveElementsAndAny {}
|
||||
subList = subList.toHaveElementsAndAny {}
|
||||
star = star.toHaveElementsAndAny {}
|
||||
}
|
||||
}
|
||||
@@ -5,21 +5,21 @@ import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.IterableToHaveNextAndNoneExpectationsSpec.Companion as C
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.IterableToHaveElementsAndNoneExpectationsSpec.Companion as C
|
||||
|
||||
class IterableToHaveNextAndNoneExpectationsSpec : Spek({
|
||||
class IterableToHaveElementsAndNoneExpectationsSpec : Spek({
|
||||
include(PredicateSpec)
|
||||
include(BuilderSpec)
|
||||
}) {
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndNoneExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndNone),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndNone).withNullableSuffix(),
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndNoneExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveElementsAndNone),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveElementsAndNone).withNullableSuffix(),
|
||||
"[Atrium][Predicate] "
|
||||
)
|
||||
|
||||
// TODO 0.19.0 #722 this will differ once we don't implement the same behaviour for contains and none
|
||||
// that's fine and we can simply remove this test here
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndNoneExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndNoneExpectationsSpec(
|
||||
functionDescription to C::notToContainFun,
|
||||
(functionDescription to C::notToContainNullableFun).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
@@ -42,9 +42,9 @@ class IterableToHaveNextAndNoneExpectationsSpec : Spek({
|
||||
var subList: Expect<ArrayList<out Number>> = notImplemented()
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
list = list.toHaveNextAndNone {}
|
||||
nList = nList.toHaveNextAndNone {}
|
||||
subList = subList.toHaveNextAndNone {}
|
||||
star = star.toHaveNextAndNone {}
|
||||
list = list.toHaveElementsAndNone {}
|
||||
nList = nList.toHaveElementsAndNone {}
|
||||
subList = subList.toHaveElementsAndNone {}
|
||||
star = star.toHaveElementsAndNone {}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package ch.tutteli.atrium.api.fluent.en_GB.samples
|
||||
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.*
|
||||
import ch.tutteli.atrium.api.verbs.internal.expect
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import kotlin.test.Test
|
||||
|
||||
class AnyExpectationSamples {
|
||||
@@ -211,7 +210,7 @@ class AnyExpectationSamples {
|
||||
notToContain("?")
|
||||
}
|
||||
|
||||
expect(customers).toHaveNextAndAll {
|
||||
expect(customers).toHaveElementsAndAll {
|
||||
because("the legal age of maturity in Switzerland is 18") {
|
||||
feature { f(it::age) }.toBeGreaterThanOrEqualTo(18)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ package ch.tutteli.atrium.api.fluent.en_GB.samples.deprecated
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.*
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.samples.fails
|
||||
import ch.tutteli.atrium.api.verbs.internal.expect
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import kotlin.test.Test
|
||||
|
||||
class AnyAssertionSamples {
|
||||
@@ -217,7 +216,7 @@ class AnyAssertionSamples {
|
||||
containsNot("?")
|
||||
}
|
||||
|
||||
expect(customers).toHaveNextAndAll {
|
||||
expect(customers).toHaveElementsAndAll {
|
||||
because("the legal age of maturity in Switzerland is 18") {
|
||||
feature { f(it::age) }.isGreaterThanOrEqual(18)
|
||||
}
|
||||
|
||||
@@ -345,8 +345,8 @@ infix fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.max(assertionCreator: E
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use toHaveNextAndAny; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveNextAndAny<E, T>(assertionCreatorOrNull)")
|
||||
"Use toHaveElementsAndAny; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveElementsAndAny<E, T>(assertionCreatorOrNull)")
|
||||
)
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.any(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
it toContain o inAny order atLeast 1 entry assertionCreatorOrNull
|
||||
@@ -362,8 +362,8 @@ infix fun <E : Any, T : Iterable<E?>> Expect<T>.any(assertionCreatorOrNull: (Exp
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use toHaveNextAndNone; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveNextAndNone<E, T>(assertionCreatorOrNull)")
|
||||
"Use toHaveElementsAndNone; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveElementsAndNone<E, T>(assertionCreatorOrNull)")
|
||||
)
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.none(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
it notToContain o entry assertionCreatorOrNull
|
||||
@@ -376,8 +376,8 @@ infix fun <E : Any, T : Iterable<E?>> Expect<T>.none(assertionCreatorOrNull: (Ex
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use toHaveNextAndAll; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveNextAndAll<E, T>(assertionCreatorOrNull)")
|
||||
"Use toHaveElementsAndAll; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveElementsAndAll<E, T>(assertionCreatorOrNull)")
|
||||
)
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.all(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
_logicAppend { all(::identity, assertionCreatorOrNull) }
|
||||
@@ -392,7 +392,7 @@ infix fun <E : Any, T : Iterable<E?>> Expect<T>.all(assertionCreatorOrNull: (Exp
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use toHaveNext; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toHaveNext<E, T>()")
|
||||
ReplaceWith("this.toHaveNext<E, T>(elements)", "ch.tutteli.atrium.api.infix.en_GB.elements")
|
||||
)
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.has(@Suppress("UNUSED_PARAMETER") next: next): Expect<T> =
|
||||
_logicAppend { hasNext(::identity) }
|
||||
@@ -406,7 +406,7 @@ infix fun <E, T : Iterable<E>> Expect<T>.has(@Suppress("UNUSED_PARAMETER") next:
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use notToHaveNext; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.notToHaveNext<E, T>()")
|
||||
ReplaceWith("this.notToHaveNext<E, T>(elements)", "ch.tutteli.atrium.api.infix.en_GB.elements")
|
||||
)
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.hasNot(@Suppress("UNUSED_PARAMETER") next: next): Expect<T> =
|
||||
_logicAppend { hasNotNext(::identity) }
|
||||
|
||||
@@ -271,7 +271,7 @@ infix fun <E, T : Iterable<E>> Expect<T>.notToContain(values: Values<E>): Expect
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndAny(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveElementsAndAny(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
it toContain o inAny order atLeast 1 entry assertionCreatorOrNull
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndAny(assertionCreato
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndNone(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveElementsAndNone(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
it notToContain o entry assertionCreatorOrNull
|
||||
|
||||
/**
|
||||
@@ -298,7 +298,7 @@ infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndNone(assertionCreat
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndAll(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveElementsAndAll(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
_logicAppend { all(::identity, assertionCreatorOrNull) }
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndAll(assertionCreato
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.toHave(@Suppress("UNUSED_PARAMETER") next: next): Expect<T> =
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.toHave(@Suppress("UNUSED_PARAMETER") elements: elements): Expect<T> =
|
||||
_logicAppend { hasNext(::identity) }
|
||||
|
||||
/**
|
||||
@@ -319,7 +319,7 @@ infix fun <E, T : Iterable<E>> Expect<T>.toHave(@Suppress("UNUSED_PARAMETER") ne
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.notToHave(@Suppress("UNUSED_PARAMETER") next: next): Expect<T> =
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.notToHave(@Suppress("UNUSED_PARAMETER") elements: elements): Expect<T> =
|
||||
_logicAppend { hasNotNext(::identity) }
|
||||
|
||||
/**
|
||||
|
||||
@@ -166,3 +166,11 @@ object noDuplicates : Keyword
|
||||
* @since 0.17.0
|
||||
*/
|
||||
object duplicates : Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing expectations about elements as in `expect(iterable) toHave elements`.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
object elements: Keyword
|
||||
|
||||
@@ -5,8 +5,8 @@ import ch.tutteli.atrium.specs.*
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableExpectationsSpec(
|
||||
getToHaveNextPair(),
|
||||
getNotToHaveNextPair(),
|
||||
getToHaveElementsPair(),
|
||||
getNotToHaveElementstPair(),
|
||||
minFeaturePair(),
|
||||
fun1<Iterable<Int>, Expect<Int>.() -> Unit>(Expect<Iterable<Int>>::min),
|
||||
maxFeaturePair(),
|
||||
@@ -14,15 +14,15 @@ class IterableExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableExp
|
||||
getToContainNoDuplicatesPair()
|
||||
) {
|
||||
companion object {
|
||||
private val toHave: KFunction2<Expect<Iterable<Int>>, next, Expect<Iterable<Int>>> = Expect<Iterable<Int>>::toHave
|
||||
private fun getToHaveNextPair() = "${toHave.name} ${next::class.simpleName}" to Companion::toHaveNext
|
||||
private fun toHaveNext(expect: Expect<Iterable<Int>>) = expect toHave next
|
||||
private val toHave: KFunction2<Expect<Iterable<Int>>, elements, Expect<Iterable<Int>>> = Expect<Iterable<Int>>::toHave
|
||||
private fun getToHaveElementsPair() = "${toHave.name} ${next::class.simpleName}" to Companion::toHaveElements
|
||||
private fun toHaveElements(expect: Expect<Iterable<Int>>) = expect toHave elements
|
||||
|
||||
private val notToHave: KFunction2<Expect<Iterable<Int>>, next, Expect<Iterable<Int>>> =
|
||||
private val notToHave: KFunction2<Expect<Iterable<Int>>, elements, Expect<Iterable<Int>>> =
|
||||
Expect<Iterable<Int>>::notToHave
|
||||
|
||||
private fun getNotToHaveNextPair() = "${notToHave.name} ${next::class.simpleName}" to Companion::notToHaveNext
|
||||
private fun notToHaveNext(expect: Expect<Iterable<Int>>) = expect notToHave next
|
||||
private fun getNotToHaveElementstPair() = "${notToHave.name} ${next::class.simpleName}" to Companion::notToHaveElements
|
||||
private fun notToHaveElements(expect: Expect<Iterable<Int>>) = expect notToHave elements
|
||||
|
||||
private fun minFeaturePair() = feature1<Iterable<Int>, o, Int>(Expect<Iterable<Int>>::min).name to ::minFeature
|
||||
private fun minFeature(expect: Expect<Iterable<Int>>) = expect min o
|
||||
@@ -46,16 +46,16 @@ class IterableExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableExp
|
||||
var a1b: Expect<Set<Double?>> = notImplemented()
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1 toHave next
|
||||
a1 = a1 notToHave next
|
||||
a1 = a1 toHave elements
|
||||
a1 = a1 notToHave elements
|
||||
a1 = a1 notToContain duplicates
|
||||
|
||||
a1b = a1b toHave next
|
||||
a1b = a1b notToHave next
|
||||
a1b = a1b toHave elements
|
||||
a1b = a1b notToHave elements
|
||||
a1b = a1b notToContain duplicates
|
||||
|
||||
star = star toHave next
|
||||
star = star notToHave next
|
||||
star = star toHave elements
|
||||
star = star notToHave elements
|
||||
star = star notToContain duplicates
|
||||
|
||||
//nullable not supported by min/max or rather T : Comparable<T> does not exist for T? (one cannot implement an interface for the nullable type)
|
||||
|
||||
@@ -5,9 +5,9 @@ import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
|
||||
class IterableToHaveNextAndAllExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAllExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndAll),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndAll).withNullableSuffix()
|
||||
class IterableToHaveElementsAndAllExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndAllExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveElementsAndAll),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveElementsAndAll).withNullableSuffix()
|
||||
) {
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
@@ -17,11 +17,11 @@ class IterableToHaveNextAndAllExpectationsSpec : ch.tutteli.atrium.specs.integra
|
||||
|
||||
var star: Expect<Iterable<*>> = notImplemented()
|
||||
|
||||
a1 = a1 toHaveNextAndAll {}
|
||||
a1 = a1 toHaveElementsAndAll {}
|
||||
|
||||
a1b = a1b toHaveNextAndAll {}
|
||||
a1b = a1b toHaveNextAndAll null
|
||||
a1b = a1b toHaveElementsAndAll {}
|
||||
a1b = a1b toHaveElementsAndAll null
|
||||
|
||||
star = star toHaveNextAndAll {}
|
||||
star = star toHaveElementsAndAll {}
|
||||
}
|
||||
}
|
||||
@@ -9,31 +9,31 @@ import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableAnyExpectationsSpec : Spek({
|
||||
class IterableToHaveElementsAndAnyExpectationsSpec : Spek({
|
||||
include(PredicateSpec)
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
include(SequenceSpec)
|
||||
}) {
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndAny),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndAny).withNullableSuffix(),
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndAnyExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveElementsAndAny),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveElementsAndAny).withNullableSuffix(),
|
||||
"[Atrium][Predicate] "
|
||||
)
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndAnyExpectationsSpec(
|
||||
getToContainPair(),
|
||||
getToContainNullablePair().withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndAnyExpectationsSpec(
|
||||
getToContainShortcutPair(),
|
||||
getToContainNullableShortcutPair().withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
object SequenceSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
object SequenceSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndAnyExpectationsSpec(
|
||||
getToContainSequencePair(),
|
||||
getToContainNullableSequencePair().withNullableSuffix(),
|
||||
"[Atrium][Sequence] "
|
||||
@@ -94,15 +94,15 @@ class IterableAnyExpectationsSpec : Spek({
|
||||
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1 toHaveNextAndAny {}
|
||||
a1 = a1 toHaveElementsAndAny {}
|
||||
a1 = a1 toContain {}
|
||||
|
||||
a1b = a1b toHaveNextAndAny {}
|
||||
a1b = a1b toHaveNextAndAny null
|
||||
a1b = a1b toHaveElementsAndAny {}
|
||||
a1b = a1b toHaveElementsAndAny null
|
||||
a1b = a1b toContain {}
|
||||
a1b = a1b toContain (null as Double?)
|
||||
|
||||
star = star toHaveNextAndAny {}
|
||||
star = star toHaveElementsAndAny {}
|
||||
star = star toContain {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ class IterableToHaveNextAndNoneExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
|
||||
}) {
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndNoneExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndNone),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndNone).withNullableSuffix(),
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndNoneExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveElementsAndNone),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveElementsAndNone).withNullableSuffix(),
|
||||
"[Atrium][Predicate] "
|
||||
)
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndNoneExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveElementsAndNoneExpectationsSpec(
|
||||
getNotToContainPair(),
|
||||
getNotToContainNullablePair().withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
@@ -44,15 +44,15 @@ class IterableToHaveNextAndNoneExpectationsSpec : Spek({
|
||||
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1.toHaveNextAndNone {}
|
||||
a1 = a1.toHaveElementsAndNone {}
|
||||
a1 = a1 notToContain o entry {}
|
||||
|
||||
a1b = a1b toHaveNextAndNone {}
|
||||
a1b = a1b toHaveNextAndNone null
|
||||
a1b = a1b toHaveElementsAndNone {}
|
||||
a1b = a1b toHaveElementsAndNone null
|
||||
a1b = a1b notToContain o entry {}
|
||||
a1b = a1b notToContain o entry null
|
||||
|
||||
star = star.toHaveNextAndNone {}
|
||||
star = star.toHaveElementsAndNone {}
|
||||
star = star notToContain o entry {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ class AnyExpectationSamples {
|
||||
it notToContain "?"
|
||||
}
|
||||
|
||||
expect(customers) toHaveNextAndAll (fun Expect<Person>.() {
|
||||
expect(customers) toHaveElementsAndAll (fun Expect<Person>.() {
|
||||
it because of("the legal age of maturity in Switzerland is 18") {
|
||||
feature { f(it::age) } toBeGreaterThanOrEqualTo 18
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package ch.tutteli.atrium.core.polyfills
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.*
|
||||
import ch.tutteli.atrium.api.verbs.internal.expect
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import kotlin.test.Test
|
||||
|
||||
class ThrowableStackTest {
|
||||
@@ -12,10 +11,10 @@ class ThrowableStackTest {
|
||||
val stack = IllegalStateException("test").stackBacktrace
|
||||
expect(stack.first()) toStartWith "${ThrowableStackTest::class.simpleName}.illegalStateException"
|
||||
expect(stack) {
|
||||
toHaveNextAndNone {
|
||||
toHaveElementsAndNone {
|
||||
this toContain "init"
|
||||
}
|
||||
toHaveNextAndAny {
|
||||
toHaveElementsAndAny {
|
||||
this toContain "mocha"
|
||||
}
|
||||
}
|
||||
@@ -26,10 +25,10 @@ class ThrowableStackTest {
|
||||
val stack = AssertionError("test").stackBacktrace
|
||||
expect(stack.first()) toStartWith "${ThrowableStackTest::class.simpleName}.assertionError"
|
||||
expect(stack) {
|
||||
toHaveNextAndNone {
|
||||
toHaveElementsAndNone {
|
||||
this toContain "init"
|
||||
}
|
||||
toHaveNextAndAny {
|
||||
toHaveElementsAndAny {
|
||||
this toContain "mocha"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ class AdjustStackSpec : Spek({
|
||||
throwable.addSuppressed(throwable2)
|
||||
val adjuster = createExpect(1, factory)._logic.components.build<AtriumErrorAdjuster>()
|
||||
adjuster.adjust(throwable)
|
||||
(expect(throwable.suppressed) asList o).toHaveNextAndAll(fun Expect<Throwable>.() {
|
||||
(expect(throwable.suppressed) asList o).toHaveElementsAndAll(fun Expect<Throwable>.() {
|
||||
feature { f(it::stackBacktrace) } and {
|
||||
it notToContain o the entries(containsNotFirst, *containsNotRest)
|
||||
it toContain entries(containsFirst, *containsRest)
|
||||
@@ -117,7 +117,7 @@ class AdjustStackSpec : Spek({
|
||||
throwable.addSuppressed(throwable2)
|
||||
val adjuster = createExpect(1, factory)._logic.components.build<AtriumErrorAdjuster>()
|
||||
adjuster.adjust(throwable)
|
||||
(expect(throwable.suppressed) asList o).toHaveNextAndAll(fun Expect<Throwable>.() {
|
||||
(expect(throwable.suppressed) asList o).toHaveElementsAndAll(fun Expect<Throwable>.() {
|
||||
cause<UnsupportedOperationException> {
|
||||
feature { f(it::stackBacktrace) } and {
|
||||
it notToContain o the entries(containsNotFirst, *containsNotRest)
|
||||
@@ -191,7 +191,7 @@ class AdjustStackSpec : Spek({
|
||||
throwable.addSuppressed(throwable2)
|
||||
val adjuster = createExpect(1, factory)._logic.components.build<AtriumErrorAdjuster>()
|
||||
adjuster.adjust(throwable)
|
||||
(expect(throwable.suppressed) asList o).toHaveNextAndAll(fun Expect<Throwable>.() {
|
||||
(expect(throwable.suppressed) asList o).toHaveElementsAndAll(fun Expect<Throwable>.() {
|
||||
it feature { f(it::stackBacktrace) } toBe empty
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package ch.tutteli.atrium.specs
|
||||
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.feature
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toHaveNextAndAll
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toHaveElementsAndAll
|
||||
import ch.tutteli.atrium.api.verbs.internal.expect
|
||||
import ch.tutteli.atrium.assertions.Assertion
|
||||
import ch.tutteli.atrium.assertions.AssertionGroup
|
||||
@@ -63,7 +63,7 @@ abstract class SubjectLessSpec<T>(
|
||||
val assertions = CollectingExpect<T>(None, expect(1)._logic.components)
|
||||
.addAssertionsCreatedBy(createAssertion)
|
||||
.getAssertions()
|
||||
expect(assertions).toHaveNextAndAll {
|
||||
expect(assertions).toHaveElementsAndAll {
|
||||
feature(Assertion::holds).toEqual(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,29 +7,29 @@ import ch.tutteli.atrium.logic.utils.expectLambda
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.translations.DescriptionIterableAssertion
|
||||
|
||||
abstract class IterableToHaveNextAndAllExpectationsSpec(
|
||||
notToBeEmptyAndAll: Fun1<Iterable<Double>, Expect<Double>.() -> Unit>,
|
||||
notToBeEmptyAndAllNullable: Fun1<Iterable<Double?>, (Expect<Double>.() -> Unit)?>,
|
||||
abstract class IterableToHaveElementsAndAllExpectationsSpec(
|
||||
toHaveElementsAndAll: Fun1<Iterable<Double>, Expect<Double>.() -> Unit>,
|
||||
toHaveElementsAndAllNullable: Fun1<Iterable<Double?>, (Expect<Double>.() -> Unit)?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
) : IterableToContainEntriesSpecBase({
|
||||
|
||||
include(object : SubjectLessSpec<Iterable<Double>>(describePrefix,
|
||||
notToBeEmptyAndAll.first to expectLambda { notToBeEmptyAndAll.second(this) { toEqual(2.5) } }
|
||||
toHaveElementsAndAll.first to expectLambda { toHaveElementsAndAll.second(this) { toEqual(2.5) } }
|
||||
) {})
|
||||
include(object : SubjectLessSpec<Iterable<Double?>>(describePrefix,
|
||||
"${notToBeEmptyAndAllNullable.first} for nullable" to expectLambda { notToBeEmptyAndAllNullable.second(this, null) }
|
||||
"${toHaveElementsAndAllNullable.first} for nullable" to expectLambda { toHaveElementsAndAllNullable.second(this, null) }
|
||||
) {})
|
||||
|
||||
include(object : AssertionCreatorSpec<Iterable<Double>>(
|
||||
describePrefix, oneToSeven().toList().asIterable(),
|
||||
notToBeEmptyAndAll.forAssertionCreatorSpec("$toBeGreaterThanDescr: 0.0") { toBeGreaterThan(0.0) }
|
||||
toHaveElementsAndAll.forAssertionCreatorSpec("$toBeGreaterThanDescr: 0.0") { toBeGreaterThan(0.0) }
|
||||
) {})
|
||||
include(object : AssertionCreatorSpec<Iterable<Double?>>(
|
||||
"$describePrefix[nullable Element] ", oneToSeven().toList().asIterable(),
|
||||
notToBeEmptyAndAllNullable.forAssertionCreatorSpec("$toBeGreaterThanDescr: 0.0") { toBeGreaterThan(0.0) }
|
||||
toHaveElementsAndAllNullable.forAssertionCreatorSpec("$toBeGreaterThanDescr: 0.0") { toBeGreaterThan(0.0) }
|
||||
) {})
|
||||
|
||||
val notToBeEmptyAndAllDescr = DescriptionIterableAssertion.ALL.getDefault()
|
||||
val toHaveElementsAndAllDescr = DescriptionIterableAssertion.ALL.getDefault()
|
||||
val hasElement = DescriptionIterableAssertion.HAS_ELEMENT.getDefault()
|
||||
|
||||
val explanatoryPointWithIndent = "$indentRootBulletPoint$indentListBulletPoint$explanatoryBulletPoint"
|
||||
@@ -38,14 +38,14 @@ abstract class IterableToHaveNextAndAllExpectationsSpec(
|
||||
|
||||
nonNullableCases(
|
||||
describePrefix,
|
||||
notToBeEmptyAndAll,
|
||||
notToBeEmptyAndAllNullable
|
||||
) { notToBeEmptyAndAllFun ->
|
||||
toHaveElementsAndAll,
|
||||
toHaveElementsAndAllNullable
|
||||
) { toHaveElementsAndAllFun ->
|
||||
|
||||
context("empty collection") {
|
||||
it("throws AssertionError as there needs to be at least one element") {
|
||||
expect {
|
||||
expect(fluentEmpty()).notToBeEmptyAndAllFun { toBeLessThan(1.0) }
|
||||
expect(fluentEmpty()).toHaveElementsAndAllFun { toBeLessThan(1.0) }
|
||||
}.toThrow<AssertionError> {
|
||||
messageContains(
|
||||
"$rootBulletPoint$featureArrow$hasElement: false$separator" +
|
||||
@@ -59,11 +59,11 @@ abstract class IterableToHaveNextAndAllExpectationsSpec(
|
||||
context("all are $toBeGreaterThanFun(2.5) and $toBeLessThanFun(7.0)") {
|
||||
it("throws AssertionError containing both assumptions in one assertion") {
|
||||
expect {
|
||||
expect(oneToSeven()).notToBeEmptyAndAllFun { toBeGreaterThan(2.5); toBeLessThan(7.0) }
|
||||
expect(oneToSeven()).toHaveElementsAndAllFun { toBeGreaterThan(2.5); toBeLessThan(7.0) }
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
toContain.exactly(1).values(
|
||||
"$rootBulletPoint$notToBeEmptyAndAllDescr: $separator",
|
||||
"$rootBulletPoint$toHaveElementsAndAllDescr: $separator",
|
||||
"$explanatoryPointWithIndent$toBeGreaterThanDescr: 2.5",
|
||||
"$explanatoryPointWithIndent$toBeLessThanDescr: 7.0",
|
||||
"$warningBulletPoint$mismatches:",
|
||||
@@ -78,7 +78,7 @@ abstract class IterableToHaveNextAndAllExpectationsSpec(
|
||||
|
||||
context("all are $toBeGreaterThanFun(0.5) and $toBeLessThanFun(7.5)") {
|
||||
it("does not throw an exception") {
|
||||
expect(oneToSeven()).notToBeEmptyAndAllFun { toBeGreaterThan(0.5); toBeLessThan(7.5) }
|
||||
expect(oneToSeven()).toHaveElementsAndAllFun { toBeGreaterThan(0.5); toBeLessThan(7.5) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,24 +86,24 @@ abstract class IterableToHaveNextAndAllExpectationsSpec(
|
||||
|
||||
nullableCases(describePrefix) {
|
||||
|
||||
describeFun(notToBeEmptyAndAllNullable) {
|
||||
val notToBeEmptyAndAllNullableFun = notToBeEmptyAndAllNullable.lambda
|
||||
describeFun(toHaveElementsAndAllNullable) {
|
||||
val toHaveElementsAndAllNullableFun = toHaveElementsAndAllNullable.lambda
|
||||
|
||||
val iterableOfNulls = { sequenceOf<Double?>(null, null).constrainOnce().asIterable() }
|
||||
context("iterable ${iterableOfNulls()}") {
|
||||
it("all are `null` does not throw") {
|
||||
expect(iterableOfNulls()).notToBeEmptyAndAllNullableFun(null)
|
||||
expect(iterableOfNulls()).toHaveElementsAndAllNullableFun(null)
|
||||
}
|
||||
}
|
||||
|
||||
context("iterable ${oneToSevenNullable().toList()}") {
|
||||
it("$toBeGreaterThanDescr(0.5) throws because two are `null`") {
|
||||
expect {
|
||||
expect(oneToSevenNullable()).notToBeEmptyAndAllNullableFun { toBeGreaterThan(0.5) }
|
||||
expect(oneToSevenNullable()).toHaveElementsAndAllNullableFun { toBeGreaterThan(0.5) }
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
toContain.exactly(1).values(
|
||||
"$rootBulletPoint$notToBeEmptyAndAllDescr: $separator",
|
||||
"$rootBulletPoint$toHaveElementsAndAllDescr: $separator",
|
||||
"$explanatoryPointWithIndent$toBeGreaterThanDescr: 0.5",
|
||||
"$warningBulletPoint$mismatches:",
|
||||
"${index(1)}: null",
|
||||
@@ -6,41 +6,41 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.translations.DescriptionComparableAssertion
|
||||
|
||||
abstract class IterableToHaveNextAndAnyExpectationsSpec(
|
||||
notToBeEmptyAndAny: Fun1<Iterable<Double>, Expect<Double>.() -> Unit>,
|
||||
notToBeEmptyAndAnyNullable: Fun1<Iterable<Double?>, (Expect<Double>.() -> Unit)?>,
|
||||
abstract class IterableToHaveElementsAndAnyExpectationsSpec(
|
||||
toHaveElementsAndAny: Fun1<Iterable<Double>, Expect<Double>.() -> Unit>,
|
||||
toHaveElementsAndAnyNullable: Fun1<Iterable<Double?>, (Expect<Double>.() -> Unit)?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
) : IterableToContainEntriesSpecBase({
|
||||
|
||||
val isGreaterThanDescr = DescriptionComparableAssertion.IS_GREATER_THAN.getDefault()
|
||||
|
||||
include(object : SubjectLessSpec<Iterable<Double>>(describePrefix,
|
||||
notToBeEmptyAndAny.forSubjectLess { toEqual(2.5) }
|
||||
toHaveElementsAndAny.forSubjectLess { toEqual(2.5) }
|
||||
) {})
|
||||
include(object : SubjectLessSpec<Iterable<Double?>>(
|
||||
describePrefix,
|
||||
notToBeEmptyAndAnyNullable.forSubjectLess(null)
|
||||
toHaveElementsAndAnyNullable.forSubjectLess(null)
|
||||
) {})
|
||||
|
||||
include(object : AssertionCreatorSpec<Iterable<Double>>(
|
||||
describePrefix, oneToSeven().toList().asIterable(),
|
||||
notToBeEmptyAndAny.forAssertionCreatorSpec("$isGreaterThanDescr: 1.0") { toBeGreaterThan(1.0) }
|
||||
toHaveElementsAndAny.forAssertionCreatorSpec("$isGreaterThanDescr: 1.0") { toBeGreaterThan(1.0) }
|
||||
) {})
|
||||
include(object : AssertionCreatorSpec<Iterable<Double?>>(
|
||||
"$describePrefix[nullable Element] ", oneToSeven().toList().asIterable(),
|
||||
notToBeEmptyAndAnyNullable.forAssertionCreatorSpec("$isGreaterThanDescr: 1.0") { toBeGreaterThan(1.0) }
|
||||
toHaveElementsAndAnyNullable.forAssertionCreatorSpec("$isGreaterThanDescr: 1.0") { toBeGreaterThan(1.0) }
|
||||
) {})
|
||||
|
||||
nonNullableCases(
|
||||
describePrefix,
|
||||
notToBeEmptyAndAny,
|
||||
notToBeEmptyAndAnyNullable
|
||||
) { notToBeEmptyAndAnyFun ->
|
||||
toHaveElementsAndAny,
|
||||
toHaveElementsAndAnyNullable
|
||||
) { toHaveElementsAndAnyFun ->
|
||||
|
||||
context("empty collection") {
|
||||
it("throws AssertionError as there needs to be at least one element") {
|
||||
expect {
|
||||
expect(fluentEmpty()).notToBeEmptyAndAnyFun { toBeLessThan(1.0) }
|
||||
expect(fluentEmpty()).toHaveElementsAndAnyFun { toBeLessThan(1.0) }
|
||||
}.toThrow<AssertionError> {
|
||||
messageContains(
|
||||
"$rootBulletPoint$toContainInAnyOrder: $separator",
|
||||
@@ -58,7 +58,7 @@ abstract class IterableToHaveNextAndAnyExpectationsSpec(
|
||||
context("search for entry which $toBeGreaterThanFun(1.0) and $toBeLessThanFun(2.0)") {
|
||||
it("throws AssertionError containing both assumptions in one assertion") {
|
||||
expect {
|
||||
expect(oneToSeven()).notToBeEmptyAndAnyFun { toBeGreaterThan(1.0); toBeLessThan(2.0) }
|
||||
expect(oneToSeven()).toHaveElementsAndAnyFun { toBeGreaterThan(1.0); toBeLessThan(2.0) }
|
||||
}.toThrow<AssertionError> {
|
||||
messageContains(
|
||||
"$rootBulletPoint$toContainInAnyOrder: $separator",
|
||||
@@ -74,7 +74,7 @@ abstract class IterableToHaveNextAndAnyExpectationsSpec(
|
||||
|
||||
context("search for entry which $toBeGreaterThanFun(1.0) and $toBeLessThanFun(2.1)") {
|
||||
it("does not throw an exception") {
|
||||
expect(oneToSeven()).notToBeEmptyAndAnyFun { toBeGreaterThan(1.0); toBeLessThan(2.1) }
|
||||
expect(oneToSeven()).toHaveElementsAndAnyFun { toBeGreaterThan(1.0); toBeLessThan(2.1) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,23 +82,23 @@ abstract class IterableToHaveNextAndAnyExpectationsSpec(
|
||||
|
||||
nullableCases(describePrefix) {
|
||||
|
||||
describeFun(notToBeEmptyAndAnyNullable) {
|
||||
val notToBeEmptyAndAnyFun = notToBeEmptyAndAnyNullable.lambda
|
||||
describeFun(toHaveElementsAndAnyNullable) {
|
||||
val toHaveElementsAndAnyFun = toHaveElementsAndAnyNullable.lambda
|
||||
|
||||
context("iterable ${oneToSevenNullable().toList()}") {
|
||||
context("happy cases (do not throw)") {
|
||||
it("$toEqualFun(1.0)") {
|
||||
expect(oneToSevenNullable()).notToBeEmptyAndAnyFun { toEqual(1.0) }
|
||||
expect(oneToSevenNullable()).toHaveElementsAndAnyFun { toEqual(1.0) }
|
||||
}
|
||||
it("null") {
|
||||
expect(oneToSevenNullable()).notToBeEmptyAndAnyFun(null)
|
||||
expect(oneToSevenNullable()).toHaveElementsAndAnyFun(null)
|
||||
}
|
||||
}
|
||||
|
||||
context("failing cases") {
|
||||
it("$toEqualFun(2.0)") {
|
||||
expect {
|
||||
expect(oneToSevenNullable()).notToBeEmptyAndAnyFun { toEqual(2.0) }
|
||||
expect(oneToSevenNullable()).toHaveElementsAndAnyFun { toEqual(2.0) }
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
toContain.exactly(1).values(
|
||||
@@ -117,7 +117,7 @@ abstract class IterableToHaveNextAndAnyExpectationsSpec(
|
||||
context("iterable ${oneToSeven().toList()}") {
|
||||
it("null, throws an AssertionError") {
|
||||
expect {
|
||||
expect(oneToSeven() as Iterable<Double?>).notToBeEmptyAndAnyFun(null)
|
||||
expect(oneToSeven() as Iterable<Double?>).toHaveElementsAndAnyFun(null)
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
toContain.exactly(1).values(
|
||||
@@ -6,26 +6,26 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.translations.DescriptionIterableAssertion
|
||||
|
||||
abstract class IterableToHaveNextAndNoneExpectationsSpec(
|
||||
notToBeEmptyAndNone: Fun1<Iterable<Double>, Expect<Double>.() -> Unit>,
|
||||
notToBeEmptyAndNoneNullable: Fun1<Iterable<Double?>, (Expect<Double>.() -> Unit)?>,
|
||||
abstract class IterableToHaveElementsAndNoneExpectationsSpec(
|
||||
toHaveElementsAndNone: Fun1<Iterable<Double>, Expect<Double>.() -> Unit>,
|
||||
toHaveElementsAndNoneNullable: Fun1<Iterable<Double?>, (Expect<Double>.() -> Unit)?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
) : IterableToContainEntriesSpecBase({
|
||||
|
||||
include(object : SubjectLessSpec<Iterable<Double>>(describePrefix,
|
||||
notToBeEmptyAndNone.forSubjectLess { toEqual(2.3) }
|
||||
toHaveElementsAndNone.forSubjectLess { toEqual(2.3) }
|
||||
) {})
|
||||
include(object : SubjectLessSpec<Iterable<Double?>>(describePrefix,
|
||||
notToBeEmptyAndNoneNullable.forSubjectLess { toEqual(2.3) }
|
||||
toHaveElementsAndNoneNullable.forSubjectLess { toEqual(2.3) }
|
||||
) {})
|
||||
|
||||
include(object : AssertionCreatorSpec<Iterable<Double>>(
|
||||
describePrefix, oneToSeven().toList().asIterable(),
|
||||
notToBeEmptyAndNone.forAssertionCreatorSpec("$toBeGreaterThanDescr: 10.0") { toBeGreaterThan(10.0) }
|
||||
toHaveElementsAndNone.forAssertionCreatorSpec("$toBeGreaterThanDescr: 10.0") { toBeGreaterThan(10.0) }
|
||||
) {})
|
||||
include(object : AssertionCreatorSpec<Iterable<Double?>>(
|
||||
"$describePrefix[nullable Element] ", oneToSeven().toList().asIterable(),
|
||||
notToBeEmptyAndNoneNullable.forAssertionCreatorSpec("$toBeGreaterThanDescr: 10.0") { toBeGreaterThan(10.0) }
|
||||
toHaveElementsAndNoneNullable.forAssertionCreatorSpec("$toBeGreaterThanDescr: 10.0") { toBeGreaterThan(10.0) }
|
||||
) {})
|
||||
|
||||
val containsNotDescr = DescriptionIterableAssertion.CONTAINS_NOT.getDefault()
|
||||
@@ -33,14 +33,14 @@ abstract class IterableToHaveNextAndNoneExpectationsSpec(
|
||||
|
||||
nonNullableCases(
|
||||
describePrefix,
|
||||
notToBeEmptyAndNone,
|
||||
notToBeEmptyAndNoneNullable
|
||||
) { notToBeEmptyAndNoneFun ->
|
||||
toHaveElementsAndNone,
|
||||
toHaveElementsAndNoneNullable
|
||||
) { toHaveElementsAndNoneFun ->
|
||||
|
||||
context("empty collection") {
|
||||
it("throws AssertionError as there needs to be at least one element") {
|
||||
expect {
|
||||
expect(fluentEmpty()).notToBeEmptyAndNoneFun { toBeLessThan(1.0) }
|
||||
expect(fluentEmpty()).toHaveElementsAndNoneFun { toBeLessThan(1.0) }
|
||||
}.toThrow<AssertionError> {
|
||||
messageContains("$featureArrow$hasElement: false")
|
||||
}
|
||||
@@ -51,7 +51,7 @@ abstract class IterableToHaveNextAndNoneExpectationsSpec(
|
||||
context("happy case") {
|
||||
listOf(1.1, 2.2, 3.3).forEach {
|
||||
it("$toBeDescr($it) does not throw") {
|
||||
expect(oneToSeven()).notToBeEmptyAndNoneFun { toEqual(1.1) }
|
||||
expect(oneToSeven()).toHaveElementsAndNoneFun { toEqual(1.1) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ abstract class IterableToHaveNextAndNoneExpectationsSpec(
|
||||
context("failing cases; search string at different positions") {
|
||||
it("$toBeDescr(4.0) throws AssertionError") {
|
||||
expect {
|
||||
expect(oneToSeven()).notToBeEmptyAndNoneFun { toEqual(4.0) }
|
||||
expect(oneToSeven()).toHaveElementsAndNoneFun { toEqual(4.0) }
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
toContainRegex(
|
||||
@@ -78,18 +78,18 @@ abstract class IterableToHaveNextAndNoneExpectationsSpec(
|
||||
}
|
||||
}
|
||||
nullableCases(describePrefix) {
|
||||
describeFun(notToBeEmptyAndNoneNullable) {
|
||||
val notToBeEmptyAndNoneFun = notToBeEmptyAndNoneNullable.lambda
|
||||
describeFun(toHaveElementsAndNoneNullable) {
|
||||
val toHaveElementsAndNoneFun = toHaveElementsAndNoneNullable.lambda
|
||||
|
||||
context("iterable ${oneToSeven().toList()}") {
|
||||
it("null does not throw") {
|
||||
expect(oneToSeven() as Iterable<Double?>).notToBeEmptyAndNoneFun(null)
|
||||
expect(oneToSeven() as Iterable<Double?>).toHaveElementsAndNoneFun(null)
|
||||
}
|
||||
}
|
||||
context("iterable ${oneToSevenNullable().toList()}") {
|
||||
it("null throws AssertionError") {
|
||||
expect {
|
||||
expect(oneToSevenNullable()).notToBeEmptyAndNoneFun(null)
|
||||
expect(oneToSevenNullable()).toHaveElementsAndNoneFun(null)
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
toContainRegex(
|
||||
@@ -107,7 +107,7 @@ abstract class IterableToHaveNextAndNoneExpectationsSpec(
|
||||
|
||||
it("1.0 throws AssertionError") {
|
||||
expect {
|
||||
expect(oneToSevenNullable()).notToBeEmptyAndNoneFun { toEqual(1.0) }
|
||||
expect(oneToSevenNullable()).toHaveElementsAndNoneFun { toEqual(1.0) }
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
toContainRegex(
|
||||
@@ -2,7 +2,6 @@ package readme.examples
|
||||
|
||||
import readme.examples.utils.expect
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.*
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import java.math.BigDecimal
|
||||
|
||||
@@ -134,17 +133,17 @@ class MostExamplesSpec : Spek({
|
||||
}
|
||||
|
||||
test("ex-collection-any") {
|
||||
expect(listOf(1, 2, 3, 4)).toHaveNextAndAny {
|
||||
expect(listOf(1, 2, 3, 4)).toHaveElementsAndAny {
|
||||
toBeLessThan(0)
|
||||
}
|
||||
}
|
||||
test("ex-collection-none") {
|
||||
expect(listOf(1, 2, 3, 4)).toHaveNextAndNone {
|
||||
expect(listOf(1, 2, 3, 4)).toHaveElementsAndNone {
|
||||
toBeGreaterThan(2)
|
||||
}
|
||||
}
|
||||
test("ex-collection-all") {
|
||||
expect(listOf(1, 2, 3, 4)).toHaveNextAndAll {
|
||||
expect(listOf(1, 2, 3, 4)).toHaveElementsAndAll {
|
||||
toBeGreaterThan(2)
|
||||
}
|
||||
}
|
||||
@@ -214,8 +213,8 @@ class MostExamplesSpec : Spek({
|
||||
}
|
||||
test("ex-map-4") {
|
||||
expect(mapOf("a" to 1, "b" to 2)) {
|
||||
keys { toHaveNextAndAll { toStartWith("a") } }
|
||||
values { toHaveNextAndNone { toBeGreaterThan(1) } }
|
||||
keys { toHaveElementsAndAll { toStartWith("a") } }
|
||||
values { toHaveElementsAndNone { toBeGreaterThan(1) } }
|
||||
}
|
||||
}
|
||||
test("ex-map-5") {
|
||||
|
||||
@@ -79,7 +79,7 @@ object OwnExpectationFunctionsSpec : Spek({
|
||||
//snippet-own-compose-4-start
|
||||
fun Expect<Person>.hasAdultChildren(): Expect<Person> =
|
||||
feature(Person::children) {
|
||||
toHaveNextAndAll {
|
||||
toHaveElementsAndAll {
|
||||
feature(Person::age).toBeGreaterThanOrEqualTo(18)
|
||||
}
|
||||
}
|
||||
@@ -101,17 +101,17 @@ object OwnExpectationFunctionsSpec : Spek({
|
||||
test("ex-own-compose-5"){
|
||||
expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, listOf()))))
|
||||
.children { // using the fun -> assertion group, ergo sub-assertions don't fail fast
|
||||
toHaveNextAndNone {
|
||||
toHaveElementsAndNone {
|
||||
feature { f(it::firstName) }.toStartWith("Ro")
|
||||
}
|
||||
toHaveNextAndAll {
|
||||
toHaveElementsAndAll {
|
||||
feature { f(it::lastName) }.toEqual("Whitley")
|
||||
}
|
||||
} // subject is still Person here
|
||||
.apply { // only evaluated because the previous assertion group holds
|
||||
children // using the val -> subsequent assertions are about children and fail fast
|
||||
.toHaveSize(2)
|
||||
.toHaveNextAndAny {
|
||||
.toHaveElementsAndAny {
|
||||
feature { f(it::age) }.toBeGreaterThan(18)
|
||||
}
|
||||
} // subject is still Person here due to the `apply`
|
||||
|
||||
Reference in New Issue
Block a user