| 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 engine.resolver_test; | 5 library engine.resolver_test; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 void test_visitAssignmentExpression_simple() { | 1268 void test_visitAssignmentExpression_simple() { |
| 1269 AssignmentExpression expression = AstFactory.assignmentExpression( | 1269 AssignmentExpression expression = AstFactory.assignmentExpression( |
| 1270 AstFactory.identifier3("x"), | 1270 AstFactory.identifier3("x"), |
| 1271 TokenType.EQ, | 1271 TokenType.EQ, |
| 1272 AstFactory.integer(0)); | 1272 AstFactory.integer(0)); |
| 1273 _resolveNode(expression); | 1273 _resolveNode(expression); |
| 1274 expect(expression.staticElement, isNull); | 1274 expect(expression.staticElement, isNull); |
| 1275 _listener.assertNoErrors(); | 1275 _listener.assertNoErrors(); |
| 1276 } | 1276 } |
| 1277 | 1277 |
| 1278 void test_visitBinaryExpression() { | 1278 void test_visitBinaryExpression_bangEq() { |
| 1279 // String i; |
| 1280 // var j; |
| 1281 // i == j |
| 1282 InterfaceType stringType = _typeProvider.stringType; |
| 1283 SimpleIdentifier left = AstFactory.identifier3("i"); |
| 1284 left.staticType = stringType; |
| 1285 BinaryExpression expression = |
| 1286 AstFactory.binaryExpression(left, TokenType.BANG_EQ, AstFactory.identifi
er3("j")); |
| 1287 _resolveNode(expression); |
| 1288 var stringElement = stringType.element; |
| 1289 expect(expression.staticElement, isNotNull); |
| 1290 expect(expression.staticElement, stringElement.lookUpMethod(TokenType.EQ_EQ.
lexeme, stringElement.library)); |
| 1291 expect(expression.propagatedElement, isNull); |
| 1292 _listener.assertNoErrors(); |
| 1293 } |
| 1294 |
| 1295 void test_visitBinaryExpression_eq() { |
| 1296 // String i; |
| 1297 // var j; |
| 1298 // i == j |
| 1299 InterfaceType stringType = _typeProvider.stringType; |
| 1300 SimpleIdentifier left = AstFactory.identifier3("i"); |
| 1301 left.staticType = stringType; |
| 1302 BinaryExpression expression = |
| 1303 AstFactory.binaryExpression(left, TokenType.EQ_EQ, AstFactory.identifier
3("j")); |
| 1304 _resolveNode(expression); |
| 1305 var stringElement = stringType.element; |
| 1306 expect(expression.staticElement, stringElement.lookUpMethod(TokenType.EQ_EQ.
lexeme, stringElement.library)); |
| 1307 expect(expression.propagatedElement, isNull); |
| 1308 _listener.assertNoErrors(); |
| 1309 } |
| 1310 |
| 1311 void test_visitBinaryExpression_plus() { |
| 1279 // num i; | 1312 // num i; |
| 1280 // var j; | 1313 // var j; |
| 1281 // i + j | 1314 // i + j |
| 1282 InterfaceType numType = _typeProvider.numType; | 1315 InterfaceType numType = _typeProvider.numType; |
| 1283 SimpleIdentifier left = AstFactory.identifier3("i"); | 1316 SimpleIdentifier left = AstFactory.identifier3("i"); |
| 1284 left.staticType = numType; | 1317 left.staticType = numType; |
| 1285 BinaryExpression expression = | 1318 BinaryExpression expression = |
| 1286 AstFactory.binaryExpression(left, TokenType.PLUS, AstFactory.identifier3
("j")); | 1319 AstFactory.binaryExpression(left, TokenType.PLUS, AstFactory.identifier3
("j")); |
| 1287 _resolveNode(expression); | 1320 _resolveNode(expression); |
| 1288 expect(expression.staticElement, getMethod(numType, "+")); | 1321 expect(expression.staticElement, getMethod(numType, "+")); |
| 1289 expect(expression.propagatedElement, isNull); | 1322 expect(expression.propagatedElement, isNull); |
| 1290 _listener.assertNoErrors(); | 1323 _listener.assertNoErrors(); |
| 1291 } | 1324 } |
| 1292 | 1325 |
| 1293 void test_visitBinaryExpression_propagatedElement() { | 1326 void test_visitBinaryExpression_plus_propagatedElement() { |
| 1294 // var i = 1; | 1327 // var i = 1; |
| 1295 // var j; | 1328 // var j; |
| 1296 // i + j | 1329 // i + j |
| 1297 InterfaceType numType = _typeProvider.numType; | 1330 InterfaceType numType = _typeProvider.numType; |
| 1298 SimpleIdentifier left = AstFactory.identifier3("i"); | 1331 SimpleIdentifier left = AstFactory.identifier3("i"); |
| 1299 left.propagatedType = numType; | 1332 left.propagatedType = numType; |
| 1300 BinaryExpression expression = | 1333 BinaryExpression expression = |
| 1301 AstFactory.binaryExpression(left, TokenType.PLUS, AstFactory.identifier3
("j")); | 1334 AstFactory.binaryExpression(left, TokenType.PLUS, AstFactory.identifier3
("j")); |
| 1302 _resolveNode(expression); | 1335 _resolveNode(expression); |
| 1303 expect(expression.staticElement, isNull); | 1336 expect(expression.staticElement, isNull); |
| (...skipping 12130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13434 // check propagated type | 13467 // check propagated type |
| 13435 FunctionType propagatedType = node.propagatedType as FunctionType; | 13468 FunctionType propagatedType = node.propagatedType as FunctionType; |
| 13436 expect(propagatedType.returnType, test.typeProvider.stringType); | 13469 expect(propagatedType.returnType, test.typeProvider.stringType); |
| 13437 } on AnalysisException catch (e, stackTrace) { | 13470 } on AnalysisException catch (e, stackTrace) { |
| 13438 thrownException[0] = new CaughtException(e, stackTrace); | 13471 thrownException[0] = new CaughtException(e, stackTrace); |
| 13439 } | 13472 } |
| 13440 } | 13473 } |
| 13441 return null; | 13474 return null; |
| 13442 } | 13475 } |
| 13443 } | 13476 } |
| OLD | NEW |