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 #library('number_format_test'); | |
8 | |
9 #import('../../../pkg/unittest/unittest.dart'); | |
10 #import('../number_format.dart'); | |
11 #import('../intl.dart'); | |
12 | |
13 /** | |
14 * Tests the Numeric formatting library in dart. | |
15 */ | |
16 var testNumbers = const { | |
17 "0.001": 0.001, | |
18 "0.01": 0.01, | |
19 "0.1": 0.1, | |
20 "1": 1, | |
21 "2": 2.0, | |
22 "10": 10, | |
23 "100": 100, | |
24 "1,000": 1000, | |
25 "2,000,000,000,000": 2000000000000, | |
26 "10,000,000,000,000,000,000,000,000,000,000": | |
27 10000000000000000000000000000000, | |
28 "0.123": 0.123, | |
29 "1,234": 1234.0, | |
30 "1.234": 1.234, | |
31 "1.23": 1.230, | |
32 "NaN": 0/0, | |
33 "∞": 1/0, | |
34 "-∞": -1/0}; | |
35 | |
36 main() { | |
37 test('Basic number printing', () { | |
38 var number = new NumberFormat(); | |
39 expect(number.format(3.14),"3.14"); | |
40 }); | |
41 | |
42 test('Simple set of numbers', () { | |
43 var number = new NumberFormat(); | |
44 for (var x in testNumbers.getKeys()) { | |
45 var formatted = number.format(testNumbers[x]); | |
46 expect(formatted, x); | |
47 } | |
48 }); | |
49 } | |
OLD | NEW |