OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 class NumberSyntaxTest { | |
6 | |
7 static void testMain() { | |
8 testShortDoubleSyntax(); | |
9 testDotSelectorSyntax(); | |
10 } | |
11 | |
12 static void testShortDoubleSyntax() { | |
13 Expect.equals(0.0, .0); | |
14 Expect.equals(0.5, .5); | |
15 Expect.equals(0.1234, .1234); | |
16 } | |
17 | |
18 static void testDotSelectorSyntax() { | |
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()); | |
24 Expect.equals('1', 1.toString()); | |
25 Expect.equals('123', 123.toString()); | |
26 | |
27 Expect.equals(0, 0 .dynamic); | |
28 Expect.equals(1, 1 .dynamic); | |
29 Expect.equals(123, 123 .dynamic); | |
30 Expect.equals('0', 0 .toString()); | |
31 Expect.equals('1', 1 .toString()); | |
32 Expect.equals('123', 123 .toString()); | |
33 | |
34 Expect.equals(0, 0. dynamic); | |
35 Expect.equals(1, 1. dynamic); | |
36 Expect.equals(123, 123. dynamic); | |
37 Expect.equals('0', 0. toString()); | |
38 Expect.equals('1', 1. toString()); | |
39 Expect.equals('123', 123. toString()); | |
40 | |
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); | |
46 Expect.equals((0.0).toString(), 0.0.toString()); | |
47 Expect.equals((0.1).toString(), .1.toString()); | |
48 Expect.equals((1.1).toString(), 1.1.toString()); | |
49 Expect.equals((123.4).toString(), 123.4.toString()); | |
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); | |
55 Expect.equals((0.0).toString(), 0.0 .toString()); | |
56 Expect.equals((0.1).toString(), .1 .toString()); | |
57 Expect.equals((1.1).toString(), 1.1 .toString()); | |
58 Expect.equals((123.4).toString(), 123.4 .toString()); | |
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); | |
64 Expect.equals((0.0).toString(), 0.0. toString()); | |
65 Expect.equals((0.1).toString(), .1. toString()); | |
66 Expect.equals((1.1).toString(), 1.1. toString()); | |
67 Expect.equals((123.4).toString(), 123.4. toString()); | |
68 | |
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); | |
73 Expect.equals((0e0).toString(), 0e0.toString()); | |
74 Expect.equals((1e+1).toString(), 1e+1.toString()); | |
75 Expect.equals((2.1e-34).toString(), 2.1e-34.toString()); | |
76 } | |
77 | |
78 } | |
79 main() { | |
80 NumberSyntaxTest.testMain(); | |
81 } | |
OLD | NEW |