Skip to content
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

[#50] Add decode.encode = id tests #173

Merged
merged 4 commits into from
Jan 12, 2019
Merged

Conversation

vrom911
Copy link
Member

@vrom911 vrom911 commented Jan 10, 2019

Resolves #50

@vrom911 vrom911 added codec Conversion between TOML and custom user data types test Testing (unit, properties) labels Jan 10, 2019
@vrom911 vrom911 self-assigned this Jan 10, 2019
@vrom911 vrom911 requested a review from chshersh January 10, 2019 16:17
Copy link
Contributor

@chshersh chshersh left a comment

Choose a reason for hiding this comment

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

The tests look pretty good! I have couple suggestions. Need to look carefully, where is the error...

genInt = Gen.int (Range.constant 0 256)

genWord :: Gen Word
genWord = Gen.word (Range.constant 1 256)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use constantBounded generator for Int and Word to avoid specifying boundaries manually. Unfortunately, won't fork for Double and Float, they don't have instances...

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

Also, do you think that it's better to move these generators to Gen module?

Copy link
Contributor

Choose a reason for hiding this comment

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

@vrom911 Yeah, I think it's a good idea to move general-purpose generators (like genWord) into single module, because they are probably going to be reusable in several places (for example, I can see that BiMap.Property uses most of the same generators. It's a good idea to keep all basic generators in single place 🙂

deriving (Show)

instance Eq BigTypeNewtype where
(BigTypeNewtype a) == (BigTypeNewtype b) = zonedTimeToUTC a == zonedTimeToUTC b
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice idea to move ZonedTime inside newtype! With this trick you can minimize the size of Eq instance and test both diwrap and zonedTime!

, btText :: Text
, btString :: String
, btBS :: ByteString
, btLazyBS :: L.ByteString
Copy link
Contributor

Choose a reason for hiding this comment

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

Lol, I just noticed that in tomland we have Text, ByteString, LByteString and String but not LText. Heh, that's awkward. Probably need to add LText to tomland as well. I've created issue for this:

@vrom911 vrom911 changed the title [WIP] [#50] Add decode.encode = id tests [#50] Add decode.encode = id tests Jan 12, 2019
@vrom911
Copy link
Member Author

vrom911 commented Jan 12, 2019

@kowainik/dev it's ready for review!

Copy link
Contributor

@chshersh chshersh left a comment

Choose a reason for hiding this comment

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

This looks good to me! I have only minor suggestion 🙂 Otherwise this is huge work! I also appreciate the refactoring 🙂

, genInteger
, genDouble
Copy link
Contributor

Choose a reason for hiding this comment

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

I like separation of reexports in this export section! 😍

test/Test/Toml/Gen.hs Outdated Show resolved Hide resolved
Co-Authored-By: vrom911 <vrom911@gmail.com>
@chshersh chshersh merged commit 90af0bd into master Jan 12, 2019
@chshersh chshersh deleted the vrom911/50-decode-encode branch January 12, 2019 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codec Conversion between TOML and custom user data types test Testing (unit, properties)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants