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 // Test number types. | 4 // Test number types. |
5 | 5 |
6 library NumbersTest.dart; | 6 library NumbersTest.dart; |
| 7 |
7 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
8 | 9 |
9 class NumbersTest { | 10 class NumbersTest { |
10 static double testMain() { | 11 static double testMain() { |
11 var one = 1; | 12 var one = 1; |
12 Expect.equals(true, one is Object); | 13 Expect.equals(true, one is Object); |
13 Expect.equals(true, one is num); | 14 Expect.equals(true, one is num); |
14 Expect.equals(true, one is int); | 15 Expect.equals(true, one is int); |
15 Expect.equals(false, one is double); | 16 Expect.equals(false, one is double); |
16 | 17 |
17 var two = 2.0; | 18 var two = 2.0; |
18 Expect.equals(true, two is Object); | 19 Expect.equals(true, two is Object); |
19 Expect.equals(true, two is num); | 20 Expect.equals(true, two is num); |
20 Expect.equals(false, two is int); | 21 Expect.equals(false, two is int); |
21 Expect.equals(true, two is double); | 22 Expect.equals(true, two is double); |
22 | 23 |
23 var result = one + two; | 24 var result = one + two; |
24 Expect.equals(true, result is Object); | 25 Expect.equals(true, result is Object); |
25 Expect.equals(true, result is num); | 26 Expect.equals(true, result is num); |
26 Expect.equals(false, result is int); | 27 Expect.equals(false, result is int); |
27 Expect.equals(true, result is double); | 28 Expect.equals(true, result is double); |
28 | 29 |
29 Expect.equals(3.0, result); | 30 Expect.equals(3.0, result); |
30 return result; | 31 return result; |
31 } | 32 } |
32 } | 33 } |
33 | 34 |
34 | |
35 main() { | 35 main() { |
36 NumbersTest.testMain(); | 36 NumbersTest.testMain(); |
37 } | 37 } |
OLD | NEW |