Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

use dynamic variable to control serialization tests #141

Merged
merged 3 commits into from
Apr 20, 2016

Conversation

sritchie
Copy link
Contributor

Here's a much simpler (in terms of required implementation changes and ease of use) solution to #123. To skip serialization for a block of tests, just pass a thunk to withoutSerialization:

withoutSerialization {
   laws[OrderLaws, Boolean].check(_.order)
}

I think this should solve our immediate issue of making the tests reusable for non-serializable instances.

@sritchie
Copy link
Contributor Author

sritchie commented Jan 6, 2016

@ceedubs, @johnynek - any thoughts?

* Object with a dynamic variable that allows users to skip the
* serialization tests for certain instances.
*/
object IsSerializable {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we make this private[laws] and just let people interact with this via the withoutSerialization?

@johnynek
Copy link
Contributor

johnynek commented Jan 6, 2016

This solution looks like the best way to go forward to me.

@sritchie
Copy link
Contributor Author

sritchie commented Jan 6, 2016

@johnynek Boom, done.

@ceedubs
Copy link
Contributor

ceedubs commented Jan 6, 2016

It makes me cringe a bit that we solved a problem of verbosity with global mutable state :). I can't think of a practical objection as long as this is scala.js-friendly though - is DynamicVariable okay to use in that context?

@ceedubs
Copy link
Contributor

ceedubs commented Jan 6, 2016

Hmm actually couldn't this be an issue when testing an instance for something like Future where the law-checking might start on one thread and end on another? Edit - hmm maybe it's not. I'm not familiar with DynamicVariable.

@sritchie
Copy link
Contributor Author

sritchie commented Jan 6, 2016

@ceedubs I think the state applies in the context created inside withoutSerialization; so any thread spawned inside that grabs that state of the variable.

@sritchie
Copy link
Contributor Author

sritchie commented Jan 6, 2016

@ceedubs pretty sure it's fine with scala.js. The tests all pass, anyway. And it's not really "global mutable state" unless someone toggles runTests, which is an abuse of the interface since we've marked the object as private.

I share your general cringe, but the alternative is too horrifying. Just pretend it's an implicit parameter that every function gets :)

@ceedubs
Copy link
Contributor

ceedubs commented Jan 6, 2016

@sritchie okay and Sébastien even confirms DynamicVariable isn't a problem for scala.js.

I'm not crazy about this approach, but it seems to get the job done with minimal impact. Thanks for all of your work on this! 👍 (note: I'm not an algebra committer so this isn't an official thumbsup)

@sritchie
Copy link
Contributor Author

sritchie commented Jan 6, 2016

Sounds great! Let me know if you guys need any changes, or feel free to
merge away.
On Wed, Jan 6, 2016 at 2:03 PM Cody Allen notifications@github.com wrote:

@sritchie https://github.com/sritchie okay and Sébastien even confirms
https://groups.google.com/d/msg/scala-js/LYj4FgZ_ACQ/p7K7vi8dM9wJ
DynamicVariable isn't a problem for scala.js.

I'm not crazy about this approach, but it seems to get the job done with
minimal impact. Thanks for all of your work on this! [image: 👍](note:
I'm not an algebra committer so this isn't an official thumbsup)


Reply to this email directly or view it on GitHub
#141 (comment).

@non
Copy link
Contributor

non commented Apr 20, 2016

After a four month hiatus I think this is basically fine. 👍

@johnynek
Copy link
Contributor

I still think this is the best solution we have to give a workaround for non-serializable types, but also check by default all the typeclasses being serializable.

@johnynek johnynek merged commit f9d65c5 into typelevel:master Apr 20, 2016
@sritchie sritchie deleted the feature/dynamic_serialization branch September 24, 2016 21:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants