-
Notifications
You must be signed in to change notification settings - Fork 641
Separate file IO from code transformation in InlineSnapshots code #232
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
Separate file IO from code transformation in InlineSnapshots code #232
Conversation
|
Hey @ferranpujolcamins, this is looking really promising! @mbrandonw and I won't have a chance to sit down and really look over this for a bit, though, so sorry for the delay. After a quick skim the thing that sticks out most is bringing in some stuff from Prelude. I think we'll want to minimize that surface area if possible (for example, we defined a minimal |
|
Yes I’ll try to reduce the ported code up to a minimum. By the way, are you ok using the state monad here? At the end this is not Haskell and a function with inout parameters would also work. If you think it’s best to keep it simple and ditch the state monad please let me know. |
|
Hi @ferranpujolcamins. Sorry for the delay! Let's definitely keep it simple and use |
|
Done! I used some operators. Now the tests are simple but in case we want to add more complex tests the operators will come handy. |
|
Looking good! Just one last thing and I think we can merge.
@mbrandonw and I are definitely fans of operators, but since we're not really using them outside of that one test, maybe we avoid them for now. I'm thinking an inline closure won't be so bad? And should make the code more immediately readable for those unfamiliar with composition operators. |
|
Fixed! |
stephencelis
left a comment
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.
Nice! Thanks so much for making this stuff testable!
|
Can you resolve the merge conflict? I'll merge as soon as the build is green 🎉 |
# Conflicts: # Sources/SnapshotTesting/AssertInlineSnapshot.swift
|
Done! |
This PR separates the inline snapshot logic into IO and pure code transformation. The code transformation needs the
recordingsstruct, so I made the new functionwriteInlineSnapshotmonadic. This is useful to write the tests, since we can easily express what code transformations would happen on a real test:I wanted to use
swift-prelude, but since it depends onswift-snapshot-testingI couldn't. So I brought some goodies from there and just copied the code here. I hope we can fix this in the future.