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 library analyzer.test.src.dart.ast.utilities_test; | 5 library analyzer.test.src.dart.ast.utilities_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
9 import 'package:analyzer/dart/ast/token.dart'; | 9 import 'package:analyzer/dart/ast/token.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 void test_binary_notEqual_invalidRight() { | 189 void test_binary_notEqual_invalidRight() { |
190 Object value = _getConstantValue("2 != a"); | 190 Object value = _getConstantValue("2 != a"); |
191 expect(value, ConstantEvaluator.NOT_A_CONSTANT); | 191 expect(value, ConstantEvaluator.NOT_A_CONSTANT); |
192 } | 192 } |
193 | 193 |
194 void test_binary_notEqual_string() { | 194 void test_binary_notEqual_string() { |
195 Object value = _getConstantValue("'a' != 'b'"); | 195 Object value = _getConstantValue("'a' != 'b'"); |
196 expect(value, true); | 196 expect(value, true); |
197 } | 197 } |
198 | 198 |
| 199 void test_binary_plus_string() { |
| 200 Object value = _getConstantValue("'hello ' + 'world'"); |
| 201 expect(value, 'hello world'); |
| 202 } |
| 203 |
199 void test_binary_plus_double() { | 204 void test_binary_plus_double() { |
200 Object value = _getConstantValue("2.3 + 3.2"); | 205 Object value = _getConstantValue("2.3 + 3.2"); |
201 expect(value, 2.3 + 3.2); | 206 expect(value, 2.3 + 3.2); |
202 } | 207 } |
203 | 208 |
204 void test_binary_plus_integer() { | 209 void test_binary_plus_integer() { |
205 Object value = _getConstantValue("2 + 3"); | 210 Object value = _getConstantValue("2 + 3"); |
206 expect(value, 5); | 211 expect(value, 5); |
207 } | 212 } |
208 | 213 |
| 214 void test_binary_plus_string_int() { |
| 215 Object value = _getConstantValue("5 + 'world'"); |
| 216 expect(value, ConstantEvaluator.NOT_A_CONSTANT); |
| 217 } |
| 218 |
| 219 void test_binary_plus_int_string() { |
| 220 Object value = _getConstantValue("'world' + 5"); |
| 221 expect(value, ConstantEvaluator.NOT_A_CONSTANT); |
| 222 } |
| 223 |
| 224 void test_binary_plus_double_string() { |
| 225 Object value = _getConstantValue("'world' + 5.5"); |
| 226 expect(value, ConstantEvaluator.NOT_A_CONSTANT); |
| 227 } |
| 228 |
| 229 void test_binary_plus_string_double() { |
| 230 Object value = _getConstantValue("5.5 + 'world'"); |
| 231 expect(value, ConstantEvaluator.NOT_A_CONSTANT); |
| 232 } |
| 233 |
209 void test_binary_remainder_double() { | 234 void test_binary_remainder_double() { |
210 Object value = _getConstantValue("3.2 % 2.3"); | 235 Object value = _getConstantValue("3.2 % 2.3"); |
211 expect(value, 3.2 % 2.3); | 236 expect(value, 3.2 % 2.3); |
212 } | 237 } |
213 | 238 |
214 void test_binary_remainder_integer() { | 239 void test_binary_remainder_integer() { |
215 Object value = _getConstantValue("8 % 3"); | 240 Object value = _getConstantValue("8 % 3"); |
216 expect(value, 2); | 241 expect(value, 2); |
217 } | 242 } |
218 | 243 |
(...skipping 5549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5768 /** | 5793 /** |
5769 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when | 5794 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when |
5770 * visiting the given [node]. | 5795 * visiting the given [node]. |
5771 */ | 5796 */ |
5772 void _assertSource(String expectedSource, AstNode node) { | 5797 void _assertSource(String expectedSource, AstNode node) { |
5773 PrintStringWriter writer = new PrintStringWriter(); | 5798 PrintStringWriter writer = new PrintStringWriter(); |
5774 node.accept(new ToSourceVisitor(writer)); | 5799 node.accept(new ToSourceVisitor(writer)); |
5775 expect(writer.toString(), expectedSource); | 5800 expect(writer.toString(), expectedSource); |
5776 } | 5801 } |
5777 } | 5802 } |
OLD | NEW |