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

Skip to content

Conversation

@dkarlinsky
Copy link
Contributor

@dkarlinsky dkarlinsky commented Nov 10, 2019

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.

This is fantastic! Way to rip through in a day something that had been hanging out there for months! Couple of comments below but looks great.

@@ -1,767 +1,643 @@
package zio
Copy link
Contributor

Choose a reason for hiding this comment

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

We should move this to the shared folder so these tests run on both the JVM and ScalaJS. It doesn't look like any of them involve blocking effects that wouldn't be available cross-platform. I think it was just labeled this way for historical reasons because not all of the tests had been migrated previously. Ideally we would make these tests part of the existing ZIOSpec.scala file though we may need to split it if the file length gets too long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what's a good way to merge it into ZIOSpec.
Right now, it's just a pile of tests with very little grouping by topic/area.
Just dumping everything at end, doesn't sound like a great idea :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps this should be a separate issue

Copy link
Contributor

Choose a reason for hiding this comment

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

They were originally part of the same file and then got split up in #1947 when some of the tests were migrated, so maybe we can organize it similarly to the original version?

Copy link
Contributor Author

@dkarlinsky dkarlinsky Nov 11, 2019

Choose a reason for hiding this comment

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

Ok, but can we merge this PR and first?
Because I keep seeing changes to ZIOSpecJvm in master...
BTW, I'm not sure how to do what you did in #2210 in ZTest.
(or do I need to change anything? I'm not getting TestClock warnings)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. Let's get this merged.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you resolve the merge conflict? I think you can just use the TestClock in the environment.

case (((a, b), c), d) => f(a, b, c, d)
}

implicit class ZioOfTestResultOps[R, E](val res: ZIO[R, E, TestResult]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we take this out? We have an open issue for the same problem you're dealing with in #1888 and do want to do something about it, but if we do something want to support all the operators and do so in a way that works for all combinations of assert and assertM. Not sure if implicit syntax is the right way to do this. If we make assertions effectual as I am working on in #2182 this problem will solve itself. In the meantime you can do something like:

  for {
    partial <- assertM(partialParse, succeeds(equalTo(List.empty[Int])))
    full    <- assertM(fullParse, succeeds(equalTo(List(123, 4))))
  } yield partial && full
  for {
    partial <- partialParse
    full    <- fullParse
  } yield assert(partial, succeeds(equalTo(List.empty[Int]))) &&
    assert(full, succeeds(equalTo(List(123, 4))))

Copy link
Contributor Author

@dkarlinsky dkarlinsky Nov 11, 2019

Choose a reason for hiding this comment

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

I've used this operator a lot in this test, so I moved it into the helper object for the Spec, for now

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea.

@dkarlinsky
Copy link
Contributor Author

dkarlinsky commented Nov 11, 2019 via email

@adamgfraser
Copy link
Contributor

Yes, you shouldn't have to create it anymore.

t5: For f: Int => String: `IO.bimap(f, identity)` maps an IO[Int, String] into an IO[String, String]
@adamgfraser adamgfraser merged commit e995631 into zio:master Nov 12, 2019
@dkarlinsky dkarlinsky deleted the 1647-ziospecjvm branch November 12, 2019 18:36
Twizty pushed a commit to Twizty/zio that referenced this pull request Nov 13, 2019
* t1: IO.foreach` returns the list of results

* t2: IO.foreach` both evaluates effects and returns the list of Ints in the same order

* t3: `IO.foreach` fails with a NumberFormatException exception

* t4: `IO.foreachPar` returns the list of Ints in the same order
t5: For f: Int => String: `IO.bimap(f, identity)` maps an IO[Int, String] into an IO[String, String]

* t6: IO.collectAllPar` returns the list in the same order

* t7: `IO.forkAll` returns the list of Ints in the same order

* t8: `IO.collectAllParN` returns the list of Ints in the same order

* t9: `IO.foreachParN` returns the list of created Strings in the appropriate order

* t10: `IO.foldLeft` with a successful step function sums the list properly

* t11: `IO.foldLeft` with a failing step function returns a failed IO

* Check done lifts exit result into IO

* Check `catchSomeCause` catches matching cause

* Check `catchSomeCause` halts if cause doesn't match

* Check `when` executes correct branch only

* scalafmt

* Check `whenM` executes condition effect and correct branch

* Check `whenCase` executes correct branch only

* Check `whenCaseM` executes condition effect and correct branch

* Check `unsandbox` unwraps exception

* Check `supervise` returns same value as IO.supervise

* Check `flatten` method on IO[E, IO[E, String] returns the same IO[E, String] as `IO.flatten` does

* Check `absolve` method on IO[E, Either[E, A]] returns the same IO[E, Either[E, String]] as `IO.absolve` does

* Check non-`memoize`d IO[E, A] returns new instances on repeated calls due to referential transparency

* Check `cached` method on IO[E, A] returns new instances after duration

* Check `raceAll` method returns the same IO[E, A] as `IO.raceAll` does

* Check `firstSuccessOf` method returns the same IO[E, A] as `IO.firstSuccessOf` does

* Check `zipPar` method does not swallow exit causes of loser;
Check `zipPar` method does not report failure when interrupting loser after it succeeded;

* Check `orElse` method does not recover from defects

* Check `eventually` method succeeds eventually

* implemented a large chunk of tests

* converted the rest of the tests

* Minor changes requested in PR review

* implemented "Check `summarized` returns summary and value", which just merged to master

* porting changes to ZIOSpecJvm from zio#2169
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