Skip to content

Commit

Permalink
Merge pull request #1817 from robstoll/improve/emptyList
Browse files Browse the repository at this point in the history
use emptyList() instead of listOf() to make it clear it is intentional
  • Loading branch information
robstoll committed Aug 20, 2024
2 parents 46a85c7 + 0e4b199 commit ce5304d
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ch.tutteli.atrium.core.polyfills.format
*/
class UsingDefaultTranslator(
primaryLocale: Locale = getDefaultLocale()
) : ArgumentsSupportingTranslator(primaryLocale, listOf()) {
) : ArgumentsSupportingTranslator(primaryLocale, emptyList()) {

override fun translateWithoutArgs(translatable: Translatable) = translatable.getDefault()
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TextNextLineAssertionPairFormatterSpec : AssertionFormatterSpecBase({
val newParameterObject = parameterObject.createChildWithNewPrefix(bulletPoint)
val assertionGroup = assertionBuilder.root
.withDescriptionAndRepresentation(name, subject)
.withAssertions(listOf())
.withAssertions(emptyList())
.build()
testee.formatGroupHeader(parameterObject, assertionGroup, newParameterObject)
expect(sb.toString()) toEqual "$name:$lineSeparator$indentBulletPoint$subject"
Expand All @@ -42,7 +42,7 @@ class TextNextLineAssertionPairFormatterSpec : AssertionFormatterSpecBase({
it("does not append a new line if the subject is ${Text::class.simpleName}${Text.Companion::EMPTY.name}") {
val assertionGroup = assertionBuilder.root
.withDescriptionAndEmptyRepresentation(name)
.withAssertions(listOf())
.withAssertions(emptyList())
.build()
val newParameterObject = parameterObject.createChildWithNewPrefix(bulletPoint)
testee.formatGroupHeader(parameterObject, assertionGroup, newParameterObject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TranslatableWithArgsSpec : Spek({
context("for a translatable without args") {
it("no arguments given; throws") {
expect {
TranslatableWithArgs(HELLO, listOf())
TranslatableWithArgs(HELLO, emptyList())
}.toThrow<IllegalArgumentException> {
its messageToContain values(
"No arguments specified"
Expand All @@ -33,7 +33,7 @@ class TranslatableWithArgsSpec : Spek({
context("for a translatable with 1 arg") {
it("no arguments given; throws") {
expect {
TranslatableWithArgs(WITH_1_ARG, listOf())
TranslatableWithArgs(WITH_1_ARG, emptyList())
}.toThrow<IllegalArgumentException> {
its messageToContain values(
"No arguments specified"
Expand All @@ -59,7 +59,7 @@ class TranslatableWithArgsSpec : Spek({
context("for a translatable with 2 args") {
it("no arguments given; throws") {
expect {
TranslatableWithArgs(WITH_2_ARGS, listOf())
TranslatableWithArgs(WITH_2_ARGS, emptyList())
}.toThrow<IllegalArgumentException> {
its messageToContain values(
"No arguments specified"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ class AdjustStackSpec : Spek({
MultiAtriumErrorAdjuster(
c.build<RemoveRunnerFromAtriumError>(),
c.build<RemoveAtriumFromAtriumError>(),
listOf()
emptyList()
)
},
"combine remove atrium adjuster and remove runner adjuster" to
{ c ->
MultiAtriumErrorAdjuster(
c.build<RemoveAtriumFromAtriumError>(),
c.build<RemoveRunnerFromAtriumError>(),
listOf()
emptyList()
)
},
"combine noop adjust, remove atrium adjuster and remove runner adjuster" to
Expand Down
2 changes: 1 addition & 1 deletion gradle/build-logic/dev/src/main/kotlin/generation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fun Project.registerGenerateLogicTaskForPackage(

val typeIdentifier = Regex(""" *fun (?<generics><.+?> )?(?<funcName>$identifier)\((?:$newLineAndIndent)?$identifier *: (?<type>$identifier(?:\.$identifier)*<.+>)""")
val patterns = (6 downTo 0).map { numOfParams ->
val params = if (numOfParams > 0) (1..numOfParams).toList() else listOf()
val params = if (numOfParams > 0) (1..numOfParams).toList() else emptyList()
Triple(
Regex(typeIdentifier.pattern + params.joinToString("") { paramNumber -> parameter(paramNumber).pattern } + returnType.pattern),
"""fun ${"$"}{generics}${"$"}{type}\.${"$"}{funcName}\(""" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DefaultFeatureExtractor : FeatureExtractor {
})

val subAssertions = maybeSubAssertions.fold({
listOf()
emptyList()
}) { assertionCreator ->
// TODO 1.3.0: factor out in common pattern, should not be the concern of the average expectation
// function writer
Expand Down Expand Up @@ -85,7 +85,7 @@ class DefaultFeatureExtractor : FeatureExtractor {
// shows why the extraction went wrong (e.g. index out of bound)
container.append(fixedClaimGroup)
})
createFeatureExpect(None, listOf())
createFeatureExpect(None, emptyList())
},
{ subject ->
createFeatureExpect(Some(subject), maybeSubAssertions.fold({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract class EmptyNameAndSubjectAssertionGroupFormatterSpec<T : AssertionGroup
it("does not include ${AssertionGroup::description.name} nor ${AssertionGroup::representation.name}") {
val assertionGroup = assertionBuilder.customType(type)
.withDescriptionAndRepresentation(TestDescription.TEST_NAME, testSubject)
.withAssertions(listOf())
.withAssertions(emptyList())
.build()
val parameterObject = AssertionFormatterParameterObject.new(
sb,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ abstract class SingleAssertionGroupTypeFormatterSpec<out T : AssertionGroupType>
}
val unsupportedAssertionGroup = assertionBuilder.customType(object : AssertionGroupType {})
.withDescriptionAndRepresentation(Untranslatable.EMPTY, 1)
.withAssertions(listOf())
.withAssertions(emptyList())
.build()
val supportedAssertionGroupWithAnonymousType = assertionBuilder.customType(supportedAnonymousAssertionGroupType)
.withDescriptionAndRepresentation(Untranslatable.EMPTY, 1)
.withAssertions(listOf())
.withAssertions(emptyList())
.build()
val supportedAnonymousAssertionGroupWithAnonymousType = object : AssertionGroup {
override val description = Untranslatable("test")
Expand All @@ -58,7 +58,7 @@ abstract class SingleAssertionGroupTypeFormatterSpec<out T : AssertionGroupType>
}
val supportedAssertionGroup = assertionBuilder.customType(supportedAssertionGroupType)
.withDescriptionAndRepresentation(Untranslatable.EMPTY, 1)
.withAssertions(listOf())
.withAssertions(emptyList())
.build()
val supportedAnonymousAssertionGroup = object : AssertionGroup {
override val description = Untranslatable("test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class TextIndentBasedAssertionGroupFormatterSpec<T : AssertionGroupType
f(
it::canFormat, assertionBuilder.customType(anonymousAssertionGroupType)
.withDescriptionAndRepresentation(Untranslatable.EMPTY, 1)
.withAssertions(listOf())
.withAssertions(emptyList())
.build()
)
}.toEqual(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class TextSummaryAssertionGroupFormatterSpec(
val result = testee.canFormat(
assertionBuilder.customType(object : SummaryAssertionGroupType {})
.withDescriptionAndRepresentation(Untranslatable.EMPTY, 1)
.withAssertions(listOf())
.withAssertions(emptyList())
.build()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ abstract class TextFeatureAssertionGroupFormatterSpec(
assertionBuilder
.customType(object : FeatureAssertionGroupType {})
.withDescriptionAndRepresentation(Untranslatable.EMPTY, 1)
.withAssertions(listOf())
.withAssertions(emptyList())
.build()
)
expect(result).toEqual(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ abstract class TextListBasedAssertionGroupFormatterSpec<T : AssertionGroupType>(
val result = testee.canFormat(
assertionBuilder.customType(anonymousAssertionGroupType)
.withDescriptionAndRepresentation(Untranslatable.EMPTY, 1)
.withAssertions(listOf())
.withAssertions(emptyList())
.build()
)
expect(result).toEqual(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object OwnExpectationFunctionsSpec : Spek({
}

test("ex-own-compose-3") {
expect(Person("Susanne", "Whitley", 43, listOf()))
expect(Person("Susanne", "Whitley", 43, emptyList()))
.toHaveNumberOfChildren(2)
}

Expand All @@ -89,7 +89,7 @@ object OwnExpectationFunctionsSpec : Spek({
//snippet-own-compose-4-insert
}
test("ex-own-compose-4") {
expect(Person("Susanne", "Whitley", 43, listOf()))
expect(Person("Susanne", "Whitley", 43, emptyList()))
.toHaveAdultChildren()
}

Expand All @@ -99,7 +99,7 @@ object OwnExpectationFunctionsSpec : Spek({
}
//@formatter:off
test("ex-own-compose-5"){
expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, listOf()))))
expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, emptyList()))))
.children { // using the fun -> expectation-group, ergo sub expectations don't fail fast
toHaveElementsAndNone {
feature { f(it::firstName) }.toStartWith("Ro")
Expand Down

0 comments on commit ce5304d

Please sign in to comment.