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 'dart:async'; | 5 import 'dart:async'; |
6 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 import 'type_test_helper.dart'; | 8 import 'type_test_helper.dart'; |
9 | 9 |
10 test(String constantInitializer, [String expectedOutput]) { | 10 test(String constantInitializer, [String expectedOutput]) { |
(...skipping 14 matching lines...) Expand all Loading... |
25 static staticFunction() {} | 25 static staticFunction() {} |
26 } | 26 } |
27 const t = true; | 27 const t = true; |
28 const f = false; | 28 const f = false; |
29 const toplevelConstant = 0; | 29 const toplevelConstant = 0; |
30 toplevelFunction() {} | 30 toplevelFunction() {} |
31 const constant = $constantInitializer; | 31 const constant = $constantInitializer; |
32 """, | 32 """, |
33 expectNoWarningsOrErrors: true) | 33 expectNoWarningsOrErrors: true) |
34 .then((env) { | 34 .then((env) { |
35 var element = env.getElement('constant'); | 35 dynamic element = env.getElement('constant'); |
36 Expect.isNotNull(element, "Element 'constant' not found."); | 36 Expect.isNotNull(element, "Element 'constant' not found."); |
37 var constant = element.constant; | 37 var constant = element.constant; |
38 var value = env.compiler.constants.getConstantValue(constant); | 38 var value = env.compiler.constants.getConstantValue(constant); |
39 Expect.isNotNull(constant, "No constant computed for '$element'."); | 39 Expect.isNotNull(constant, "No constant computed for '$element'."); |
40 Expect.equals( | 40 Expect.equals( |
41 expectedOutput, | 41 expectedOutput, |
42 constant.toDartText(), | 42 constant.toDartText(), |
43 "Unexpected to string '${constant.toDartText()}' for constant " | 43 "Unexpected to string '${constant.toDartText()}' for constant " |
44 "'$constantInitializer' of value " | 44 "'$constantInitializer' of value " |
45 "${value.toStructuredText()}"); | 45 "${value.toStructuredText()}"); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 test('t ? t : f ? f ? 0 : 1 : 2'), | 102 test('t ? t : f ? f ? 0 : 1 : 2'), |
103 test('t ? t ? t : t : t ? t : t'), | 103 test('t ? t ? t : t : t ? t : t'), |
104 test('t ? (t ? t : t) : (t ? t : t)', 't ? t ? t : t : t ? t : t'), | 104 test('t ? (t ? t : t) : (t ? t : t)', 't ? t ? t : t : t ? t : t'), |
105 test( | 105 test( |
106 'const [const <dynamic, dynamic>{0: true, "1": "c" "d"}, ' | 106 'const [const <dynamic, dynamic>{0: true, "1": "c" "d"}, ' |
107 'const Class(const Class<dynamic, dynamic>(toplevelConstant))]', | 107 'const Class(const Class<dynamic, dynamic>(toplevelConstant))]', |
108 'const [const {0: true, "1": "cd"}, ' | 108 'const [const {0: true, "1": "cd"}, ' |
109 'const Class(const Class(toplevelConstant))]'), | 109 'const Class(const Class(toplevelConstant))]'), |
110 ], (f) => f())); | 110 ], (f) => f())); |
111 } | 111 } |
OLD | NEW |