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 dart2js.constants.expressions.evaluate_test; | 5 library dart2js.constants.expressions.evaluate_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/evaluation.dart'; | 10 import 'package:compiler/src/constants/evaluation.dart'; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 const ConstantData('0.0', const { const {} : 'DoubleConstant(0.0)' }), | 54 const ConstantData('0.0', const { const {} : 'DoubleConstant(0.0)' }), |
55 const ConstantData('"foo"', const { const {} : 'StringConstant("foo")' }), | 55 const ConstantData('"foo"', const { const {} : 'StringConstant("foo")' }), |
56 const ConstantData('1 + 2', const { const {} : 'IntConstant(3)' }), | 56 const ConstantData('1 + 2', const { const {} : 'IntConstant(3)' }), |
57 const ConstantData('-(1)', const { const {} : 'IntConstant(-1)' }), | 57 const ConstantData('-(1)', const { const {} : 'IntConstant(-1)' }), |
58 const ConstantData('1 == 2', const { const {} : 'BoolConstant(false)' }), | 58 const ConstantData('1 == 2', const { const {} : 'BoolConstant(false)' }), |
59 const ConstantData('1 != 2', const { const {} : 'BoolConstant(true)' }), | 59 const ConstantData('1 != 2', const { const {} : 'BoolConstant(true)' }), |
60 const ConstantData('"foo".length', const { const {} : 'IntConstant(3)' }), | 60 const ConstantData('"foo".length', const { const {} : 'IntConstant(3)' }), |
61 const ConstantData('identical(0, 1)', | 61 const ConstantData('identical(0, 1)', |
62 const { const {} : 'BoolConstant(false)' }), | 62 const { const {} : 'BoolConstant(false)' }), |
63 const ConstantData('"a" "b"', const { const {} : 'StringConstant("ab")' }), | 63 const ConstantData('"a" "b"', const { const {} : 'StringConstant("ab")' }), |
| 64 const ConstantData(r'"${null}"', |
| 65 const { const {} : 'StringConstant("null")' }), |
64 const ConstantData('identical', | 66 const ConstantData('identical', |
65 const { const {} : 'FunctionConstant(identical)' }), | 67 const { const {} : 'FunctionConstant(identical)' }), |
66 const ConstantData('true ? 0 : 1', const { const {} : 'IntConstant(0)' }), | 68 const ConstantData('true ? 0 : 1', const { const {} : 'IntConstant(0)' }), |
67 const ConstantData('proxy', | 69 const ConstantData('proxy', |
68 const { const {} : 'ConstructedConstant(_Proxy())' }), | 70 const { const {} : 'ConstructedConstant(_Proxy())' }), |
69 const ConstantData('Object', const { const {} : 'TypeConstant(Object)' }), | 71 const ConstantData('Object', const { const {} : 'TypeConstant(Object)' }), |
70 const ConstantData('const [0, 1]', | 72 const ConstantData('const [0, 1]', |
71 const { const {} : 'ListConstant([IntConstant(0), IntConstant(1)])' }), | 73 const { const {} : 'ListConstant([IntConstant(0), IntConstant(1)])' }), |
72 const ConstantData('const <int>[0, 1]', const { | 74 const ConstantData('const <int>[0, 1]', const { |
73 const {} : 'ListConstant(<int>[IntConstant(0), IntConstant(1)])' }), | 75 const {} : 'ListConstant(<int>[IntConstant(0), IntConstant(1)])' }), |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 Environment environment = new MemoryEnvironment(compiler, env); | 242 Environment environment = new MemoryEnvironment(compiler, env); |
241 ConstantValue value = | 243 ConstantValue value = |
242 constant.evaluate(environment, DART_CONSTANT_SYSTEM); | 244 constant.evaluate(environment, DART_CONSTANT_SYSTEM); |
243 String valueText = value.toStructuredText(); | 245 String valueText = value.toStructuredText(); |
244 Expect.equals(expectedText, valueText, | 246 Expect.equals(expectedText, valueText, |
245 "Unexpected value '${valueText}' for contant " | 247 "Unexpected value '${valueText}' for contant " |
246 "`${constant.toDartText()}`, expected '${expectedText}'."); | 248 "`${constant.toDartText()}`, expected '${expectedText}'."); |
247 }); | 249 }); |
248 }); | 250 }); |
249 } | 251 } |
OLD | NEW |