Skip to content

Commit

Permalink
Merge pull request #497 from assaflei/#493-merge-jdk8-extensions-to-jvm
Browse files Browse the repository at this point in the history
* build windows also against JDK 11

introduce typealias CharSequenceOrNumberOrChar for Any

move CharSequenceOrNumberOrChar to domain-api and use in domain-impl

update setup instructions for the new infix API

include the new infix API to be published

preparation for accepting String instead of Zoned/LocalDate(Time) object

preparation for #480, #481 and #482

refer to current milestone in good_first_issue template

fix link for nullableContainer

return empty message in case callee is org.spekframework.ide

reduce code duplication also for jvm specs, add more cases to PathSpec

fix wrong replacements and workaround KT-38721 (add import next to star)

api-fluent work done

commiting requested changes

updated with comments

adding problematic classes which break the build

adding problemtic code to server to reproduce error

reproducing problematic build on CI

fix to build problem

addressing latest comment, build should pass

adjust the pseudo-keyword from exist to existing

moved infix jdk8 extension to jvm module

rebasing

* added file deprecation suppress message + removed niok and kbox references

* resolving comments in re
  • Loading branch information
robstoll authored May 15, 2020
2 parents 5c28ece + b34272c commit 527a55a
Show file tree
Hide file tree
Showing 75 changed files with 1,571 additions and 132 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Please choose the appropriate template and fill in all sections
*Affected Version*:
*API* (fluent-en_GB, cc or cc-infix):
*Platform* (jvm, js, android):
*Extension* (none, kotlin 1.3, jdk8): none
*Extension* (none, kotlin 1.3): none

## How to reproduce the problem
Consider the following code snippet
Expand All @@ -25,7 +25,7 @@ A clear and concise description of what you expected to happen.
# Feature Request

*Platform* (jvm, js, android):
*Extension* (none, kotlin 1.3, jdk8): none
*Extension* (none, kotlin 1.3): none

## Code related feature
```
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ labels: bug
*Affected Version*:
*API* (fluent-en_GB, cc or cc-infix):
*Platform* (jvm, js, android):
*Extension* (none, kotlin 1.3, jdk8): none
*Extension* (none, kotlin 1.3): none

## How to reproduce the problem
Consider the following code snippet
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ about: Suggest an idea for this project
---

*Platform* (jvm, js, android):
*Extension* (none, kotlin 1.3, jdk8): none
*Extension* (none, kotlin 1.3): none

## Code related feature
```
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/good_first_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ about: Create a good first issue
labels: good first issue, help wanted
---
*Platform* (jvm, js, android):
*Extension* (none, kotlin 1.3, jdk8): none
*Extension* (none, kotlin 1.3): none

## Code related feature
```
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,11 @@ which provides a pure fluent API (in en_GB) for the JVM platform.
Have a look at the [JVM sample projects](https://github.com/robstoll/atrium/tree/master/samples/jvm) for a quick setup.

We currently provide the following extensions for the JVM platform:
- jdk8: assertion functions for JDK 8 specific types (e.g. for `Path`)
- kotlin_1_3: assertion functions for Kotlin 1.3 specific types (e.g. for [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)).

You can enable them as follows:
```
dependencies {
testImplementation "ch.tutteli.atrium:atrium-api-fluent-en_GB-jdk8:$atrium_version"
testImplementation "ch.tutteli.atrium:atrium-api-fluent-en_GB-kotlin_1_3:$atrium_version"
testRuntimeOnly "ch.tutteli.atrium:atrium-domain-robstoll-kotlin_1_3:$atrium_version"
}
Expand All @@ -140,7 +138,6 @@ dependencies {
And for the aforementioned extensions:
```
dependencies {
testImplementation "ch.tutteli.atrium:atrium-api-infix-en_GB-jdk8:$atrium_version"
testImplementation "ch.tutteli.atrium:atrium-api-infix-en_GB-kotlin_1_3:$atrium_version"
testRuntimeOnly "ch.tutteli.atrium:atrium-domain-robstoll-kotlin_1_3:$atrium_version"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */)

package ch.tutteli.atrium.api.fluent.en_GB

import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.domain.builders.ExpectImpl
import ch.tutteli.atrium.domain.builders.chronoLocalDate
import java.time.chrono.ChronoLocalDate

/**
* Expects that the subject of the assertion (a [ChronoLocalDate])
* is before the [expected] [ChronoLocalDate].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoLocalDate> Expect<T>.isBefore(expected: ChronoLocalDate): Expect<T> =
addAssertion(ExpectImpl.chronoLocalDate.isBefore(this, expected))

/**
* Expects that the subject of the assertion (a [ChronoLocalDate])
* is before or equal the [expected] [ChronoLocalDate].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoLocalDate> Expect<T>.isBeforeOrEqual(expected: ChronoLocalDate): Expect<T> =
addAssertion(ExpectImpl.chronoLocalDate.isBeforeOrEquals(this, expected))


/**
* Expects that the subject of the assertion (a [ChronoLocalDate])
* is after the [expected] [ChronoLocalDate].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoLocalDate> Expect<T>.isAfter(expected: ChronoLocalDate): Expect<T> =
addAssertion(ExpectImpl.chronoLocalDate.isAfter(this, expected))

/**
* Expects that the subject of the assertion (a [ChronoLocalDate])
* is after or equal the [expected] [ChronoLocalDate].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoLocalDate> Expect<T>.isAfterOrEqual(expected: ChronoLocalDate): Expect<T> =
addAssertion(ExpectImpl.chronoLocalDate.isAfterOrEquals(this, expected))

/**
* Expects that the subject of the assertion (a [ChronoLocalDate])
* is equal to the [expected] [ChronoLocalDate].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoLocalDate> Expect<T>.isEqual(expected: ChronoLocalDate): Expect<T> =
addAssertion(ExpectImpl.chronoLocalDate.isEqual(this, expected))
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */)

package ch.tutteli.atrium.api.fluent.en_GB

import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.domain.builders.ExpectImpl
import ch.tutteli.atrium.domain.builders.chronoLocalDateTime
import java.time.chrono.ChronoLocalDate
import java.time.chrono.ChronoLocalDateTime

/**
* Expects that the subject of the assertion (a [ChronoLocalDateTime])
* is before the [expected] [ChronoLocalDateTime].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.isBefore(expected: ChronoLocalDateTime<*>): Expect<T> =
addAssertion(ExpectImpl.chronoLocalDateTime.isBefore(this, expected))

/**
* Expects that the subject of the assertion (a [ChronoLocalDateTime])
* is before or equal the [expected] [ChronoLocalDateTime].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.isBeforeOrEqual(
expected: ChronoLocalDateTime<*>
): Expect<T> = addAssertion(ExpectImpl.chronoLocalDateTime.isBeforeOrEquals(this, expected))

/**
* Expects that the subject of the assertion (a [ChronoLocalDateTime])
* is after the [expected] [ChronoLocalDateTime].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.isAfter(
expected: ChronoLocalDateTime<*>
): Expect<T> = addAssertion(ExpectImpl.chronoLocalDateTime.isAfter(this, expected))

/**
* Expects that the subject of the assertion (a [ChronoLocalDateTime])
* is after or equal the [expected] [ChronoLocalDateTime].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.isAfterOrEqual(
expected: ChronoLocalDateTime<*>
): Expect<T> = addAssertion(ExpectImpl.chronoLocalDateTime.isAfterOrEquals(this, expected))

/**
* Expects that the subject of the assertion (a [ChronoLocalDateTime])
* is equal to the [expected] [ChronoLocalDateTime].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoLocalDateTime<out ChronoLocalDate>> Expect<T>.isEqual(
expected: ChronoLocalDateTime<*>
): Expect<T> = addAssertion(ExpectImpl.chronoLocalDateTime.isEqual(this, expected))
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */)

package ch.tutteli.atrium.api.fluent.en_GB

import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.domain.builders.ExpectImpl
import ch.tutteli.atrium.domain.builders.chronoZonedDateTime
import java.time.chrono.ChronoLocalDate
import java.time.chrono.ChronoZonedDateTime

/**
* Expects that the subject of the assertion (a [ChronoZonedDateTime])
* is before the [expected] [ChronoZonedDateTime].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoZonedDateTime<out ChronoLocalDate>> Expect<T>.isBefore(
expected: ChronoZonedDateTime<*>
): Expect<T> = addAssertion(ExpectImpl.chronoZonedDateTime.isBefore(this, expected))

/**
* Expects that the subject of the assertion (a [ChronoZonedDateTime])
* is before or equals the [expected] [ChronoZonedDateTime].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoZonedDateTime<out ChronoLocalDate>> Expect<T>.isBeforeOrEqual(
expected: ChronoZonedDateTime<*>
): Expect<T> = addAssertion(ExpectImpl.chronoZonedDateTime.isBeforeOrEqual(this, expected))

/**
* Expects that the subject of the assertion (a [ChronoZonedDateTime])
* is after the [expected] [ChronoZonedDateTime].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoZonedDateTime<out ChronoLocalDate>> Expect<T>.isAfter(
expected: ChronoZonedDateTime<*>
): Expect<T> = addAssertion(ExpectImpl.chronoZonedDateTime.isAfter(this, expected))

/**
* Expects that the subject of the assertion (a [ChronoZonedDateTime])
* is after or equal the [expected] [ChronoZonedDateTime].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoZonedDateTime<out ChronoLocalDate>> Expect<T>.isAfterOrEqual(
expected: ChronoZonedDateTime<*>
): Expect<T> = addAssertion(ExpectImpl.chronoZonedDateTime.isAfterOrEqual(this, expected))

/**
* Expects that the subject of the assertion (a [ChronoZonedDateTime])
* is equal to the [expected] [ChronoZonedDateTime].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*
* @since 0.9.0
*/
fun <T : ChronoZonedDateTime<out ChronoLocalDate>> Expect<T>.isEqual(
expected: ChronoZonedDateTime<*>
): Expect<T> = addAssertion(ExpectImpl.chronoZonedDateTime.isEqual(this, expected))
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */)

package ch.tutteli.atrium.api.fluent.en_GB

import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.domain.builders.ExpectImpl
import java.io.File
import java.nio.file.Path

/**
* Turns `Expect<File>` into `Expect<Path>`.
*
* The transformation as such is not reflected in reporting.
* Use `feature(File::toPath)` if you want to show the transformation in reporting.
*
* @return The newly created [Expect] for the transformed subject.
*
* @since 0.9.0
*/
fun <T : File> Expect<T>.asPath(): Expect<Path> =
ExpectImpl.changeSubject(this).unreported { it.toPath() }

/**
* Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for
* the subject as [Path].
*
* The transformation as such is not reflected in reporting.
* Use `feature(File::toPath, assertionCreator)` if you want to show the transformation in reporting.
*
* @return An [Expect] for the current subject of the assertion.
*
* @since 0.9.0
*/
fun <T : File> Expect<T>.asPath(assertionCreator: Expect<Path>.() -> Unit): Expect<T> =
apply { asPath().addAssertionsCreatedBy(assertionCreator) }
Loading

0 comments on commit 527a55a

Please sign in to comment.