Skip to content

Commit

Permalink
adopt comments for IteratorSamples from infix also for fluent
Browse files Browse the repository at this point in the history
  • Loading branch information
robstoll committed Dec 27, 2020
1 parent 162938f commit effb406
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ class IteratorAssertionSamples {
fun hasNext() {
val list = listOf(1)
val iterator = list.iterator()
expect(iterator).hasNext()
expect(iterator).hasNext() // holds as iterator has a next element

fails {
iterator.next()
expect(iterator).hasNext()
iterator.next() // returns the next element in iteration
expect(iterator).hasNext() // fails as list has only 1 element, i.e. no next any more.
}
}

@Test
fun hasNoNext() {
val list = listOf(1)
val iterator = list.iterator()
val iterator = list.iterator() // fails as iterator has a next element (has actually one element)

fails {
expect(iterator).hasNotNext()
}

iterator.next()
expect(iterator).hasNotNext()
iterator.next() // returns the next element in iteration
expect(iterator).hasNotNext() // returns the next element in iteration
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ import kotlin.test.Test
class IteratorAssertionSamples {

@Test
fun has() {
fun has_next() {
val list = listOf(1)
val iterator = list.iterator()
expect(iterator) has next //subject is iterator of list
expect(iterator) has next // holds as iterator has a next element

fails {
iterator.next() //returns the next element in iteration
expect(iterator) has next //fails as list has only 1 element
iterator.next() // returns the next element in iteration
expect(iterator) has next // fails as list has only 1 element, i.e. no next any more.
}
}

@Test
fun hasNot() {
fun hasNot_next() {
val list = listOf(1)
val iterator = list.iterator()

fails {
expect(iterator) hasNot next //fails as list has one element
expect(iterator) hasNot next // fails as iterator has a next element (has actually one element)
}

iterator.next() //returns the next element in iteration
expect(iterator) hasNot next //list has no more elements
iterator.next() // returns the next element in iteration
expect(iterator) hasNot next // list has no more elements thus expectation holds
}
}

0 comments on commit effb406

Please sign in to comment.