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

[#536] Fix ex.Utils.clamp min/max handling #673

Merged
merged 11 commits into from
Dec 6, 2016

Conversation

jasonlh-harris
Copy link
Contributor

@jasonlh-harris jasonlh-harris commented Oct 26, 2016

Closes #536

Changes:

  • Update ex.Util.clamp to use Math libraries Min and Max
  • Add unit tests for ex.Util.clamp

@jedeen jedeen self-assigned this Oct 26, 2016
@jedeen jedeen added this to the 0.8.0 Release milestone Oct 26, 2016
@jedeen jedeen added the enhancement Label applied to enhancements or improvements to existing features label Oct 26, 2016
@eonarheim eonarheim changed the title Fices #536 - Update ex.Utils.clamp Fixes #536 - Update ex.Utils.clamp Oct 26, 2016
Copy link
Member

@kamranayub kamranayub left a comment

Choose a reason for hiding this comment

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

@FerociousQuasar do you mind updating the PR description according to our template? That'd be awesome.

@kamranayub kamranayub changed the title Fixes #536 - Update ex.Utils.clamp [#536] Fix ex.Utils.clamp min/max handling Oct 26, 2016
@kamranayub
Copy link
Member

Also, I'm thinking to be good citizens we should ensure this function has proper tests around it.

Copy link
Member

@jedeen jedeen left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! A couple of additional notes:

There is a small typo in the commit message. In additon, we would appreciate it if all commit messages followed our styleguide.

Please update CHANGELOG.md with the changes you made in this pull request. You can find more information in our pull request guidelines.

@jasonlh-harris
Copy link
Contributor Author

Roger.
Will add unit tests to make sure this behaves as expected.
Will update CHANGELOG.md with the changes.
Will update commit message to meet the appropriate standard.

@jedeen jedeen modified the milestones: 0.8.0 Release, 0.9.0 Release Dec 4, 2016
@eonarheim
Copy link
Member

@jedeen @FerociousQuasar Let's not worry about the commit messages on this one since we'll squash the messages.

Any issues @excaliburjs/core-contributors? LGTM :shipit:

it('can clamp a number to a maximum and minimum', () => {
expect(ex.Util.clamp(0, 10, 20)).toBe(10);
expect(ex.Util.clamp(15, 10, 20)).toBe(15);
expect(ex.Util.clamp(30, 10, 20)).toBe(20);
Copy link
Member

Choose a reason for hiding this comment

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

Could you add another couple tests for Infinity and -Infinity to test those boundaries?

@@ -104,7 +104,7 @@ module ex.Util {
}

export function clamp(val, min, max) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add the number types to each parameter to make sure people don't accidentally pass in other types?

@jedeen jedeen merged commit dded702 into excaliburjs:master Dec 6, 2016
@jasonlh-harris jasonlh-harris deleted the #536-Update-ex.Utils.Clamp branch April 4, 2018 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Label applied to enhancements or improvements to existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants