OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 f() {} | 7 f() {} |
8 const g = 1; | 8 const g = 1; |
9 | 9 |
10 const identical_ff = identical(f, f); | 10 const identical_ff = identical(f, f); |
11 const identical_fg = identical(f, g); | 11 const identical_fg = identical(f, g); |
12 const identical_gf = identical(g, f); | 12 const identical_gf = identical(g, f); |
13 const identical_gg = identical(g, g); | 13 const identical_gg = identical(g, g); |
14 | 14 |
15 // Verify proper compile time computation of identical() | 15 // Verify proper compile time computation of identical() |
16 const a = const { | 16 const a = const { |
17 identical_ff: 0, //# 01: static type warning | 17 identical_ff: 0, //# 01: static type warning |
18 identical_gg: 0, //# 02: static type warning | 18 identical_gg: 0, //# 02: static type warning |
19 true: 0 | 19 true: 0 }; |
20 }; | |
21 | 20 |
22 const b = const { | 21 const b = const { |
23 identical_fg: 0, //# 03: static type warning | 22 identical_fg: 0, //# 03: static type warning |
24 identical_gf: 0, //# 04: static type warning | 23 identical_gf: 0, //# 04: static type warning |
25 false: 0 | 24 false: 0 }; |
26 }; | |
27 | 25 |
28 use(x) => x; | 26 use(x) => x; |
29 | 27 |
30 main() { | 28 main() { |
31 use(a); | 29 use(a); |
32 use(b); | 30 use(b); |
33 | 31 |
34 // Verify proper run time computation of identical() | 32 // Verify proper run time computation of identical() |
35 Expect.isTrue(identical_ff); //# 05: ok | 33 Expect.isTrue(identical_ff); //# 05: ok |
36 Expect.isTrue(identical_gg); //# 06: ok | 34 Expect.isTrue(identical_gg); //# 06: ok |
37 Expect.isFalse(identical_fg); //# 07: ok | 35 Expect.isFalse(identical_fg); //# 07: ok |
38 Expect.isFalse(identical_gf); //# 08: ok | 36 Expect.isFalse(identical_gf); //# 08: ok |
39 } | 37 } |
OLD | NEW |