-
-
Notifications
You must be signed in to change notification settings - Fork 229
add CharSequence.length feature extractor (fluent/infix) #2106
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
base: main
Are you sure you want to change the base?
add CharSequence.length feature extractor (fluent/infix) #2106
Conversation
|
Can you check this PR? |
robstoll
left a comment
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.
@joonseolee looks already very good. Just an addition and we are good to merge
...ommonMain/kotlin/ch/tutteli/atrium/specs/integration/AbstractCharSequenceExpectationsTest.kt
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2106 +/- ##
============================================
- Coverage 91.31% 91.30% -0.01%
Complexity 125 125
============================================
Files 467 468 +1
Lines 4776 4783 +7
Branches 242 242
============================================
+ Hits 4361 4367 +6
Misses 366 366
- Partials 49 50 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5bc99b8 to
ab01751
Compare
...ent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceExpectationsTest.kt
Outdated
Show resolved
Hide resolved
...ent/src/commonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceExpectationsTest.kt
Show resolved
Hide resolved
...-fluent/src/commonMain/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceExpectations.kt
Outdated
Show resolved
Hide resolved
...mmonTest/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/CharSequenceExpectationSamples.kt
Outdated
Show resolved
Hide resolved
| public static final fun getLength (Lch/tutteli/atrium/creating/Expect;)Lch/tutteli/atrium/creating/Expect; | ||
| public static final fun length (Lch/tutteli/atrium/creating/Expect;Lkotlin/jvm/functions/Function1;)Lch/tutteli/atrium/creating/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.
please re-run ./gradlew apiDump & KOTLIN_VERSION=1.9 ./gradlew apiDump once you have moved the code as outlined above
...pi-infix/src/commonMain/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceExpectations.kt
Show resolved
Hide resolved
| ("length" to Companion::lengthFeature).withFeatureSuffix(), | ||
| "length" to Companion::length | ||
| ) { | ||
| companion object { | ||
| private fun toBeEmpty(expect: Expect<CharSequence>) = expect toBe empty | ||
| private fun notToBeEmpty(expect: Expect<CharSequence>) = expect notToBe empty | ||
| private fun notToBeBlank(expect: Expect<CharSequence>) = expect notToBe blank | ||
| private fun lengthFeature(expect: Expect<CharSequence>): Expect<Int> = | ||
| expect.length | ||
|
|
||
| private fun length( | ||
| expect: Expect<CharSequence>, | ||
| assertionCreator: Expect<Int>.() -> Unit | ||
| ): Expect<Int> = expect.length.apply(assertionCreator) |
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.
same same revert to what you had previously
| a1 = a1 toMatch Regex(".+Robert") | ||
| a1 = a1 notToMatch Regex("a") | ||
|
|
||
| a1 = a1 length { it toEqual 23 } |
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.
val l1 =...
...ommonTest/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/CharSequenceExpectationSamples.kt
Outdated
Show resolved
Hide resolved
...ommonMain/kotlin/ch/tutteli/atrium/specs/integration/AbstractCharSequenceExpectationsTest.kt
Show resolved
Hide resolved
...ommonMain/kotlin/ch/tutteli/atrium/specs/integration/AbstractCharSequenceExpectationsTest.kt
Show resolved
Hide resolved
...ommonMain/kotlin/ch/tutteli/atrium/specs/integration/AbstractCharSequenceExpectationsTest.kt
Show resolved
Hide resolved
| toMatchSpec.forSubjectLessTest(Regex("")), | ||
| notToMatchSpec.forSubjectLessTest(Regex("")) | ||
| ) | ||
|
|
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.
also something I overlooked 🙈
Can you please add
@TestFactory
fun expectationCreatorTest() = expectationCreatorTestFactory(
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.
@robstoll - Do you mean you want a block for the expectationCreatorTest with the same logic as as the subjectLessTest?
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.
Each expectation function which expects an expectationCreator-lambda (i.e. length { ... } should have an
@TestFactory
fun expectationCreatorTest() = expectationCreatorTestFactory(
)
test. The test checks that an empty lambda causes an error.
I see that we should rename it to expectationCreatorEmptyTest but that's something we can do in a subsequent PR for all cases. Take a look at other usages of expectationCreatorTestFactory. Hope that helps
...ommonMain/kotlin/ch/tutteli/atrium/specs/integration/AbstractCharSequenceExpectationsTest.kt
Show resolved
Hide resolved
|
@joonseolee do you intend to finish it or shall we take over? |
|
@TomerPacific would you like to take over? Something else than a migration for a change. |
|
But I can't make any promises |
|
@robstoll - I am having compile issues in the ExpectationsTest classes (infix & fluent), but I believe these are due to the method definitions in the abstract class. Let me know what needs to be changed. |
|
@TomerPacific nothing needs to be changed there, that's all good. The problem is that you create a class CharSequenceFeatureExtractors in fluent/infix. Remove it, we want top-level functions (see other .kt files in the API) |
...nt/src/commonMain/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceFeatureExtractors.kt
Outdated
Show resolved
Hide resolved
Regarding this, I did not create the class in infix and it seems to be in the right syntax. I have looked at the previous commit and there is no change to the lines with the Companion reference, but I don't think those should remain. |
|
@TomerPacific regarding the infix-api, the following should work: No need for the Companion, but you need to fix the constructor of AbstractCharSequenceExpectationsTest. Currently you still have: but as you pointed out here #2106 (comment), lengthSpec needs to be Fun1 |
|
@robstoll - Been a bit busy this week. Hopefully I'll have time this weekend. |

Summary
Expect<CharSequence>.lengthfeature extractor for fluent and infix APIs.Related Issue
I confirm that I have read the Contributor Agreements v1.0, agree to be bound on them and confirm that my contribution is compliant.