-
Notifications
You must be signed in to change notification settings - Fork 408
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
Prevent nesting properties #677
Prevent nesting properties #677
Conversation
eb0c945
to
92c74c3
Compare
@@ -46,7 +47,10 @@ class Properties(val name: String) { | |||
|
|||
/** Returns all properties of this collection in a list of name/property | |||
* pairs. */ | |||
def properties: collection.Seq[(String,Prop)] = props | |||
def properties: collection.Seq[(String,Prop)] = { | |||
frozen = true // once the properties have been exposed, they must be frozen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an alternative would be to add a private[scalacheck] def freeze(): Unit
and call it from the task when it gets the properties
or right before execution
elsewhere you said "the scalacheck folks said this is not something you're supposed to do", was on that on Twitter? |
for reference, what currently happens when you nest properties is not particularly sensible in the first place. they do run, but their name/path does not include the property they were nested inside of, and they get executed at the end, rather than in order. |
src/test/scala/org/scalacheck/NoPropertyNestingSpecification.scala
Outdated
Show resolved
Hide resolved
does anyone object to this? if not, let's merge it (in a week or so, say) |
I don't see any objections |
okay, if you squash it, I'll merge it |
Prevent nesting properties or otherwise adding properties during execution.
29bd318
to
32ee5ab
Compare
squashed |
What was the motivation for this change? I recall discussing in Gitter that there was an effort to optimize the Scala collections library that revealed a defect in this code in ScalaCheck. Is there an upstream issue to read more about this? |
There were two motivations for this change:
|
Thanks, for the explanation. Had you run across a test suite that had nested properties and an exception was thrown with the |
yes. scala/scala's 😬 |
Ok, I wonder if I was wrong about nested properties not being supported. I know nesting properties isn't documented, but I suppose it may be possible for people to use it. I recall that cats and discipline projects could be doing something like this with law checking. |
@ashawley would you like me to run this through the Scala community build? |
Yes, that would be useful. I was planning to ask. I'll open an issue there. |
We're good over at scala/community-build#1226, so it looks like this change will stand. |
Yes, thanks for doing that for us, Seth! |
because doing so runs afoul of typelevel/scalacheck#677
Prevent nesting properties or otherwise adding properties
during execution.