Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jaliss
Copy link
Contributor

@jaliss jaliss commented Sep 21, 2019

No description provided.


test.foldCauseM(
_.untraced match {
case Cause.Fail(TestFailure.Runtime(Traced(e, _))) if p.run(e).isSuccess =>
Copy link
Member

Choose a reason for hiding this comment

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

untraced removes all inner Traced so this shouldn't be needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from what I tested I had to get rid of it before I could match things.

ZIO.succeed(TestSuccess.Succeeded(BoolAlgebra.unit))

case other => {
println(s"other = $other")
Copy link
Member

Choose a reason for hiding this comment

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

You can remove this one

@adamgfraser
Copy link
Contributor

@ghostdogpr We are going to change the signature of this to take an Assertion[TestFailure[E]] which should let us remove most of this code and let the caller specify what subtypes of TestFailure they are accepting.

@ghostdogpr
Copy link
Member

ghostdogpr commented Sep 22, 2019

@adamgfraser ah ok that makes sense 👍

/**
* Makes a new assertion that verifies a TestFailure matches a given failure
*/
final def testFails[E](failure: E): Assertion[TestFailure[E]] = {
Copy link
Member

Choose a reason for hiding this comment

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

maybe failsWith? @adamgfraser wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can simplify this. I am reviewing now.

Copy link
Contributor

@adamgfraser adamgfraser left a comment

Choose a reason for hiding this comment

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

Almost there! Just a few changes

else BoolAlgebra.failure(AssertionValue(self, actual))
}

final def isInstance[A](reference: A): Assertion[Any] =
Copy link
Contributor

Choose a reason for hiding this comment

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

I would take this out and use isSubType in your test.

}

/**
* An aspect that makes a test succeed if it fails for any cause.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to update this a bit because it makes a test that failed for any reason into a success, it doesn't have to be because the test failed with a Cause. It could have just failed with an AssertionFailure. Also clarify that it makes a previously successful test into a failure.

val failure: PerTest[Nothing, Any, Nothing, Any, Unit, Unit] = failure(Assertion.anything)

/**
* An aspect that makes a test succeed if it fails for a given cause.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

def perTest[R >: Nothing <: Any, E >: Nothing <: E0, S >: Unit <: Unit](
test: ZIO[R, TestFailure[E], TestSuccess[S]]
): ZIO[R, TestFailure[E], TestSuccess[S]] = {
def fail(value: TestFailure[E]) = ZIO.fail(
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can inline these definitions into test.foldM since they are each only used once?

Copy link
Contributor

@adamgfraser adamgfraser left a comment

Choose a reason for hiding this comment

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

Looks great! Will merge when it goes green.

@adamgfraser adamgfraser merged commit cc17b6c into zio:master Sep 22, 2019
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.

3 participants