OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Test that 'identical(a,b)' is a compile-time constant. | 7 // Test that 'identical(a,b)' is a compile-time constant. |
8 | 8 |
9 class C { | 9 class C { |
10 final x; | 10 final x; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const CT(s1, l1), | 79 const CT(s1, l1), |
80 const CT(l1, m1), | 80 const CT(l1, m1), |
81 const CT(m1, c1), | 81 const CT(m1, c1), |
82 const CT(c1, f1), | 82 const CT(c1, f1), |
83 const CT(f1, C.f3), | 83 const CT(f1, C.f3), |
84 const CT(C.f3, identical), | 84 const CT(C.f3, identical), |
85 const CT(identical, i1), | 85 const CT(identical, i1), |
86 ]; | 86 ]; |
87 | 87 |
88 // Not a constant if it's not written 'identical'. | 88 // Not a constant if it's not written 'identical'. |
89 const idtest = id(i1, i2); /// 01: compile-time error | 89 const idtest = id(i1, i2); //# 01: compile-time error |
90 | 90 |
91 // Not a constant if aliased? (Current interpretation, waiting for | 91 // Not a constant if aliased? (Current interpretation, waiting for |
92 // confirmation). | 92 // confirmation). |
93 class T { /// 02: compile-time error | 93 class T { //# 02: compile-time error |
94 static const identical = id; /// 02: continued | 94 static const identical = id; //# 02: continued |
95 static const idtest2 = identical(i1, i2); /// 02: continued | 95 static const idtest2 = identical(i1, i2); //# 02: continued |
96 } /// 02: continued | 96 } //# 02: continued |
97 | 97 |
98 main() { | 98 main() { |
99 for (int i = 0; i < trueTests.length; i++) { | 99 for (int i = 0; i < trueTests.length; i++) { |
100 trueTests[i].test(Expect.isTrue, "true[$i]"); | 100 trueTests[i].test(Expect.isTrue, "true[$i]"); |
101 } | 101 } |
102 for (int i = 0; i < falseTests.length; i++) { | 102 for (int i = 0; i < falseTests.length; i++) { |
103 falseTests[i].test(Expect.isFalse, "false[$i]"); | 103 falseTests[i].test(Expect.isFalse, "false[$i]"); |
104 } | 104 } |
105 | 105 |
106 var x = idtest; /// 01: continued | 106 var x = idtest; //# 01: continued |
107 var x = T.idtest2; /// 02: continued | 107 var x = T.idtest2; //# 02: continued |
108 } | 108 } |
109 | 109 |
OLD | NEW |