Skip to content

add ListFeatureExtractor.last #1654

@robstoll

Description

@robstoll

Platform (all, jvm, js): all
Extension (none, kotlin 1.3): none

Code related feature

val list = listOf(1, 3, 4)
expect(list) {
    last.toEqual(1)
    last {
        toBeGreaterThan(0)
        toBeLessThan(0)
    }
}

//instead of
expect(list) {
    get(list.size - 1).toEqual(1)
    get(List.size -1) {
        toBeGreaterThan(0)
        toBeLessThan(0)
    }
}

Following the things you need to do:

logic

  • extend ListAssertions with a function last (see MapEntryAssertions key as a guideline)
  • implement last in DefaultListAssertions.kt by using the ExpectImpl.feature.extractor... (see get as guideline)

api-fluent

  • provide a val which returns Expect<E> in listFeatureExtractors.kt (see mapEntryFeatureExtractors.kt key as a guideline)
  • provide a fun which expects an assertionCreator-lambda and returns Expect<T> in listFeatureExtractors.kt (see mapEntryFeatureExtractors.kt key as a guideline)
  • extend ListExpectationsSpec in specs -> commonMain (see get... params in this spec) and extend it in atrium-api-fluent -> commonTest
  • add samples to ListFeatureExtractoSamples.kt (see getFeature and get as guideline -- try to provide the reason why an expectation fails)
  • add @since 1.2.0 (adapt to current milestone) to KDOC

api-infix

  • provide a val which returns Expect<E> in listFeatureExtractors.kt (see mapEntryFeatureExtractors.kt key as a guideline)
  • provide a fun which expects an assertionCreator-lambda and returns Expect<T> in listFeatureExtractors.kt (see mapEntryFeatureExtractors.kt key as a guideline)
  • extend ListExpectationsSpec in specs -> commonMain (see get... params in this spec) and extend it in atrium-api-fluent -> commonTest
  • add samples to ListFeatureExtractoSamples.kt (see getFeature and get as guideline -- try to provide the reason why an expectation fails)
  • add @since 1.2.0 (adapt to current milestone) to KDOC

Metadata

Metadata

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions