Prototype: Add Number.prototype.round as an alias to Math.round(). [Thomas Fuchs]
This commit is contained in:
parent
431dd4e994
commit
225597cb35
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Add Number.prototype.round as an alias to Math.round(). [Thomas Fuchs]
|
||||
|
||||
* Test library fixes: make rake dist work on Windows, only teardown if a browser is supported. Closes #8463, #8498. [Mislav Marohnić, grant]
|
||||
|
||||
* Change Element.insert syntax to allow multiple positions. [Thomas Fuchs]
|
||||
|
|
|
@ -114,6 +114,10 @@ Object.extend(Function.prototype, {
|
|||
Function.prototype.defer = Function.prototype.delay.curry(0.01);
|
||||
|
||||
Object.extend(Number.prototype, {
|
||||
round: function() {
|
||||
return Math.round(this);
|
||||
},
|
||||
|
||||
toColorPart: function() {
|
||||
return this.toPaddedString(2, 16);
|
||||
},
|
||||
|
|
|
@ -218,6 +218,13 @@
|
|||
}
|
||||
},
|
||||
|
||||
testNumberRound: function() {with(this) {
|
||||
assertEqual(1, (0.9).round());
|
||||
assertEqual(-2, (-1.9).round());
|
||||
|
||||
assertEqual(Math.round(Math.PI), Math.PI.round());
|
||||
}},
|
||||
|
||||
testNumberToColorPart: function() {with(this) {
|
||||
assertEqual('00', (0).toColorPart());
|
||||
assertEqual('0a', (10).toColorPart());
|
||||
|
|
Loading…
Reference in New Issue