Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: pkg/analyzer/test/generated/simple_resolver_test.dart

Issue 1842563003: Format everything in analyzer (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.generated.simple_resolver_test; 5 library analyzer.test.generated.simple_resolver_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/visitor.dart'; 8 import 'package:analyzer/dart/ast/visitor.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void main() { 44 void main() {
45 new C().x += 1; 45 new C().x += 1;
46 } 46 }
47 '''); 47 ''');
48 LibraryElement library = resolve2(source); 48 LibraryElement library = resolve2(source);
49 assertNoErrors(source); 49 assertNoErrors(source);
50 verify([source]); 50 verify([source]);
51 // Verify that both the getter and setter for "x" in "new C().x" refer to 51 // Verify that both the getter and setter for "x" in "new C().x" refer to
52 // the accessors defined in M2. 52 // the accessors defined in M2.
53 FunctionDeclaration main = 53 FunctionDeclaration main =
54 library.definingCompilationUnit.functions[0].computeNode(); 54 library.definingCompilationUnit.functions[0].computeNode();
55 BlockFunctionBody body = main.functionExpression.body; 55 BlockFunctionBody body = main.functionExpression.body;
56 ExpressionStatement stmt = body.block.statements[0]; 56 ExpressionStatement stmt = body.block.statements[0];
57 AssignmentExpression assignment = stmt.expression; 57 AssignmentExpression assignment = stmt.expression;
58 PropertyAccess propertyAccess = assignment.leftHandSide; 58 PropertyAccess propertyAccess = assignment.leftHandSide;
59 expect( 59 expect(
60 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2'); 60 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2');
61 expect( 61 expect(
62 propertyAccess 62 propertyAccess
63 .propertyName.auxiliaryElements.staticElement.enclosingElement.name, 63 .propertyName.auxiliaryElements.staticElement.enclosingElement.name,
64 'M2'); 64 'M2');
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 }'''); 189 }''');
190 LibraryElement library = resolve2(source); 190 LibraryElement library = resolve2(source);
191 CompilationUnitElement unit = library.definingCompilationUnit; 191 CompilationUnitElement unit = library.definingCompilationUnit;
192 // find "a.sss = 0" 192 // find "a.sss = 0"
193 AssignmentExpression assignment; 193 AssignmentExpression assignment;
194 { 194 {
195 FunctionElement mainElement = unit.functions[0]; 195 FunctionElement mainElement = unit.functions[0];
196 FunctionBody mainBody = mainElement.computeNode().functionExpression.body; 196 FunctionBody mainBody = mainElement.computeNode().functionExpression.body;
197 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; 197 Statement statement = (mainBody as BlockFunctionBody).block.statements[1];
198 ExpressionStatement expressionStatement = 198 ExpressionStatement expressionStatement =
199 statement as ExpressionStatement; 199 statement as ExpressionStatement;
200 assignment = expressionStatement.expression as AssignmentExpression; 200 assignment = expressionStatement.expression as AssignmentExpression;
201 } 201 }
202 // get parameter 202 // get parameter
203 Expression rhs = assignment.rightHandSide; 203 Expression rhs = assignment.rightHandSide;
204 expect(rhs.staticParameterElement, isNull); 204 expect(rhs.staticParameterElement, isNull);
205 ParameterElement parameter = rhs.propagatedParameterElement; 205 ParameterElement parameter = rhs.propagatedParameterElement;
206 expect(parameter, isNotNull); 206 expect(parameter, isNotNull);
207 expect(parameter.displayName, "x"); 207 expect(parameter.displayName, "x");
208 // validate 208 // validate
209 ClassElement classA = unit.types[0]; 209 ClassElement classA = unit.types[0];
(...skipping 15 matching lines...) Expand all
225 }'''); 225 }''');
226 LibraryElement library = resolve2(source); 226 LibraryElement library = resolve2(source);
227 CompilationUnitElement unit = library.definingCompilationUnit; 227 CompilationUnitElement unit = library.definingCompilationUnit;
228 // find "a.b.sss = 0" 228 // find "a.b.sss = 0"
229 AssignmentExpression assignment; 229 AssignmentExpression assignment;
230 { 230 {
231 FunctionElement mainElement = unit.functions[0]; 231 FunctionElement mainElement = unit.functions[0];
232 FunctionBody mainBody = mainElement.computeNode().functionExpression.body; 232 FunctionBody mainBody = mainElement.computeNode().functionExpression.body;
233 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; 233 Statement statement = (mainBody as BlockFunctionBody).block.statements[1];
234 ExpressionStatement expressionStatement = 234 ExpressionStatement expressionStatement =
235 statement as ExpressionStatement; 235 statement as ExpressionStatement;
236 assignment = expressionStatement.expression as AssignmentExpression; 236 assignment = expressionStatement.expression as AssignmentExpression;
237 } 237 }
238 // get parameter 238 // get parameter
239 Expression rhs = assignment.rightHandSide; 239 Expression rhs = assignment.rightHandSide;
240 expect(rhs.staticParameterElement, isNull); 240 expect(rhs.staticParameterElement, isNull);
241 ParameterElement parameter = rhs.propagatedParameterElement; 241 ParameterElement parameter = rhs.propagatedParameterElement;
242 expect(parameter, isNotNull); 242 expect(parameter, isNotNull);
243 expect(parameter.displayName, "x"); 243 expect(parameter.displayName, "x");
244 // validate 244 // validate
245 ClassElement classB = unit.types[1]; 245 ClassElement classB = unit.types[1];
(...skipping 12 matching lines...) Expand all
258 }'''); 258 }''');
259 LibraryElement library = resolve2(source); 259 LibraryElement library = resolve2(source);
260 CompilationUnitElement unit = library.definingCompilationUnit; 260 CompilationUnitElement unit = library.definingCompilationUnit;
261 // find "a.sss = 0" 261 // find "a.sss = 0"
262 AssignmentExpression assignment; 262 AssignmentExpression assignment;
263 { 263 {
264 FunctionElement mainElement = unit.functions[0]; 264 FunctionElement mainElement = unit.functions[0];
265 FunctionBody mainBody = mainElement.computeNode().functionExpression.body; 265 FunctionBody mainBody = mainElement.computeNode().functionExpression.body;
266 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; 266 Statement statement = (mainBody as BlockFunctionBody).block.statements[1];
267 ExpressionStatement expressionStatement = 267 ExpressionStatement expressionStatement =
268 statement as ExpressionStatement; 268 statement as ExpressionStatement;
269 assignment = expressionStatement.expression as AssignmentExpression; 269 assignment = expressionStatement.expression as AssignmentExpression;
270 } 270 }
271 // get parameter 271 // get parameter
272 Expression rhs = assignment.rightHandSide; 272 Expression rhs = assignment.rightHandSide;
273 ParameterElement parameter = rhs.staticParameterElement; 273 ParameterElement parameter = rhs.staticParameterElement;
274 expect(parameter, isNotNull); 274 expect(parameter, isNotNull);
275 expect(parameter.displayName, "x"); 275 expect(parameter.displayName, "x");
276 // validate 276 // validate
277 ClassElement classA = unit.types[0]; 277 ClassElement classA = unit.types[0];
278 PropertyAccessorElement setter = classA.accessors[0]; 278 PropertyAccessorElement setter = classA.accessors[0];
(...skipping 14 matching lines...) Expand all
293 }'''); 293 }''');
294 LibraryElement library = resolve2(source); 294 LibraryElement library = resolve2(source);
295 CompilationUnitElement unit = library.definingCompilationUnit; 295 CompilationUnitElement unit = library.definingCompilationUnit;
296 // find "a.b.sss = 0" 296 // find "a.b.sss = 0"
297 AssignmentExpression assignment; 297 AssignmentExpression assignment;
298 { 298 {
299 FunctionElement mainElement = unit.functions[0]; 299 FunctionElement mainElement = unit.functions[0];
300 FunctionBody mainBody = mainElement.computeNode().functionExpression.body; 300 FunctionBody mainBody = mainElement.computeNode().functionExpression.body;
301 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; 301 Statement statement = (mainBody as BlockFunctionBody).block.statements[1];
302 ExpressionStatement expressionStatement = 302 ExpressionStatement expressionStatement =
303 statement as ExpressionStatement; 303 statement as ExpressionStatement;
304 assignment = expressionStatement.expression as AssignmentExpression; 304 assignment = expressionStatement.expression as AssignmentExpression;
305 } 305 }
306 // get parameter 306 // get parameter
307 Expression rhs = assignment.rightHandSide; 307 Expression rhs = assignment.rightHandSide;
308 ParameterElement parameter = rhs.staticParameterElement; 308 ParameterElement parameter = rhs.staticParameterElement;
309 expect(parameter, isNotNull); 309 expect(parameter, isNotNull);
310 expect(parameter.displayName, "x"); 310 expect(parameter.displayName, "x");
311 // validate 311 // validate
312 ClassElement classB = unit.types[1]; 312 ClassElement classB = unit.types[1];
313 PropertyAccessorElement setter = classB.accessors[0]; 313 PropertyAccessorElement setter = classB.accessors[0];
(...skipping 10 matching lines...) Expand all
324 break loop1; 324 break loop1;
325 break loop2; 325 break loop2;
326 } 326 }
327 } 327 }
328 } 328 }
329 '''; 329 ''';
330 CompilationUnit unit = resolveSource(text); 330 CompilationUnit unit = resolveSource(text);
331 WhileStatement whileStatement = EngineTestCase.findNode( 331 WhileStatement whileStatement = EngineTestCase.findNode(
332 unit, text, 'while (true)', (n) => n is WhileStatement); 332 unit, text, 'while (true)', (n) => n is WhileStatement);
333 ForStatement forStatement = 333 ForStatement forStatement =
334 EngineTestCase.findNode(unit, text, 'for', (n) => n is ForStatement); 334 EngineTestCase.findNode(unit, text, 'for', (n) => n is ForStatement);
335 BreakStatement break1 = EngineTestCase.findNode( 335 BreakStatement break1 = EngineTestCase.findNode(
336 unit, text, 'break loop1', (n) => n is BreakStatement); 336 unit, text, 'break loop1', (n) => n is BreakStatement);
337 BreakStatement break2 = EngineTestCase.findNode( 337 BreakStatement break2 = EngineTestCase.findNode(
338 unit, text, 'break loop2', (n) => n is BreakStatement); 338 unit, text, 'break loop2', (n) => n is BreakStatement);
339 expect(break1.target, same(whileStatement)); 339 expect(break1.target, same(whileStatement));
340 expect(break2.target, same(forStatement)); 340 expect(break2.target, same(forStatement));
341 } 341 }
342 342
343 void test_breakTarget_unlabeledBreakFromDo() { 343 void test_breakTarget_unlabeledBreakFromDo() {
344 String text = r''' 344 String text = r'''
345 void f() { 345 void f() {
346 do { 346 do {
347 break; 347 break;
348 } while (true); 348 } while (true);
349 } 349 }
350 '''; 350 ''';
351 CompilationUnit unit = resolveSource(text); 351 CompilationUnit unit = resolveSource(text);
352 DoStatement doStatement = 352 DoStatement doStatement =
353 EngineTestCase.findNode(unit, text, 'do', (n) => n is DoStatement); 353 EngineTestCase.findNode(unit, text, 'do', (n) => n is DoStatement);
354 BreakStatement breakStatement = EngineTestCase.findNode( 354 BreakStatement breakStatement = EngineTestCase.findNode(
355 unit, text, 'break', (n) => n is BreakStatement); 355 unit, text, 'break', (n) => n is BreakStatement);
356 expect(breakStatement.target, same(doStatement)); 356 expect(breakStatement.target, same(doStatement));
357 } 357 }
358 358
359 void test_breakTarget_unlabeledBreakFromFor() { 359 void test_breakTarget_unlabeledBreakFromFor() {
360 String text = r''' 360 String text = r'''
361 void f() { 361 void f() {
362 for (int i = 0; i < 10; i++) { 362 for (int i = 0; i < 10; i++) {
363 break; 363 break;
364 } 364 }
365 } 365 }
366 '''; 366 ''';
367 CompilationUnit unit = resolveSource(text); 367 CompilationUnit unit = resolveSource(text);
368 ForStatement forStatement = 368 ForStatement forStatement =
369 EngineTestCase.findNode(unit, text, 'for', (n) => n is ForStatement); 369 EngineTestCase.findNode(unit, text, 'for', (n) => n is ForStatement);
370 BreakStatement breakStatement = EngineTestCase.findNode( 370 BreakStatement breakStatement = EngineTestCase.findNode(
371 unit, text, 'break', (n) => n is BreakStatement); 371 unit, text, 'break', (n) => n is BreakStatement);
372 expect(breakStatement.target, same(forStatement)); 372 expect(breakStatement.target, same(forStatement));
373 } 373 }
374 374
375 void test_breakTarget_unlabeledBreakFromForEach() { 375 void test_breakTarget_unlabeledBreakFromForEach() {
376 String text = r''' 376 String text = r'''
377 void f() { 377 void f() {
378 for (x in []) { 378 for (x in []) {
379 break; 379 break;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 continue loop1; 510 continue loop1;
511 continue loop2; 511 continue loop2;
512 } 512 }
513 } 513 }
514 } 514 }
515 '''; 515 ''';
516 CompilationUnit unit = resolveSource(text); 516 CompilationUnit unit = resolveSource(text);
517 WhileStatement whileStatement = EngineTestCase.findNode( 517 WhileStatement whileStatement = EngineTestCase.findNode(
518 unit, text, 'while (true)', (n) => n is WhileStatement); 518 unit, text, 'while (true)', (n) => n is WhileStatement);
519 ForStatement forStatement = 519 ForStatement forStatement =
520 EngineTestCase.findNode(unit, text, 'for', (n) => n is ForStatement); 520 EngineTestCase.findNode(unit, text, 'for', (n) => n is ForStatement);
521 ContinueStatement continue1 = EngineTestCase.findNode( 521 ContinueStatement continue1 = EngineTestCase.findNode(
522 unit, text, 'continue loop1', (n) => n is ContinueStatement); 522 unit, text, 'continue loop1', (n) => n is ContinueStatement);
523 ContinueStatement continue2 = EngineTestCase.findNode( 523 ContinueStatement continue2 = EngineTestCase.findNode(
524 unit, text, 'continue loop2', (n) => n is ContinueStatement); 524 unit, text, 'continue loop2', (n) => n is ContinueStatement);
525 expect(continue1.target, same(whileStatement)); 525 expect(continue1.target, same(whileStatement));
526 expect(continue2.target, same(forStatement)); 526 expect(continue2.target, same(forStatement));
527 } 527 }
528 528
529 void test_continueTarget_unlabeledContinueFromDo() { 529 void test_continueTarget_unlabeledContinueFromDo() {
530 String text = r''' 530 String text = r'''
531 void f() { 531 void f() {
532 do { 532 do {
533 continue; 533 continue;
534 } while (true); 534 } while (true);
535 } 535 }
536 '''; 536 ''';
537 CompilationUnit unit = resolveSource(text); 537 CompilationUnit unit = resolveSource(text);
538 DoStatement doStatement = 538 DoStatement doStatement =
539 EngineTestCase.findNode(unit, text, 'do', (n) => n is DoStatement); 539 EngineTestCase.findNode(unit, text, 'do', (n) => n is DoStatement);
540 ContinueStatement continueStatement = EngineTestCase.findNode( 540 ContinueStatement continueStatement = EngineTestCase.findNode(
541 unit, text, 'continue', (n) => n is ContinueStatement); 541 unit, text, 'continue', (n) => n is ContinueStatement);
542 expect(continueStatement.target, same(doStatement)); 542 expect(continueStatement.target, same(doStatement));
543 } 543 }
544 544
545 void test_continueTarget_unlabeledContinueFromFor() { 545 void test_continueTarget_unlabeledContinueFromFor() {
546 String text = r''' 546 String text = r'''
547 void f() { 547 void f() {
548 for (int i = 0; i < 10; i++) { 548 for (int i = 0; i < 10; i++) {
549 continue; 549 continue;
550 } 550 }
551 } 551 }
552 '''; 552 ''';
553 CompilationUnit unit = resolveSource(text); 553 CompilationUnit unit = resolveSource(text);
554 ForStatement forStatement = 554 ForStatement forStatement =
555 EngineTestCase.findNode(unit, text, 'for', (n) => n is ForStatement); 555 EngineTestCase.findNode(unit, text, 'for', (n) => n is ForStatement);
556 ContinueStatement continueStatement = EngineTestCase.findNode( 556 ContinueStatement continueStatement = EngineTestCase.findNode(
557 unit, text, 'continue', (n) => n is ContinueStatement); 557 unit, text, 'continue', (n) => n is ContinueStatement);
558 expect(continueStatement.target, same(forStatement)); 558 expect(continueStatement.target, same(forStatement));
559 } 559 }
560 560
561 void test_continueTarget_unlabeledContinueFromForEach() { 561 void test_continueTarget_unlabeledContinueFromForEach() {
562 String text = r''' 562 String text = r'''
563 void f() { 563 void f() {
564 for (x in []) { 564 for (x in []) {
565 continue; 565 continue;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 void main() { 832 void main() {
833 var y = new C().x; 833 var y = new C().x;
834 } 834 }
835 '''); 835 ''');
836 LibraryElement library = resolve2(source); 836 LibraryElement library = resolve2(source);
837 assertNoErrors(source); 837 assertNoErrors(source);
838 verify([source]); 838 verify([source]);
839 // Verify that the getter for "x" in "new C().x" refers to the getter 839 // Verify that the getter for "x" in "new C().x" refers to the getter
840 // defined in M2. 840 // defined in M2.
841 FunctionDeclaration main = 841 FunctionDeclaration main =
842 library.definingCompilationUnit.functions[0].computeNode(); 842 library.definingCompilationUnit.functions[0].computeNode();
843 BlockFunctionBody body = main.functionExpression.body; 843 BlockFunctionBody body = main.functionExpression.body;
844 VariableDeclarationStatement stmt = body.block.statements[0]; 844 VariableDeclarationStatement stmt = body.block.statements[0];
845 PropertyAccess propertyAccess = stmt.variables.variables[0].initializer; 845 PropertyAccess propertyAccess = stmt.variables.variables[0].initializer;
846 expect( 846 expect(
847 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2'); 847 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2');
848 } 848 }
849 849
850 void test_getterAndSetterWithDifferentTypes() { 850 void test_getterAndSetterWithDifferentTypes() {
851 Source source = addSource(r''' 851 Source source = addSource(r'''
852 class A { 852 class A {
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 void test_localVariable_types_invoked() { 1190 void test_localVariable_types_invoked() {
1191 Source source = addSource(r''' 1191 Source source = addSource(r'''
1192 const A = null; 1192 const A = null;
1193 main() { 1193 main() {
1194 var myVar = (int p) => 'foo'; 1194 var myVar = (int p) => 'foo';
1195 myVar(42); 1195 myVar(42);
1196 }'''); 1196 }''');
1197 LibraryElement library = resolve2(source); 1197 LibraryElement library = resolve2(source);
1198 expect(library, isNotNull); 1198 expect(library, isNotNull);
1199 CompilationUnit unit = 1199 CompilationUnit unit =
1200 analysisContext.resolveCompilationUnit(source, library); 1200 analysisContext.resolveCompilationUnit(source, library);
1201 expect(unit, isNotNull); 1201 expect(unit, isNotNull);
1202 List<bool> found = [false]; 1202 List<bool> found = [false];
1203 List<CaughtException> thrownException = new List<CaughtException>(1); 1203 List<CaughtException> thrownException = new List<CaughtException>(1);
1204 unit.accept(new _SimpleResolverTest_localVariable_types_invoked( 1204 unit.accept(new _SimpleResolverTest_localVariable_types_invoked(
1205 this, found, thrownException)); 1205 this, found, thrownException));
1206 if (thrownException[0] != null) { 1206 if (thrownException[0] != null) {
1207 throw new AnalysisException( 1207 throw new AnalysisException(
1208 "Exception", new CaughtException(thrownException[0], null)); 1208 "Exception", new CaughtException(thrownException[0], null));
1209 } 1209 }
1210 expect(found[0], isTrue); 1210 expect(found[0], isTrue);
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 class C extends B with M1, M2 {} 1463 class C extends B with M1, M2 {}
1464 void main() { 1464 void main() {
1465 new C().f(); 1465 new C().f();
1466 } 1466 }
1467 '''); 1467 ''');
1468 LibraryElement library = resolve2(source); 1468 LibraryElement library = resolve2(source);
1469 assertNoErrors(source); 1469 assertNoErrors(source);
1470 verify([source]); 1470 verify([source]);
1471 // Verify that the "f" in "new C().f()" refers to the "f" defined in M2. 1471 // Verify that the "f" in "new C().f()" refers to the "f" defined in M2.
1472 FunctionDeclaration main = 1472 FunctionDeclaration main =
1473 library.definingCompilationUnit.functions[0].computeNode(); 1473 library.definingCompilationUnit.functions[0].computeNode();
1474 BlockFunctionBody body = main.functionExpression.body; 1474 BlockFunctionBody body = main.functionExpression.body;
1475 ExpressionStatement stmt = body.block.statements[0]; 1475 ExpressionStatement stmt = body.block.statements[0];
1476 MethodInvocation expr = stmt.expression; 1476 MethodInvocation expr = stmt.expression;
1477 expect(expr.methodName.staticElement.enclosingElement.name, 'M2'); 1477 expect(expr.methodName.staticElement.enclosingElement.name, 'M2');
1478 } 1478 }
1479 1479
1480 void test_method_fromMixins_bare_identifier() { 1480 void test_method_fromMixins_bare_identifier() {
1481 Source source = addSource(''' 1481 Source source = addSource('''
1482 class B {} 1482 class B {}
1483 class M1 { 1483 class M1 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 void main() { 1518 void main() {
1519 new C().f(); 1519 new C().f();
1520 } 1520 }
1521 '''); 1521 ''');
1522 LibraryElement library = resolve2(source); 1522 LibraryElement library = resolve2(source);
1523 assertNoErrors(source); 1523 assertNoErrors(source);
1524 verify([source]); 1524 verify([source]);
1525 // Verify that the call to f() in "new C().f()" refers to the method 1525 // Verify that the call to f() in "new C().f()" refers to the method
1526 // defined in M2. 1526 // defined in M2.
1527 FunctionDeclaration main = 1527 FunctionDeclaration main =
1528 library.definingCompilationUnit.functions[0].computeNode(); 1528 library.definingCompilationUnit.functions[0].computeNode();
1529 BlockFunctionBody body = main.functionExpression.body; 1529 BlockFunctionBody body = main.functionExpression.body;
1530 ExpressionStatement stmt = body.block.statements[0]; 1530 ExpressionStatement stmt = body.block.statements[0];
1531 MethodInvocation invocation = stmt.expression; 1531 MethodInvocation invocation = stmt.expression;
1532 expect(invocation.methodName.staticElement.enclosingElement.name, 'M2'); 1532 expect(invocation.methodName.staticElement.enclosingElement.name, 'M2');
1533 } 1533 }
1534 1534
1535 void test_method_fromSuperclassMixin() { 1535 void test_method_fromSuperclassMixin() {
1536 Source source = addSource(r''' 1536 Source source = addSource(r'''
1537 class A { 1537 class A {
1538 void m1() {} 1538 void m1() {}
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 void main() { 1635 void main() {
1636 new C().x = 1; 1636 new C().x = 1;
1637 } 1637 }
1638 '''); 1638 ''');
1639 LibraryElement library = resolve2(source); 1639 LibraryElement library = resolve2(source);
1640 assertNoErrors(source); 1640 assertNoErrors(source);
1641 verify([source]); 1641 verify([source]);
1642 // Verify that the setter for "x" in "new C().x" refers to the setter 1642 // Verify that the setter for "x" in "new C().x" refers to the setter
1643 // defined in M2. 1643 // defined in M2.
1644 FunctionDeclaration main = 1644 FunctionDeclaration main =
1645 library.definingCompilationUnit.functions[0].computeNode(); 1645 library.definingCompilationUnit.functions[0].computeNode();
1646 BlockFunctionBody body = main.functionExpression.body; 1646 BlockFunctionBody body = main.functionExpression.body;
1647 ExpressionStatement stmt = body.block.statements[0]; 1647 ExpressionStatement stmt = body.block.statements[0];
1648 AssignmentExpression assignment = stmt.expression; 1648 AssignmentExpression assignment = stmt.expression;
1649 PropertyAccess propertyAccess = assignment.leftHandSide; 1649 PropertyAccess propertyAccess = assignment.leftHandSide;
1650 expect( 1650 expect(
1651 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2'); 1651 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2');
1652 } 1652 }
1653 1653
1654 void test_setter_inherited() { 1654 void test_setter_inherited() {
1655 Source source = addSource(r''' 1655 Source source = addSource(r'''
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 * valid 1701 * valid
1702 */ 1702 */
1703 void _validateArgumentResolution(Source source, List<int> indices) { 1703 void _validateArgumentResolution(Source source, List<int> indices) {
1704 LibraryElement library = resolve2(source); 1704 LibraryElement library = resolve2(source);
1705 expect(library, isNotNull); 1705 expect(library, isNotNull);
1706 ClassElement classElement = library.definingCompilationUnit.types[0]; 1706 ClassElement classElement = library.definingCompilationUnit.types[0];
1707 List<ParameterElement> parameters = classElement.methods[1].parameters; 1707 List<ParameterElement> parameters = classElement.methods[1].parameters;
1708 CompilationUnit unit = resolveCompilationUnit(source, library); 1708 CompilationUnit unit = resolveCompilationUnit(source, library);
1709 expect(unit, isNotNull); 1709 expect(unit, isNotNull);
1710 ClassDeclaration classDeclaration = 1710 ClassDeclaration classDeclaration =
1711 unit.declarations[0] as ClassDeclaration; 1711 unit.declarations[0] as ClassDeclaration;
1712 MethodDeclaration methodDeclaration = 1712 MethodDeclaration methodDeclaration =
1713 classDeclaration.members[0] as MethodDeclaration; 1713 classDeclaration.members[0] as MethodDeclaration;
1714 Block block = (methodDeclaration.body as BlockFunctionBody).block; 1714 Block block = (methodDeclaration.body as BlockFunctionBody).block;
1715 ExpressionStatement statement = block.statements[0] as ExpressionStatement; 1715 ExpressionStatement statement = block.statements[0] as ExpressionStatement;
1716 MethodInvocation invocation = statement.expression as MethodInvocation; 1716 MethodInvocation invocation = statement.expression as MethodInvocation;
1717 NodeList<Expression> arguments = invocation.argumentList.arguments; 1717 NodeList<Expression> arguments = invocation.argumentList.arguments;
1718 int argumentCount = arguments.length; 1718 int argumentCount = arguments.length;
1719 expect(argumentCount, indices.length); 1719 expect(argumentCount, indices.length);
1720 for (int i = 0; i < argumentCount; i++) { 1720 for (int i = 0; i < argumentCount; i++) {
1721 Expression argument = arguments[i]; 1721 Expression argument = arguments[i];
1722 ParameterElement element = argument.staticParameterElement; 1722 ParameterElement element = argument.staticParameterElement;
1723 int index = indices[i]; 1723 int index = indices[i];
(...skipping 29 matching lines...) Expand all
1753 // check propagated type 1753 // check propagated type
1754 FunctionType propagatedType = node.propagatedType as FunctionType; 1754 FunctionType propagatedType = node.propagatedType as FunctionType;
1755 expect(propagatedType.returnType, test.typeProvider.stringType); 1755 expect(propagatedType.returnType, test.typeProvider.stringType);
1756 } on AnalysisException catch (e, stackTrace) { 1756 } on AnalysisException catch (e, stackTrace) {
1757 thrownException[0] = new CaughtException(e, stackTrace); 1757 thrownException[0] = new CaughtException(e, stackTrace);
1758 } 1758 }
1759 } 1759 }
1760 return null; 1760 return null;
1761 } 1761 }
1762 } 1762 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test_case.dart ('k') | pkg/analyzer/test/generated/static_type_analyzer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698