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

Skip to content

Conversation

@dkarlinsky
Copy link
Contributor

@dkarlinsky dkarlinsky commented Jan 4, 2021

This is a refinement of #4427
Moves the captured expression into the description of the value being asserted on.
Moves the source location to a separate line.
image

Also made rendered expressions much cleaner - closer to how you would normally write the code.
Under dotty the actual source code is shown.
Example (for Scala 2.x)

//before
Tuple4.apply[String, Int, String, Boolean]("foo", 123, Test.this.fooVal, false)
// now 
("foo", 123, fooVal, false)

@dkarlinsky dkarlinsky closed this Jan 4, 2021
@dkarlinsky dkarlinsky reopened this Jan 4, 2021
adamgfraser
adamgfraser previously approved these changes Jan 5, 2021
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.

Nice!

@dkarlinsky dkarlinsky marked this pull request as ready for review January 6, 2021 14:14
@jdegoes jdegoes merged commit e94be18 into zio:master Jan 8, 2021
@dkarlinsky dkarlinsky deleted the zio-test/assert-label-location-imorovements branch January 8, 2021 18:29
@hmemcpy
Copy link
Contributor

hmemcpy commented Jan 16, 2021

@dkarlinsky nice! Just noticed this when rebasing my changes. Did you make this adjustment for the dotty variant as well?

@dkarlinsky
Copy link
Contributor Author

@dkarlinsky nice! Just noticed this when rebasing my changes. Did you make this adjustment for the dotty variant as well?

Yes, and in dotty you can just get the actual source:

Term.of(expr).pos.sourceCode

@hmemcpy
Copy link
Contributor

hmemcpy commented Jan 16, 2021

Ah cool! I saw that specific line was rewritten by @sideeffffect (https://github.com/zio/zio/blob/master/test/shared/src/main/scala-dotty/zio/test/CompileVariants.scala#L105), but I guess it's for compat with the latest dotty.

Thanks!

@sideeffffect
Copy link
Member

sideeffffect commented Jan 16, 2021

Exactly, Scala 3.0.0-M3's method sourceCode changed from returning String to Option[String].
Due to bad timing of merging of some PRs (and the fact that our current CI setup isn't designed to deal with such incidents), it made master branch's build red (which causes its whole set of issues, like preventing any PR to be merged).
I added a little .get to make it all work out and unblock the CI. But if it turns out that in some cases it indeed is None, then we would have to deal with that -- using .getOrElse("") or something like that I presume?

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.

5 participants