OLD | NEW |
(Empty) | |
| 1 /** |
| 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 * for details. All rights reserved. Use of this source code is governed by a |
| 4 * BSD-style license that can be found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 #import('../../../pkg/unittest/unittest.dart'); |
| 8 #import('../number_format.dart'); |
| 9 #import('../intl.dart'); |
| 10 |
| 11 /** |
| 12 * Tests the Numeric formatting library in dart. |
| 13 */ |
| 14 var testNumbers = const { |
| 15 "0.001": 0.001, |
| 16 "0.01": 0.01, |
| 17 "0.1": 0.1, |
| 18 "1": 1, |
| 19 "2": 2.0, |
| 20 "10": 10, |
| 21 "100": 100, |
| 22 "1,000": 1000, |
| 23 "2,000,000,000,000": 2000000000000, |
| 24 "10,000,000,000,000,000,000,000,000,000,000": |
| 25 10000000000000000000000000000000, |
| 26 "0.123": 0.123, |
| 27 "1,234": 1234.0, |
| 28 "1.234": 1.234, |
| 29 "1.23": 1.230, |
| 30 "NaN": 0/0, |
| 31 "∞": 1/0, |
| 32 "-∞": -1/0}; |
| 33 |
| 34 main() { |
| 35 test('Basic number printing', () { |
| 36 var number = new NumberFormat(); |
| 37 expect(number.format(3.14),"3.14"); |
| 38 }); |
| 39 |
| 40 test('Simple set of numbers', () { |
| 41 var number = new NumberFormat(); |
| 42 for (var x in testNumbers.getKeys()) { |
| 43 var formatted = number.format(testNumbers[x]); |
| 44 expect(formatted, x); |
| 45 } |
| 46 }); |
| 47 } |
OLD | NEW |