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); | |
23 Expect.equals('0', 0.toString()); | 20 Expect.equals('0', 0.toString()); |
24 Expect.equals('1', 1.toString()); | 21 Expect.equals('1', 1.toString()); |
25 Expect.equals('123', 123.toString()); | 22 Expect.equals('123', 123.toString()); |
26 | 23 |
27 Expect.equals(0, 0 .dynamic); | |
28 Expect.equals(1, 1 .dynamic); | |
29 Expect.equals(123, 123 .dynamic); | |
30 Expect.equals('0', 0 .toString()); | 24 Expect.equals('0', 0 .toString()); |
31 Expect.equals('1', 1 .toString()); | 25 Expect.equals('1', 1 .toString()); |
32 Expect.equals('123', 123 .toString()); | 26 Expect.equals('123', 123 .toString()); |
33 | 27 |
34 Expect.equals(0, 0. dynamic); | |
35 Expect.equals(1, 1. dynamic); | |
36 Expect.equals(123, 123. dynamic); | |
37 Expect.equals('0', 0. toString()); | 28 Expect.equals('0', 0. toString()); |
38 Expect.equals('1', 1. toString()); | 29 Expect.equals('1', 1. toString()); |
39 Expect.equals('123', 123. toString()); | 30 Expect.equals('123', 123. toString()); |
40 | 31 |
41 // Doubles. | 32 // 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); | |
46 Expect.equals((0.0).toString(), 0.0.toString()); | 33 Expect.equals((0.0).toString(), 0.0.toString()); |
47 Expect.equals((0.1).toString(), .1.toString()); | 34 Expect.equals((0.1).toString(), .1.toString()); |
48 Expect.equals((1.1).toString(), 1.1.toString()); | 35 Expect.equals((1.1).toString(), 1.1.toString()); |
49 Expect.equals((123.4).toString(), 123.4.toString()); | 36 Expect.equals((123.4).toString(), 123.4.toString()); |
50 | 37 |
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); | |
55 Expect.equals((0.0).toString(), 0.0 .toString()); | 38 Expect.equals((0.0).toString(), 0.0 .toString()); |
56 Expect.equals((0.1).toString(), .1 .toString()); | 39 Expect.equals((0.1).toString(), .1 .toString()); |
57 Expect.equals((1.1).toString(), 1.1 .toString()); | 40 Expect.equals((1.1).toString(), 1.1 .toString()); |
58 Expect.equals((123.4).toString(), 123.4 .toString()); | 41 Expect.equals((123.4).toString(), 123.4 .toString()); |
59 | 42 |
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); | |
64 Expect.equals((0.0).toString(), 0.0. toString()); | 43 Expect.equals((0.0).toString(), 0.0. toString()); |
65 Expect.equals((0.1).toString(), .1. toString()); | 44 Expect.equals((0.1).toString(), .1. toString()); |
66 Expect.equals((1.1).toString(), 1.1. toString()); | 45 Expect.equals((1.1).toString(), 1.1. toString()); |
67 Expect.equals((123.4).toString(), 123.4. toString()); | 46 Expect.equals((123.4).toString(), 123.4. toString()); |
68 | 47 |
69 // Exponent notation. | 48 // 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); | |
73 Expect.equals((0e0).toString(), 0e0.toString()); | 49 Expect.equals((0e0).toString(), 0e0.toString()); |
74 Expect.equals((1e+1).toString(), 1e+1.toString()); | 50 Expect.equals((1e+1).toString(), 1e+1.toString()); |
75 Expect.equals((2.1e-34).toString(), 2.1e-34.toString()); | 51 Expect.equals((2.1e-34).toString(), 2.1e-34.toString()); |
76 } | 52 } |
77 | 53 |
78 } | 54 } |
79 main() { | 55 main() { |
80 NumberSyntaxTest.testMain(); | 56 NumberSyntaxTest.testMain(); |
81 } | 57 } |
OLD | NEW |