OLD | NEW |
(Empty) | |
| 1 // Copyright 2012 the v8-i18n authors. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the 'License'); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an 'AS IS' BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 // Tests Number.prototype.toLocaleString method override. |
| 16 |
| 17 var integer = 123456790; |
| 18 var float = 1234567890.123434; |
| 19 |
| 20 |
| 21 // Defaults |
| 22 var nf = new Intl.NumberFormat(); |
| 23 assertEquals(nf.format(integer), integer.toLocaleString()); |
| 24 assertEquals(nf.format(float), float.toLocaleString()); |
| 25 |
| 26 |
| 27 // Specify locale, default options for toLocaleString method. |
| 28 var locale = ['sr']; |
| 29 nf = new Intl.NumberFormat(locale); |
| 30 assertEquals(nf.format(integer), integer.toLocaleString(locale)); |
| 31 assertEquals(nf.format(float), float.toLocaleString(locale)); |
| 32 |
| 33 |
| 34 // Specify locale and options for toLocaleString method. |
| 35 locale = ['ko']; |
| 36 var options = {minimumIntegerDigits: 8, useGroupingSeparator: true, |
| 37 minimumFractionalDigits: 1, maximumFractionalDigits: 2}; |
| 38 nf = new Intl.NumberFormat(locale, options); |
| 39 assertEquals(nf.format(integer), integer.toLocaleString(locale, options)); |
| 40 assertEquals(nf.format(float), float.toLocaleString(locale, options)); |
OLD | NEW |