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

Use less ambiguous string representations in equality errors #368

Merged
merged 2 commits into from
Jun 25, 2018

Conversation

ajalt
Copy link
Contributor

@ajalt ajalt commented Jun 25, 2018

toString produces ambiguous results for a number of common types. For example:

"1" shouldBe 1L
expected: 1 but was: 1

or

listOf(1f) shouldBe listOf(1.0)
expected: [1.0] but was: [1.0]

etc.

This PR formats objects the way their literal values appear in code.

e.g.

expected: "1" but was: 1L

Now that the representations are less ambiguous, we can use the JUnit assertions for all types.

ajalt added 2 commits June 25, 2018 10:46
`toString` produces ambiguous results for a number of common types. For example:

```kotlin
"1" shouldBe 1L
```

```
expected: 1 but was: 1
```

or

```kotlin
listOf(1f) shouldBe listOf(1.0)
```

```
expected: [1.0] but was: [1.0]
```

etc.

This PR formats objects the way their literal values appear in code.

e.g.

```
expected: "1" but was: 1L
```

Now that the representations are less ambiguous, we can use the JUnit assertions for all types.
@sksamuel
Copy link
Member

Awesome!

@sksamuel sksamuel merged commit b02f4e1 into kotest:master Jun 25, 2018
@ajalt ajalt deleted the string-repr branch June 25, 2018 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants