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 class NumberSyntaxTest { | 5 class NumberSyntaxTest { |
6 | 6 |
7 static void testMain() { | 7 static void testMain() { |
8 testShortDoubleSyntax(); | 8 testShortDoubleSyntax(); |
9 testDotSelectorSyntax(); | 9 testDotSelectorSyntax(); |
10 } | 10 } |
11 | 11 |
12 static void testShortDoubleSyntax() { | 12 static void testShortDoubleSyntax() { |
13 Expect.equals(0.0, .0); | 13 Expect.equals(0.0, .0); |
14 Expect.equals(0.5, .5); | 14 Expect.equals(0.5, .5); |
15 Expect.equals(0.1234, .1234); | 15 Expect.equals(0.1234, .1234); |
16 } | 16 } |
17 | 17 |
18 static void testDotSelectorSyntax() { | 18 static void testDotSelectorSyntax() { |
19 // Integers. | 19 // Integers. |
| 20 Expect.equals(0, 0.dynamic); |
| 21 Expect.equals(1, 1.dynamic); |
| 22 Expect.equals(123, 123.dynamic); |
20 Expect.equals('0', 0.toString()); | 23 Expect.equals('0', 0.toString()); |
21 Expect.equals('1', 1.toString()); | 24 Expect.equals('1', 1.toString()); |
22 Expect.equals('123', 123.toString()); | 25 Expect.equals('123', 123.toString()); |
23 | 26 |
| 27 Expect.equals(0, 0 .dynamic); |
| 28 Expect.equals(1, 1 .dynamic); |
| 29 Expect.equals(123, 123 .dynamic); |
24 Expect.equals('0', 0 .toString()); | 30 Expect.equals('0', 0 .toString()); |
25 Expect.equals('1', 1 .toString()); | 31 Expect.equals('1', 1 .toString()); |
26 Expect.equals('123', 123 .toString()); | 32 Expect.equals('123', 123 .toString()); |
27 | 33 |
| 34 Expect.equals(0, 0. dynamic); |
| 35 Expect.equals(1, 1. dynamic); |
| 36 Expect.equals(123, 123. dynamic); |
28 Expect.equals('0', 0. toString()); | 37 Expect.equals('0', 0. toString()); |
29 Expect.equals('1', 1. toString()); | 38 Expect.equals('1', 1. toString()); |
30 Expect.equals('123', 123. toString()); | 39 Expect.equals('123', 123. toString()); |
31 | 40 |
32 // Doubles. | 41 // Doubles. |
| 42 Expect.equals(0.0, 0.0.dynamic); |
| 43 Expect.equals(0.1, .1.dynamic); |
| 44 Expect.equals(1.1, 1.1.dynamic); |
| 45 Expect.equals(123.4, 123.4.dynamic); |
33 Expect.equals((0.0).toString(), 0.0.toString()); | 46 Expect.equals((0.0).toString(), 0.0.toString()); |
34 Expect.equals((0.1).toString(), .1.toString()); | 47 Expect.equals((0.1).toString(), .1.toString()); |
35 Expect.equals((1.1).toString(), 1.1.toString()); | 48 Expect.equals((1.1).toString(), 1.1.toString()); |
36 Expect.equals((123.4).toString(), 123.4.toString()); | 49 Expect.equals((123.4).toString(), 123.4.toString()); |
37 | 50 |
| 51 Expect.equals(0.0, 0.0 .dynamic); |
| 52 Expect.equals(0.1, .1.dynamic); |
| 53 Expect.equals(1.1, 1.1 .dynamic); |
| 54 Expect.equals(123.4, 123.4 .dynamic); |
38 Expect.equals((0.0).toString(), 0.0 .toString()); | 55 Expect.equals((0.0).toString(), 0.0 .toString()); |
39 Expect.equals((0.1).toString(), .1 .toString()); | 56 Expect.equals((0.1).toString(), .1 .toString()); |
40 Expect.equals((1.1).toString(), 1.1 .toString()); | 57 Expect.equals((1.1).toString(), 1.1 .toString()); |
41 Expect.equals((123.4).toString(), 123.4 .toString()); | 58 Expect.equals((123.4).toString(), 123.4 .toString()); |
42 | 59 |
| 60 Expect.equals(0.0, 0.0. dynamic); |
| 61 Expect.equals(0.1, .1.dynamic); |
| 62 Expect.equals(1.1, 1.1. dynamic); |
| 63 Expect.equals(123.4, 123.4. dynamic); |
43 Expect.equals((0.0).toString(), 0.0. toString()); | 64 Expect.equals((0.0).toString(), 0.0. toString()); |
44 Expect.equals((0.1).toString(), .1. toString()); | 65 Expect.equals((0.1).toString(), .1. toString()); |
45 Expect.equals((1.1).toString(), 1.1. toString()); | 66 Expect.equals((1.1).toString(), 1.1. toString()); |
46 Expect.equals((123.4).toString(), 123.4. toString()); | 67 Expect.equals((123.4).toString(), 123.4. toString()); |
47 | 68 |
48 // Exponent notation. | 69 // Exponent notation. |
| 70 Expect.equals(0e0, 0e0.dynamic); |
| 71 Expect.equals(1e+1, 1e+1.dynamic); |
| 72 Expect.equals(2.1e-34, 2.1e-34.dynamic); |
49 Expect.equals((0e0).toString(), 0e0.toString()); | 73 Expect.equals((0e0).toString(), 0e0.toString()); |
50 Expect.equals((1e+1).toString(), 1e+1.toString()); | 74 Expect.equals((1e+1).toString(), 1e+1.toString()); |
51 Expect.equals((2.1e-34).toString(), 2.1e-34.toString()); | 75 Expect.equals((2.1e-34).toString(), 2.1e-34.toString()); |
52 } | 76 } |
53 | 77 |
54 } | 78 } |
55 main() { | 79 main() { |
56 NumberSyntaxTest.testMain(); | 80 NumberSyntaxTest.testMain(); |
57 } | 81 } |
OLD | NEW |