Open
Conversation
|
Nice! I'd like to use this in my fork. Could you make these commits into one? |
maiha
pushed a commit
to maiha/spec2.cr
that referenced
this pull request
Jan 7, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the current version of crystal (0.24.1) the tests fail.
The following changes where made:
1. Changed Time constructor
In
spec/elapsed_time_spec.crI had to change fromTime.new(year, month, day, hour, minute, second, millisecond)toTime.new(year, month, day, hour, minute, second) + 57.milliseconds. This is due to an API change in the Time constructor, which dropped milliseconds but added nanoseconds. With this change both older versions and the current work the same.2. Changed Time::Span constructor
Similar to 1. the constructor of Time::Span changed to now take nanoseconds as a named parameter.
I've added the
to_millisecondsmethod to keep backwards compatibility. I usedms.millisecondsbecause it's simpler. Alternatively you could useTime::Span.new(nanoseconds: ms * 1_000_000)(note: 100 times more than in the previous version. Usingms.millisecondsin older versions does not break the build, but it ignores any floating points.If you know a better option to check the crystal version or you don't want backwards compatibility just let me know.
3. Rounding
It seems like there have been minor changes to the rounding of numbers. The delta between
42.05and42changed from 0.049999999999997158 to 0.04999999999999716.As a workaround I've added a regex matcher that matches both and is in my opinion close enough for the test.
4. String represenations of literal expressions
The expression
(2 + 2)is no as a String"(2 + 2)"and not"2 + 2"as before.2 + 2on the other hand is in all versions2 + 2As a workaround I've swiched from
(2 + 2)to2 + 2.5. expect_raises without arguments
The methods
expect_raiseswithout any arguments got removed. I've added the parameterExceptionto the unit test.Testing
I've tested it with docker containers: