-
Notifications
You must be signed in to change notification settings - Fork 89
Description
prop
isn't short for property
–at least not in the Kotlin-sense. Its KFunction
and lambda-accepting overloads let it operate on more than just Kotlin properties. It may be short for "property" in the general sense, but that's then confusing against the Kotlin concept and abbreviations are generally frowned upon in API signatures.
extracting
is prop
projected over a collection.
suspendCall
is the lambda-accepting prop
but suspend
able.
These are all the same thing, and it would be cool if they had a unified naming convention.
I don't have any perfect naming proposals yet but I've been sitting on filing this issue for months now so I'm firing it off in the hopes others can help.
I came up with two ideas:
Center around the verb "have":
-
Assert that some user has (a) name (that) is equal to "Alice":
assertThat(someUser).has(User::name).isEqualTo("Alice") assertThat(someUser).has("name", { it.name() }).isEqualTo("Alice")
-
Assert that all users each has (a) name (that) is equal to "Alice", "Bob", "Eve":
assertThat(allUsers) .eachHas(User::name) .isEqualTo(listOf("Alice", "Bob", "Eve"))
Is this
eachHave
? Tempted to bend grammar even if it is for consistency. -
Assert that some user has (a) DB name (that) is equal to "Alice":
assertThat(someUser).has("name", { it.dbName() }).isEqualTo("Alice")
Can we pull this off, where the signature matches? Can the main one be
inline
with some API changes maybe?
Alternatively, lean into map
whose semantics are hopefully known from its available on Iterable
s, Flow
s, Rx, other languages, etc.
-
Assert that some user map(ped to a) name (that) is equal to "Alice":
assertThat(someUser).map(User::name).isEqualTo("Alice") assertThat(someUser).map("name", { it.name() }).isEqualTo("Alice")
-
Assert that all users map(ped to their) name (that) is equal to "Alice", "Bob", "Eve":
assertThat(allUsers) .map(User::name) .isEqualTo(listOf("Alice", "Bob", "Eve"))
Is this
eachHave
? Tempted to bend grammar even if it is for consistency. -
Assert that some user map(ped to a) DB name (that) is equal to "Alice":
assertThat(someUser).map("name", { it.dbName() }).isEqualTo("Alice")
Thoughts?
(Also whoops cmd+enter too soon)