| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library constant_expression_test; | 5 library constant_expression_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
| 10 import 'package:compiler/src/constants/expressions.dart'; | 10 import 'package:compiler/src/constants/expressions.dart'; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 }), | 140 }), |
| 141 ]), | 141 ]), |
| 142 const TestData( | 142 const TestData( |
| 143 ''' | 143 ''' |
| 144 class A<T> implements B { | 144 class A<T> implements B { |
| 145 final field1; | 145 final field1; |
| 146 const A({this.field1:42}); | 146 const A({this.field1:42}); |
| 147 } | 147 } |
| 148 class B<S> implements C { | 148 class B<S> implements C { |
| 149 const factory B({field1}) = A<B<S>>; | 149 const factory B({field1}) = A<B<S>>; |
| 150 // TODO(johnniwinther): Enable this when the constructor evaluator doesn't | |
| 151 // crash: | |
| 152 const factory B.named() = A<S>; | 150 const factory B.named() = A<S>; |
| 153 } | 151 } |
| 154 class C<U> { | 152 class C<U> { |
| 155 const factory C({field1}) = A<B<double>>; | 153 const factory C({field1}) = A<B<double>>; |
| 156 } | 154 } |
| 157 ''', | 155 ''', |
| 158 const [ | 156 const [ |
| 159 const ConstantData('const A()', ConstantExpressionKind.CONSTRUCTED, | 157 const ConstantData('const A()', ConstantExpressionKind.CONSTRUCTED, |
| 160 type: 'A<dynamic>', fields: const {'field(A#field1)': '42'}), | 158 type: 'A<dynamic>', fields: const {'field(A#field1)': '42'}), |
| 161 const ConstantData( | 159 const ConstantData( |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 String expected = data.fields[name]; | 243 String expected = data.fields[name]; |
| 246 Expect.equals( | 244 Expect.equals( |
| 247 expected, | 245 expected, |
| 248 expression, | 246 expression, |
| 249 "Unexpected field expression ${expression} for field '$name' in " | 247 "Unexpected field expression ${expression} for field '$name' in " |
| 250 "contant `${constant.toDartText()}`, expected '${expected}'."); | 248 "contant `${constant.toDartText()}`, expected '${expected}'."); |
| 251 }); | 249 }); |
| 252 } | 250 } |
| 253 }); | 251 }); |
| 254 } | 252 } |
| OLD | NEW |