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

🚧 Adopt the ‘to+infinitive’ Convention #714

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ch.tutteli.atrium.api.fluent.en_GB

import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic.creating.typeutils.IterableLike
import ch.tutteli.atrium.logic.*
import ch.tutteli.atrium.logic.creating.typeutils.IterableLike
import ch.tutteli.atrium.logic.utils.iterableLikeToIterable
import ch.tutteli.atrium.reporting.Reporter
import ch.tutteli.kbox.glue
Expand Down Expand Up @@ -30,22 +30,56 @@ fun <T> Expect<T>.notToBe(expected: T): Expect<T> = _logicAppend { notToBe(expec
/**
* Expects that the subject of the assertion is the same instance as [expected].
*
* Deprecated as atrium moves to a consistent ‘to + infinitive’ naming convention. Use [toBeTheSameAs] instead.
Copy link
Owner

Choose a reason for hiding this comment

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

Detail but more aligned with the readme:

Suggested change
* Deprecated as atrium moves to a consistent ‘to + infinitive’ naming convention. Use [toBeTheSameAs] instead.
* Deprecated as Atrium moves to a consistent ‘to + infinitive’ naming convention. Use [toBeTheSameAs] instead.

* This function will be removed in version 1.0.0. See
* [atrium-roadmap#93](https://github.com/robstoll/atrium-roadmap/issues/93) for details and to give feedback.
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*/
@Deprecated(
"Replaced by toBeTheSameAs. Will be removed with version 1.0.0",
robstoll marked this conversation as resolved.
Show resolved Hide resolved
ReplaceWith("this.toBeTheSameAs<T>(expected)")
) // TODO remove with 1.0.0
fun <T> Expect<T>.isSameAs(expected: T): Expect<T> = toBeTheSameAs(expected)
Copy link
Owner

Choose a reason for hiding this comment

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

@jGleitz IMO we should provide once again a script in order that users have a smooth migration experience. Do you see the draft release here? https://github.com/robstoll/atrium/releases/tag/untagged-c4eefbbdd8d22b72bc20

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you see the draft release

No, I get a 404 for that link.

Writing a script feels like duplicating what the @ReplaceWith annotations do anyway. Isn’t there any IntelliJ functionality to say ‘perform all migrations’?

Copy link
Owner

Choose a reason for hiding this comment

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

Not that I know of, you were able to choose Replace for all for a particular ReplaceWith but last time I wanted to use it I couldn't find the option. Moreover, from my experience, the applications of the ReplaceWith by Intellij are many times buggy and don't work as they should. I was always happy that I had the scripts. I'll put a draft of the release note into the wiki so that you could provide the replacements as well
Up to you if you want to help out or not. It's also fine if I collect/write down the replacements at the end of 0.16.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. I’ll prioritize work on my open pull requests, but will help on the script if I find the time.


/**
* Expects that the subject of `this` assertion is the same instance as [expected].
robstoll marked this conversation as resolved.
Show resolved Hide resolved
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.AnyAssertionSamples.isSameAs
* @return an [Expect] for the current subject of `this` assertion.
robstoll marked this conversation as resolved.
Show resolved Hide resolved
* @throws AssertionError if the subject of `this` assertion is not the same instance as [expected].
robstoll marked this conversation as resolved.
Show resolved Hide resolved
*
* @since 0.16.0
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.AnyAssertionSamples.toBeTheSameAs
*/
fun <T> Expect<T>.isSameAs(expected: T): Expect<T> = _logicAppend { isSameAs(expected) }
fun <T> Expect<T>.toBeTheSameAs(expected: T): Expect<T> = _logicAppend { toBeTheSameAs(expected) }

/**
* Expects that the subject of the assertion is not the same instance as [expected].
*
* Deprecated as atrium moves to a consistent ‘to + infinitive’ naming convention. Use [notToBeTheSameAs] instead.
* This function will be removed in version 1.0.0. See
* [atrium-roadmap#93](https://github.com/robstoll/atrium-roadmap/issues/93) for details and to give feedback.
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*/
@Deprecated(
"Replaced by notToBeTheSameAs. Will be removed with version 1.0.0",
ReplaceWith("this.notToBeTheSameAs<T>(expected)")
) // TODO remove with 1.0.0
fun <T> Expect<T>.isNotSameAs(expected: T): Expect<T> = notToBeTheSameAs(expected)

/**
* Expects that the subject of `this` assertion is not the same instance as [expected].
*
* @return an [Expect] for the current subject of `this` assertion.
* @throws AssertionError if the subject of `this` assertion is the same instance as [expected].
jGleitz marked this conversation as resolved.
Show resolved Hide resolved
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.AnyAssertionSamples.isNotSameAs
* @since 0.16.0
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.AnyAssertionSamples.notToBeTheSameAs
*/
fun <T> Expect<T>.isNotSameAs(expected: T): Expect<T> = _logicAppend { isNotSameAs(expected) }
fun <T> Expect<T>.notToBeTheSameAs(expected: T): Expect<T> = _logicAppend { notToBeTheSameAs(expected) }

/**
* Expects that the subject of the assertion is either `null` in case [assertionCreatorOrNull]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package ch.tutteli.atrium.api.fluent.en_GB

import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.specs.feature0
import ch.tutteli.atrium.specs.fun1
import ch.tutteli.atrium.specs.fun2
import ch.tutteli.atrium.specs.withFeatureSuffix
import ch.tutteli.atrium.specs.withNullableSuffix
import ch.tutteli.atrium.specs.*
import kotlin.reflect.KFunction2
import kotlin.reflect.KProperty1

Expand All @@ -18,14 +14,14 @@ class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec(
fun1(Expect<DataClass>::notToBe),
fun1(Expect<Int?>::notToBe).withNullableSuffix(),
fun1(Expect<DataClass?>::notToBe).withNullableSuffix(),
fun1(Expect<Int>::isSameAs),
fun1(Expect<DataClass>::isSameAs),
fun1(Expect<Int?>::isSameAs).withNullableSuffix(),
fun1(Expect<DataClass?>::isSameAs).withNullableSuffix(),
fun1(Expect<Int>::isNotSameAs),
fun1(Expect<DataClass>::isNotSameAs),
fun1(Expect<Int?>::isNotSameAs).withNullableSuffix(),
fun1(Expect<DataClass?>::isNotSameAs).withNullableSuffix(),
fun1(Expect<Int>::toBeTheSameAs),
fun1(Expect<DataClass>::toBeTheSameAs),
fun1(Expect<Int?>::toBeTheSameAs).withNullableSuffix(),
fun1(Expect<DataClass?>::toBeTheSameAs).withNullableSuffix(),
fun1(Expect<Int>::notToBeTheSameAs),
fun1(Expect<DataClass>::notToBeTheSameAs),
fun1(Expect<Int?>::notToBeTheSameAs).withNullableSuffix(),
fun1(Expect<DataClass?>::notToBeTheSameAs).withNullableSuffix(),
fun2(Expect<Int>::isNoneOf),
fun2(Expect<DataClass>::isNoneOf),
fun2(Expect<Int?>::isNoneOf).withNullableSuffix(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ class AnyAssertionSamples {
}

@Test
fun isSameAs() {
fun toBeTheSameAs() {
val list = listOf(3)
expect(list).isSameAs(list)
expect(list).toBeTheSameAs(list)

fails {
// fails because isSameAs is based on identity, use toBe for equality
expect(listOf(3)).isSameAs(listOf(3))
// fails because toBeTheSameAs is based on identity, use toBe for equality
expect(listOf(3)).toBeTheSameAs(listOf(3))
}
}

@Test
fun isNotSameAs() {
// holds because isSameAs is based on identity, use notToBe for equality
expect(listOf(2)).isNotSameAs(listOf(2))
fun notToBeTheSameAs() {
// holds because notToBeTheSameAs is based on identity, use notToBe for equality
expect(listOf(2)).notToBeTheSameAs(listOf(2))

fails {
val list = listOf(3)
expect(list).isNotSameAs(list)
expect(list).notToBeTheSameAs(list)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ infix fun <T> Expect<T>.notToBe(expected: T): Expect<T> = _logicAppend { notToBe
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*/
infix fun <T> Expect<T>.isSameAs(expected: T): Expect<T> = _logicAppend { isSameAs(expected) }
infix fun <T> Expect<T>.isSameAs(expected: T): Expect<T> = _logicAppend { toBeTheSameAs(expected) }

/**
* Expects that the subject of the assertion is not the same instance as [expected].
*
* @return An [Expect] for the current subject of the assertion.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*/
infix fun <T> Expect<T>.isNotSameAs(expected: T): Expect<T> = _logicAppend { isNotSameAs(expected) }
infix fun <T> Expect<T>.isNotSameAs(expected: T): Expect<T> = _logicAppend { notToBeTheSameAs(expected) }

/**
* Expects that the subject of the assertion is either `null` in case [assertionCreatorOrNull]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import ch.tutteli.atrium.logic.impl.DefaultAnyAssertions

fun <T> AssertionContainer<T>.toBe(expected: T): Assertion = impl.toBe(this, expected)
fun <T> AssertionContainer<T>.notToBe(expected: T): Assertion = impl.notToBe(this, expected)
fun <T> AssertionContainer<T>.isSameAs(expected: T): Assertion = impl.isSameAs(this, expected)
fun <T> AssertionContainer<T>.isNotSameAs(expected: T): Assertion = impl.isNotSameAs(this, expected)
fun <T> AssertionContainer<T>.toBeTheSameAs(expected: T): Assertion = impl.toBeTheSameAs(this, expected)
fun <T> AssertionContainer<T>.notToBeTheSameAs(expected: T): Assertion = impl.notToBeTheSameAs(this, expected)

fun <T : Any?> AssertionContainer<T>.toBeNull(): Assertion = impl.toBeNull(this)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import kotlin.reflect.KClass
interface AnyAssertions {
fun <T> toBe(container: AssertionContainer<T>, expected: T): Assertion
fun <T> notToBe(container: AssertionContainer<T>, expected: T): Assertion
fun <T> isSameAs(container: AssertionContainer<T>, expected: T): Assertion
fun <T> isNotSameAs(container: AssertionContainer<T>, expected: T): Assertion
fun <T> toBeTheSameAs(container: AssertionContainer<T>, expected: T): Assertion
fun <T> notToBeTheSameAs(container: AssertionContainer<T>, expected: T): Assertion

fun <T : Any?> toBeNull(container: AssertionContainer<T>): Assertion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class DefaultAnyAssertions : AnyAssertions {
override fun <T> notToBe(container: AssertionContainer<T>, expected: T): Assertion =
container.createDescriptiveAssertion(NOT_TO_BE, expected) { it != expected }

override fun <T> isSameAs(container: AssertionContainer<T>, expected: T): Assertion =
override fun <T> toBeTheSameAs(container: AssertionContainer<T>, expected: T): Assertion =
container.createDescriptiveAssertion(IS_SAME, expected) { it === expected }

override fun <T> isNotSameAs(container: AssertionContainer<T>, expected: T): Assertion =
override fun <T> notToBeTheSameAs(container: AssertionContainer<T>, expected: T): Assertion =
container.createDescriptiveAssertion(IS_NOT_SAME, expected) { it !== expected }

override fun <T> toBeNull(container: AssertionContainer<T>): Assertion =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object IoResultSpec : Spek({
val result = testPath.runCatchingIo { throw testException }
expect(result).isA<Failure> {
feature(IoResult<*>::path).toBe(testPath)
feature(Failure::exception).isSameAs(testException)
feature(Failure::exception).toBeTheSameAs(testException)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ object SymbolicLinkResolvingSpec : Spek({
val file = tempFolder.newFile("testFile").toRealPath()

val resultAssertion = explainForResolvedLink(file, resolvedPathConsumer)
expect(resultAssertion).isSameAs(testAssertion)
expect(resultAssertion).toBeTheSameAs(testAssertion)
}

it("adds an explanation for one symbolic link") {
Expand All @@ -145,7 +145,7 @@ object SymbolicLinkResolvingSpec : Spek({
expect(resultAssertion).isA<AssertionGroup>()
.feature { p(it::assertions) }.containsExactly(
{ describesLink(link, target) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}

Expand All @@ -160,7 +160,7 @@ object SymbolicLinkResolvingSpec : Spek({
.feature { p(it::assertions) }.containsExactly(
{ describesLink(start, toNowhere) },
{ describesLink(toNowhere, nowhere) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}

Expand All @@ -183,7 +183,7 @@ object SymbolicLinkResolvingSpec : Spek({
{ describesLink(linkToInnerLink, innerLinkInGrandparentLink) },
{ describesLink(grandparentLink, grandparent) },
{ describesLink(innerLink, target) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}

Expand All @@ -199,7 +199,7 @@ object SymbolicLinkResolvingSpec : Spek({
{ describesLink(barLink, testDir) },
{ describesLink(barLink, testDir) },
{ describesLink(barLink, testDir) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}
}
Expand All @@ -216,7 +216,7 @@ object SymbolicLinkResolvingSpec : Spek({
{ describesLink(a, b) },
{ describesLink(b, a) },
{ describesLinkLoop(a, b, a) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}

Expand All @@ -232,7 +232,7 @@ object SymbolicLinkResolvingSpec : Spek({
{ describesLink(link, fooLink.resolve("link")) },
{ describesLink(fooLink, foo) },
{ describesLinkLoop(link, link) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}

Expand Down Expand Up @@ -260,7 +260,7 @@ object SymbolicLinkResolvingSpec : Spek({
{ describesLink(b, c) },
{ describesLink(c, a) },
{ describesLinkLoop(a, b, c, a) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object IoResultSpec : Spek({
val result = testPath.runCatchingIo { throw testException }
expect(result).isA<Failure> {
feature(IoResult<*>::path).toBe(testPath)
feature(Failure::exception).isSameAs(testException)
feature(Failure::exception).toBeTheSameAs(testException)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ object SymbolicLinkResolvingSpec : Spek({
val file = tempFolder.newFile("testFile").toRealPath()

val resultAssertion = explainForResolvedLink(file, resolvedPathConsumer)
expect(resultAssertion).isSameAs(testAssertion)
expect(resultAssertion).toBeTheSameAs(testAssertion)
}

it("adds an explanation for one symbolic link") {
Expand All @@ -149,7 +149,7 @@ object SymbolicLinkResolvingSpec : Spek({
expect(resultAssertion).isA<AssertionGroup>()
.feature { p(it::assertions) }.containsExactly(
{ describesLink(link, target) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}

Expand All @@ -164,7 +164,7 @@ object SymbolicLinkResolvingSpec : Spek({
.feature { p(it::assertions) }.containsExactly(
{ describesLink(start, toNowhere) },
{ describesLink(toNowhere, nowhere) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}

Expand All @@ -187,7 +187,7 @@ object SymbolicLinkResolvingSpec : Spek({
{ describesLink(linkToInnerLink, innerLinkInGrandparentLink) },
{ describesLink(grandparentLink, grandparent) },
{ describesLink(innerLink, target) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}

Expand All @@ -203,7 +203,7 @@ object SymbolicLinkResolvingSpec : Spek({
{ describesLink(barLink, testDir) },
{ describesLink(barLink, testDir) },
{ describesLink(barLink, testDir) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}
}
Expand All @@ -220,7 +220,7 @@ object SymbolicLinkResolvingSpec : Spek({
{ describesLink(a, b) },
{ describesLink(b, a) },
{ describesLinkLoop(a, b, a) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}

Expand All @@ -236,7 +236,7 @@ object SymbolicLinkResolvingSpec : Spek({
{ describesLink(link, fooLink.resolve("link")) },
{ describesLink(fooLink, foo) },
{ describesLinkLoop(link, link) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}

Expand Down Expand Up @@ -264,7 +264,7 @@ object SymbolicLinkResolvingSpec : Spek({
{ describesLink(b, c) },
{ describesLink(c, a) },
{ describesLinkLoop(a, b, c, a) },
{ isSameAs(testAssertion) }
{ toBeTheSameAs(testAssertion) }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class FeatureAssertionCheckerSpec(
it("copies the assertion") {
assertions.clear()
expect(captured).isA<AssertionGroup> {
feature { f(it::assertions) }.hasSize(1).and.isNotSameAs(assertions)
feature { f(it::assertions) }.hasSize(1).and.notToBeTheSameAs(assertions)
}
}
}
Expand Down
Loading