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 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 const t = true; | 25 const t = true; |
26 const f = false; | 26 const f = false; |
27 const toplevelConstant = 0; | 27 const toplevelConstant = 0; |
28 toplevelFunction() {} | 28 toplevelFunction() {} |
29 const constant = $constantInitializer; | 29 const constant = $constantInitializer; |
30 """, expectNoWarningsOrErrors: true).then((env) { | 30 """, expectNoWarningsOrErrors: true).then((env) { |
31 var element = env.getElement('constant'); | 31 var element = env.getElement('constant'); |
32 Expect.isNotNull(element, "Element 'constant' not found."); | 32 Expect.isNotNull(element, "Element 'constant' not found."); |
33 var constant = env.compiler.constants.getConstantForVariable(element); | 33 var constant = env.compiler.constants.getConstantForVariable(element); |
| 34 var value = env.compiler.constants.getConstantValue(constant); |
34 Expect.isNotNull(constant, | 35 Expect.isNotNull(constant, |
35 "No constant computed for '$element'."); | 36 "No constant computed for '$element'."); |
36 Expect.equals(expectedOutput, constant.getText(), | 37 Expect.equals(expectedOutput, constant.getText(), |
37 "Unexpected to string '${constant.getText()}' for constant " | 38 "Unexpected to string '${constant.getText()}' for constant " |
38 "'$constantInitializer' of value " | 39 "'$constantInitializer' of value " |
39 "${constant.value.toStructuredString()}"); | 40 "${value.toStructuredString()}"); |
40 }); | 41 }); |
41 } | 42 } |
42 | 43 |
43 void main() { | 44 void main() { |
44 asyncTest(() => Future.forEach([ | 45 asyncTest(() => Future.forEach([ |
45 test('null'), | 46 test('null'), |
46 test('0'), | 47 test('0'), |
47 test('1.5'), | 48 test('1.5'), |
48 test('true'), | 49 test('true'), |
49 test('false'), | 50 test('false'), |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 test('t ? t : f ? f ? 0 : 1 : 2'), | 96 test('t ? t : f ? f ? 0 : 1 : 2'), |
96 test('t ? t ? t : t : t ? t : t'), | 97 test('t ? t ? t : t : t ? t : t'), |
97 test('t ? (t ? t : t) : (t ? t : t)', | 98 test('t ? (t ? t : t) : (t ? t : t)', |
98 't ? t ? t : t : t ? t : t'), | 99 't ? t ? t : t : t ? t : t'), |
99 test('const [const <dynamic, dynamic>{0: true, "1": "c" "d"}, ' | 100 test('const [const <dynamic, dynamic>{0: true, "1": "c" "d"}, ' |
100 'const Class(const Class<dynamic, dynamic>(toplevelConstant))]', | 101 'const Class(const Class<dynamic, dynamic>(toplevelConstant))]', |
101 'const [const {0: true, "1": "cd"}, ' | 102 'const [const {0: true, "1": "cd"}, ' |
102 'const Class(const Class(toplevelConstant))]'), | 103 'const Class(const Class(toplevelConstant))]'), |
103 ], (f) => f())); | 104 ], (f) => f())); |
104 } | 105 } |
OLD | NEW |