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

Allow to call isInstanceOf and equivalent assertions on nullable types #127

Merged
merged 3 commits into from
Dec 2, 2018
Merged

Allow to call isInstanceOf and equivalent assertions on nullable types #127

merged 3 commits into from
Dec 2, 2018

Conversation

jcornaz
Copy link
Contributor

@jcornaz jcornaz commented Dec 2, 2018

Description

It seemed odd to me that fun Any?.shouldBeInstanceOf(className: KClass<*>) was accepting nullable receiver but fun <reified T : Any> Any.shouldBeInstanceOf(): T not.

This PR make possible to call the following functions on a nullable type:

  • shouldBeInstanceOf
  • shouldNotBeInstanceOf
  • should be instance of
  • should not be instance of
  • shouldHaveTheSameClassAs
  • shouldNotHaveTheSameClassAs

I added tests to assert the expected behavior when called on a null reference.

Checklist

  • I've added my name to the AUTHORS file, if it wasn't already present.

@MarkusAmshove MarkusAmshove merged commit 5c906fe into MarkusAmshove:master Dec 2, 2018
@MarkusAmshove
Copy link
Owner

Oh didn't catch that when implementing, thanks for the PR 👍

@jcornaz jcornaz deleted the feature/improve-isInstanceOf branch December 2, 2018 15:28
@MarkusAmshove
Copy link
Owner

This is part of the just released v1.44

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