Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

481 accept date and time as string in ISO 8601 format for ChronoLocalDateTime 2 #552

Conversation

rkiselev
Copy link
Contributor

Hi @robstoll, thanks for your answers. I think that I have implemented as you said, but I get an error on build:
ChronoLocalDateTimeAssertionSpec.kt: (18, 9): Type inference failed: inline fun <T, A1> fun1(f: KFunction2<Expect, A1, Expect>): Fun1<T, A1> /* = Pair<String, Expect.(A1) -> Expect> /
cannot be applied to
(KFunction2<Expect<ChronoLocalDateTime<
>>, ChronoLocalDateTime<>, Expect<ChronoLocalDateTime<>>>)

and others for each method, could you help me?


I confirm that I have read the Contributor Agreements v1.0, agree to be bound on them and confirm that my contribution is compliant.

rkiselev and others added 12 commits July 5, 2020 10:40
# Conflicts:
#	misc/deprecated/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/chronoLocalDateTimeAssertions.kt
…/impl/DefaultChronoLocalDateTimeAssertions.kt
…/impl/DefaultChronoLocalDateTimeAssertions.kt
…/impl/DefaultChronoLocalDateTimeAssertions.kt
…/impl/DefaultChronoLocalDateTimeAssertions.kt
…/impl/DefaultChronoLocalDateTimeAssertions.kt
…ll#481-chrono-local-date-time

# Conflicts:
#	apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ChronoLocalDateTimeAssertionSpec.kt
#	logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultChronoLocalDateTimeAssertions.kt
@rkiselev rkiselev requested a review from robstoll as a code owner July 26, 2020 18:33
@robstoll robstoll changed the base branch from master to #481-ChronoLocalDateTime-as-string July 26, 2020 19:37
@robstoll
Copy link
Owner

@rkiselev can you please base your work on my branch. It already contains all changes you did in the other PR (see instructions in the other PR on how to checkout the branch). This way I see immediately what you have changed since then. thanks.

@rkiselev
Copy link
Contributor Author

rkiselev commented Jul 26, 2020

@robstoll, I can't change the source branch of PR, but after you have changed PR from master to #481-ChronoLocalDateTime-as-string at file changed tab there are only my last changes from today. Is it enough, or do I need to close this PR and create a new one?

@robstoll
Copy link
Owner

I would expect to see only one commit but it's OK if the changes I see now are the new ones. I'll look at your problem tomorrow

Copy link
Owner

@robstoll robstoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkiselev the problem is Kotlin, the compiler is not able to infer the types as we have now two functions with the name isBefore in the API. We need to help it.
change

fun1(Expect<ChronoLocalDateTime<*>>::isBefore),

to

fun1<ChronoLocalDateTime<*>, ChronoLocalDateTime<*>>(Expect<ChronoLocalDateTime<*>>::isBefore),

Same same for the other functions. Intellij will tell you that the type arguments are redundant but you need to keep them as the compiler sees it differently (it will work as expected with Kotlin 1.4)


/**
* Expects that the subject of the assertion (a [ChronoLocalDateTime])
* is before the [expected] [String].
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add to the other KDoc

Suggested change
* is before the [expected] [String].
* is before the [expected] [LocalDateTime] given as [String] in (modified) ISO 8601 format.
*
* The string will be converted to a LocalDateTime according to ISO 8601 but with a slight deviation. The alternative notation (e.g. 20200401120001 instead of 2020-04-01T12:00:01) is not supported and we accept a date without time in which case 00:00:00 is used. Following the supported formats from the longest to the shortest:
* * yyyy-mm-ddThh:mm:ss.sss (up to 9 digits for nanoseconds)
* * yyyy-mm-ddThh:mm:ss
* * yyyy-mm-ddThh:mm
* * yyyy-mm-dd

@rkiselev
Copy link
Contributor Author

thanks, it works.

…stoll#481-chrono-local-date-time

# Conflicts:
#	apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateTimeAssertions.kt
#	apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ChronoLocalDateTimeAssertionSpec.kt
@rkiselev rkiselev changed the title 481 accept date and time as string in ISO 8601 format for ChronoLocalDateTime 2 [WIP] 481 accept date and time as string in ISO 8601 format for ChronoLocalDateTime 2 Aug 8, 2020
@rkiselev
Copy link
Contributor Author

rkiselev commented Aug 8, 2020

hi, @robstoll, could you please check my changes, I have finished implementation.

Copy link
Owner

@robstoll robstoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanksfor the changes. Following a few suggestions for improvement.

"2020-01-01T01:01:1" to "wrong string format",
"2020-01-01t01:01:01" to "wrong string format"
).forEach{(value, description) ->
run {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this (not necessary)

Suggested change
run {

).forEach{(value, description) ->
run {
val now = expect(LocalDateTime.now())
describe(description) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the description is always the same, I would move it outside of the forEach and turn the mapOf into a listOf. Instead I would use the value here.

run {
val now = expect(LocalDateTime.now())
describe(description) {
it("throws an DateTimeParseException") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the name of the function (also ain the other places)

Suggested change
it("throws an DateTimeParseException") {
it("isBefore -- throws an DateTimeParseException") {

}
}
it("doesn't throw any Error") {
expect {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove expect{...} as this creates an Expect of a lambda which is never executed. Alternatively you could use notToThrow to verify it (instead of toThrow) but we haven't use this so far and I prefer the shorter version

@robstoll robstoll merged commit ae4a36f into robstoll:#481-ChronoLocalDateTime-as-string Aug 19, 2020
@robstoll
Copy link
Owner

@rkiselev thanks for the update. I am going to adjust a few more things and add the infix API and then merge into master. Thanks for the endurance and your work 🙂 👍
Fancy to tackle the other related issues? I guess they should be easy now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants