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_mixed() { | |
scheglov
2016/12/22 23:22:54
Maybe worth to test when both case for num/string
mfairhurst
2016/12/23 00:04:41
Acknowledged.
| |
215 Object value = _getConstantValue("5 + 'world'"); | |
216 expect(value, ConstantEvaluator.NOT_A_CONSTANT); | |
217 } | |
218 | |
209 void test_binary_remainder_double() { | 219 void test_binary_remainder_double() { |
210 Object value = _getConstantValue("3.2 % 2.3"); | 220 Object value = _getConstantValue("3.2 % 2.3"); |
211 expect(value, 3.2 % 2.3); | 221 expect(value, 3.2 % 2.3); |
212 } | 222 } |
213 | 223 |
214 void test_binary_remainder_integer() { | 224 void test_binary_remainder_integer() { |
215 Object value = _getConstantValue("8 % 3"); | 225 Object value = _getConstantValue("8 % 3"); |
216 expect(value, 2); | 226 expect(value, 2); |
217 } | 227 } |
218 | 228 |
(...skipping 5549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5768 /** | 5778 /** |
5769 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when | 5779 * Assert that a `ToSourceVisitor` will produce the [expectedSource] when |
5770 * visiting the given [node]. | 5780 * visiting the given [node]. |
5771 */ | 5781 */ |
5772 void _assertSource(String expectedSource, AstNode node) { | 5782 void _assertSource(String expectedSource, AstNode node) { |
5773 PrintStringWriter writer = new PrintStringWriter(); | 5783 PrintStringWriter writer = new PrintStringWriter(); |
5774 node.accept(new ToSourceVisitor(writer)); | 5784 node.accept(new ToSourceVisitor(writer)); |
5775 expect(writer.toString(), expectedSource); | 5785 expect(writer.toString(), expectedSource); |
5776 } | 5786 } |
5777 } | 5787 } |
OLD | NEW |