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 16 matching lines...) Expand all Loading... |
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 var value = env.compiler.constants.getConstantValue(constant); |
35 Expect.isNotNull(constant, | 35 Expect.isNotNull(constant, |
36 "No constant computed for '$element'."); | 36 "No constant computed for '$element'."); |
37 Expect.equals(expectedOutput, constant.getText(), | 37 Expect.equals(expectedOutput, constant.toDartText(), |
38 "Unexpected to string '${constant.getText()}' for constant " | 38 "Unexpected to string '${constant.toDartText()}' for constant " |
39 "'$constantInitializer' of value " | 39 "'$constantInitializer' of value " |
40 "${value.toStructuredString()}"); | 40 "${value.toStructuredText()}"); |
41 }); | 41 }); |
42 } | 42 } |
43 | 43 |
44 void main() { | 44 void main() { |
45 asyncTest(() => Future.forEach([ | 45 asyncTest(() => Future.forEach([ |
46 test('null'), | 46 test('null'), |
47 test('0'), | 47 test('0'), |
48 test('1.5'), | 48 test('1.5'), |
49 test('true'), | 49 test('true'), |
50 test('false'), | 50 test('false'), |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 test('t ? t : f ? f ? 0 : 1 : 2'), | 96 test('t ? t : f ? f ? 0 : 1 : 2'), |
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 test('t ? (t ? t : t) : (t ? t : t)', |
99 't ? t ? t : t : t ? t : t'), | 99 't ? t ? t : t : t ? t : t'), |
100 test('const [const <dynamic, dynamic>{0: true, "1": "c" "d"}, ' | 100 test('const [const <dynamic, dynamic>{0: true, "1": "c" "d"}, ' |
101 'const Class(const Class<dynamic, dynamic>(toplevelConstant))]', | 101 'const Class(const Class<dynamic, dynamic>(toplevelConstant))]', |
102 'const [const {0: true, "1": "cd"}, ' | 102 'const [const {0: true, "1": "cd"}, ' |
103 'const Class(const Class(toplevelConstant))]'), | 103 'const Class(const Class(toplevelConstant))]'), |
104 ], (f) => f())); | 104 ], (f) => f())); |
105 } | 105 } |
OLD | NEW |