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 main() { | 7 main() { |
8 // Integer literals. | 8 // Integer literals. |
9 Expect.isTrue(2is int); | 9 Expect.isTrue(2is int); |
10 Expect.equals(2, 2as int); | 10 Expect.equals(2, 2as int); |
11 Expect.isTrue(-2is int); | 11 Expect.isTrue(-2is int); |
12 Expect.equals(-2, -2as int); | 12 Expect.equals(-2, -2as int); |
13 Expect.isTrue(0x10is int); | 13 Expect.isTrue(0x10is int); |
14 Expect.isTrue(-0x10is int); | 14 Expect.isTrue(-0x10is int); |
15 // "a" will be part of hex literal, the following "s" is an error. | 15 // "a" will be part of hex literal, the following "s" is an error. |
16 0x10as int; // /// 01: compile-time error | 16 0x10as int; // //# 01: compile-time error |
17 0x; // /// 04: compile-time error | 17 0x; // //# 04: compile-time error |
18 | 18 |
19 // Double literals. | 19 // Double literals. |
20 Expect.isTrue(2.0is double); | 20 Expect.isTrue(2.0is double); |
21 Expect.equals(2.0, 2.0as double); | 21 Expect.equals(2.0, 2.0as double); |
22 Expect.isTrue(-2.0is double); | 22 Expect.isTrue(-2.0is double); |
23 Expect.equals(-2.0, -2.0as double); | 23 Expect.equals(-2.0, -2.0as double); |
24 Expect.isTrue(.2is double); | 24 Expect.isTrue(.2is double); |
25 Expect.equals(0.2, .2as double); | 25 Expect.equals(0.2, .2as double); |
26 Expect.isTrue(1e2is double); | 26 Expect.isTrue(1e2is double); |
27 Expect.equals(1e2, 1e2as double); | 27 Expect.equals(1e2, 1e2as double); |
28 Expect.isTrue(1e-2is double); | 28 Expect.isTrue(1e-2is double); |
29 Expect.equals(1e-2, 1e-2as double); | 29 Expect.equals(1e-2, 1e-2as double); |
30 Expect.isTrue(1e+2is double); | 30 Expect.isTrue(1e+2is double); |
31 Expect.equals(1e+2, 1e+2as double); | 31 Expect.equals(1e+2, 1e+2as double); |
32 Expect.throws(() => 1.e+2, // /// 05: ok | 32 Expect.throws(() => 1.e+2, // //# 05: ok |
33 (e) => e is NoSuchMethodError); // /// 05: continued | 33 (e) => e is NoSuchMethodError); // //# 05: continued |
34 1d; // /// 06: compile-time error | 34 1d; // //# 06: compile-time error |
35 1D; // /// 07: compile-time error | 35 1D; // //# 07: compile-time error |
36 Expect.throws(() => 1.d+2, // /// 08: ok | 36 Expect.throws(() => 1.d+2, // //# 08: ok |
37 (e) => e is NoSuchMethodError); // /// 08: continued | 37 (e) => e is NoSuchMethodError); // //# 08: continued |
38 Expect.throws(() => 1.D+2, // /// 09: ok | 38 Expect.throws(() => 1.D+2, // //# 09: ok |
39 (e) => e is NoSuchMethodError); // /// 09: continued | 39 (e) => e is NoSuchMethodError); // //# 09: continued |
40 1.1d; // /// 10: compile-time error | 40 1.1d; // //# 10: compile-time error |
41 1.1D; // /// 11: compile-time error | 41 1.1D; // //# 11: compile-time error |
42 1e; // /// 02: compile-time error | 42 1e; // //# 02: compile-time error |
43 1x; // /// 03: compile-time error | 43 1x; // //# 03: compile-time error |
44 } | 44 } |
OLD | NEW |