-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
481 accept date and time as string in ISO 8601 format for ChronoLocalDateTime 2 #552
Conversation
# 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 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. |
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 |
There was a problem hiding this 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]. |
There was a problem hiding this comment.
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
* 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 |
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
hi, @robstoll, could you please check my changes, I have finished implementation. |
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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)
run { | |
).forEach{(value, description) -> | ||
run { | ||
val now = expect(LocalDateTime.now()) | ||
describe(description) { |
There was a problem hiding this comment.
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") { |
There was a problem hiding this comment.
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)
it("throws an DateTimeParseException") { | |
it("isBefore -- throws an DateTimeParseException") { |
} | ||
} | ||
it("doesn't throw any Error") { | ||
expect { |
There was a problem hiding this comment.
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
@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 🙂 👍 |
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.