robstoll / atrium

A multiplatform expectation library for Kotlin

Home Page:https://docs.atriumlib.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature extractor for Iterator.next

robstoll opened this issue · comments

Code related feature

expect(iterator).next().toEqual(true)

//instead of
expect(iterator).feature { f(it::next) }.toEqual(true)

However, we also want to show a better error message in case there is not a next

Following the things you need to do:

logic

  • extend IteratorAssertions with a function next (see ListAssertions.get as a guideline)
  • implement next in DefaultIteratorAssertions.kt by using container.extractFeature... (see DefaultListAssertions.get)

api-fluent

  • provide a val which returns Expect<T> in iteratorFeatureExtractors.kt (see listFeatureExtractors.kt as a guideline)
  • provide a fun which expects an assertionCreator-lambda and returns Expect<E> (where E is the element type in Iterator<E>) in iteratorFeatureExtractors.kt (see listFeatureExtractors.kt as a guideline)
  • extend or write a separate Spec named IteratorFeatureExtractorSpec in specs -> commonMain (see for instance ListExpectationsSpec) and extend it in atrium-api-fluent -> commonTest
  • add samples to IteratorFeatureExtractorSamples.kt (see ListFeatureExtractorSamples.kt as guideline -- try to provide the reason why an expectation fails)
  • add @sample with link to your sample method to the two functions in iteratorExpectations.kt
  • add @since 1.3.0 (adapt to current milestone) to KDOC of the two functions in iteratorExpectations.kt

api-infix

  • provide a val which returns Expect<T> in iteratorExpectations.kt (see listExpectations.kt as a guideline)
  • provide a fun which expects an assertionCreator-lambda and returns Expect<E> (where E is the element type in Iterator<E>) in iteratorFeatureExtractors.kt (see listFeatureExtractors.kt as a guideline)
  • extend or write a separate Spec named IteratorFeatureExtractorSpec in specs -> commonMain (see for instance ListExpectationsSpec) and extend it in atrium-api-infix -> commonTest
  • add samples to IteratorFeatureExtractorSamples.kt (see ListFeatureExtractorSamples.kt as guideline -- try to provide the reason why an expectation fails)
  • add @sample with link to your sample method to the two functions in iteratorExpectations.kt
  • add @since 1.3.0 (adapt to current milestone) to KDOC of the two functions in iteratorExpectations.kt

Your first contribution?

  • Write a comment I'll work on this if you would like to take this issue over.
    This way we get the chance to revise the description in case things have changed in the meantime, we might give you additional hints and we can assign the task to you, so that others do not start as well.
  • See Your first code contribution for guidelines.
  • Do not hesitate to ask questions here or to contact us via Atrium's slack channel if you need help
    (Invite yourself in case you do not have an account yet).