OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 class NumberSyntaxTest { | 7 class NumberSyntaxTest { |
8 | |
9 static void testMain() { | 8 static void testMain() { |
10 testShortDoubleSyntax(); | 9 testShortDoubleSyntax(); |
11 testDotSelectorSyntax(); | 10 testDotSelectorSyntax(); |
12 } | 11 } |
13 | 12 |
14 static void testShortDoubleSyntax() { | 13 static void testShortDoubleSyntax() { |
15 Expect.equals(0.0, .0); | 14 Expect.equals(0.0, .0); |
16 Expect.equals(0.5, .5); | 15 Expect.equals(0.5, .5); |
17 Expect.equals(0.1234, .1234); | 16 Expect.equals(0.1234, .1234); |
18 } | 17 } |
19 | 18 |
20 static void testDotSelectorSyntax() { | 19 static void testDotSelectorSyntax() { |
21 // Integers. | 20 // Integers. |
22 Expect.equals('0', 0.toString()); | 21 Expect.equals('0', 0.toString()); |
23 Expect.equals('1', 1.toString()); | 22 Expect.equals('1', 1.toString()); |
24 Expect.equals('123', 123.toString()); | 23 Expect.equals('123', 123.toString()); |
25 | 24 |
26 Expect.equals('0', 0 .toString()); | 25 Expect.equals('0', 0.toString()); |
27 Expect.equals('1', 1 .toString()); | 26 Expect.equals('1', 1.toString()); |
28 Expect.equals('123', 123 .toString()); | 27 Expect.equals('123', 123.toString()); |
29 | 28 |
30 Expect.equals('0', 0. toString()); | 29 Expect.equals('0', 0.toString()); |
31 Expect.equals('1', 1. toString()); | 30 Expect.equals('1', 1.toString()); |
32 Expect.equals('123', 123. toString()); | 31 Expect.equals('123', 123.toString()); |
33 | 32 |
34 // Doubles. | 33 // Doubles. |
35 Expect.equals((0.0).toString(), 0.0.toString()); | 34 Expect.equals((0.0).toString(), 0.0.toString()); |
36 Expect.equals((0.1).toString(), .1.toString()); | 35 Expect.equals((0.1).toString(), .1.toString()); |
37 Expect.equals((1.1).toString(), 1.1.toString()); | 36 Expect.equals((1.1).toString(), 1.1.toString()); |
38 Expect.equals((123.4).toString(), 123.4.toString()); | 37 Expect.equals((123.4).toString(), 123.4.toString()); |
39 | 38 |
40 Expect.equals((0.0).toString(), 0.0 .toString()); | 39 Expect.equals((0.0).toString(), 0.0.toString()); |
41 Expect.equals((0.1).toString(), .1 .toString()); | 40 Expect.equals((0.1).toString(), .1.toString()); |
42 Expect.equals((1.1).toString(), 1.1 .toString()); | 41 Expect.equals((1.1).toString(), 1.1.toString()); |
43 Expect.equals((123.4).toString(), 123.4 .toString()); | 42 Expect.equals((123.4).toString(), 123.4.toString()); |
44 | 43 |
45 Expect.equals((0.0).toString(), 0.0. toString()); | 44 Expect.equals((0.0).toString(), 0.0.toString()); |
46 Expect.equals((0.1).toString(), .1. toString()); | 45 Expect.equals((0.1).toString(), .1.toString()); |
47 Expect.equals((1.1).toString(), 1.1. toString()); | 46 Expect.equals((1.1).toString(), 1.1.toString()); |
48 Expect.equals((123.4).toString(), 123.4. toString()); | 47 Expect.equals((123.4).toString(), 123.4.toString()); |
49 | 48 |
50 // Exponent notation. | 49 // Exponent notation. |
51 Expect.equals((0e0).toString(), 0e0.toString()); | 50 Expect.equals((0e0).toString(), 0e0.toString()); |
52 Expect.equals((1e+1).toString(), 1e+1.toString()); | 51 Expect.equals((1e+1).toString(), 1e+1.toString()); |
53 Expect.equals((2.1e-34).toString(), 2.1e-34.toString()); | 52 Expect.equals((2.1e-34).toString(), 2.1e-34.toString()); |
54 } | 53 } |
| 54 } |
55 | 55 |
56 } | |
57 main() { | 56 main() { |
58 NumberSyntaxTest.testMain(); | 57 NumberSyntaxTest.testMain(); |
59 } | 58 } |
OLD | NEW |