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

Side by Side Diff: pkg/analyzer/test/src/dart/constant/evaluation_test.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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.constant_test; 5 library analyzer.test.constant_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/context/declared_variables.dart'; 9 import 'package:analyzer/context/declared_variables.dart';
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 _validate(true, (members[0] as TopLevelVariableDeclaration).variables); 309 _validate(true, (members[0] as TopLevelVariableDeclaration).variables);
310 _validate(true, (members[1] as TopLevelVariableDeclaration).variables); 310 _validate(true, (members[1] as TopLevelVariableDeclaration).variables);
311 } 311 }
312 312
313 test_computeValues_empty() async { 313 test_computeValues_empty() async {
314 ConstantValueComputer computer = _makeConstantValueComputer(); 314 ConstantValueComputer computer = _makeConstantValueComputer();
315 computer.computeValues(); 315 computer.computeValues();
316 } 316 }
317 317
318 test_computeValues_multipleSources() async { 318 test_computeValues_multipleSources() async {
319 Source librarySource = addNamedSource( 319 Source librarySource = addNamedSource("/lib.dart", r'''
320 "/lib.dart",
321 r'''
322 library lib; 320 library lib;
323 part 'part.dart'; 321 part 'part.dart';
324 const int c = b; 322 const int c = b;
325 const int a = 0;'''); 323 const int a = 0;''');
326 Source partSource = addNamedSource( 324 Source partSource = addNamedSource("/part.dart", r'''
327 "/part.dart",
328 r'''
329 part of lib; 325 part of lib;
330 const int b = a; 326 const int b = a;
331 const int d = c;'''); 327 const int d = c;''');
332 LibraryElement libraryElement = resolve2(librarySource); 328 LibraryElement libraryElement = resolve2(librarySource);
333 CompilationUnit libraryUnit = 329 CompilationUnit libraryUnit =
334 analysisContext.resolveCompilationUnit(librarySource, libraryElement); 330 analysisContext.resolveCompilationUnit(librarySource, libraryElement);
335 expect(libraryUnit, isNotNull); 331 expect(libraryUnit, isNotNull);
336 CompilationUnit partUnit = 332 CompilationUnit partUnit =
337 analysisContext.resolveCompilationUnit(partSource, libraryElement); 333 analysisContext.resolveCompilationUnit(partSource, libraryElement);
338 expect(partUnit, isNotNull); 334 expect(partUnit, isNotNull);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 class A { 394 class A {
399 const A(this.next); 395 const A(this.next);
400 final A next; 396 final A next;
401 } 397 }
402 const A x = const A(null); 398 const A x = const A(null);
403 const A y = const A(x);'''); 399 const A y = const A(x);''');
404 } 400 }
405 401
406 test_dependencyOnConstructorArgument_unresolvedConstructor() async { 402 test_dependencyOnConstructorArgument_unresolvedConstructor() async {
407 // "const A.a(x)" depends on x even if the constructor A.a can't be found. 403 // "const A.a(x)" depends on x even if the constructor A.a can't be found.
408 await _assertProperDependencies( 404 await _assertProperDependencies(r'''
409 r'''
410 class A { 405 class A {
411 } 406 }
412 const int x = 1; 407 const int x = 1;
413 const A y = const A.a(x);''', 408 const A y = const A.a(x);''',
414 [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]); 409 [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]);
415 } 410 }
416 411
417 test_dependencyOnConstructorInitializer() async { 412 test_dependencyOnConstructorInitializer() async {
418 // "const A()" depends on x 413 // "const A()" depends on x
419 await _assertProperDependencies(r''' 414 await _assertProperDependencies(r'''
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 final int x = 1; 491 final int x = 1;
497 } 492 }
498 const A a = const A(); 493 const A a = const A();
499 '''); 494 ''');
500 } 495 }
501 496
502 test_dependencyOnInitializedNonStaticConst() async { 497 test_dependencyOnInitializedNonStaticConst() async {
503 // Even though non-static consts are not allowed by the language, we need 498 // Even though non-static consts are not allowed by the language, we need
504 // to handle them for error recovery purposes. 499 // to handle them for error recovery purposes.
505 // a depends on A() depends on A.x 500 // a depends on A() depends on A.x
506 await _assertProperDependencies( 501 await _assertProperDependencies('''
507 '''
508 class A { 502 class A {
509 const A(); 503 const A();
510 const int x = 1; 504 const int x = 1;
511 } 505 }
512 const A a = const A(); 506 const A a = const A();
513 ''', 507 ''', [CompileTimeErrorCode.CONST_INSTANCE_FIELD]);
514 [CompileTimeErrorCode.CONST_INSTANCE_FIELD]);
515 } 508 }
516 509
517 test_dependencyOnNonFactoryRedirect() async { 510 test_dependencyOnNonFactoryRedirect() async {
518 // a depends on A.foo() depends on A.bar() 511 // a depends on A.foo() depends on A.bar()
519 await _assertProperDependencies(r''' 512 await _assertProperDependencies(r'''
520 const A a = const A.foo(); 513 const A a = const A.foo();
521 class A { 514 class A {
522 const A.foo() : this.bar(); 515 const A.foo() : this.bar();
523 const A.bar(); 516 const A.bar();
524 }'''); 517 }''');
(...skipping 19 matching lines...) Expand all
544 class A { 537 class A {
545 const A.foo() : this.bar(); 538 const A.foo() : this.bar();
546 const A.bar([x = b]) : y = x; 539 const A.bar([x = b]) : y = x;
547 final int y; 540 final int y;
548 }'''); 541 }''');
549 } 542 }
550 543
551 test_dependencyOnNonFactoryRedirect_toMissing() async { 544 test_dependencyOnNonFactoryRedirect_toMissing() async {
552 // a depends on A.foo() which depends on nothing, since A.bar() is 545 // a depends on A.foo() which depends on nothing, since A.bar() is
553 // missing. 546 // missing.
554 await _assertProperDependencies( 547 await _assertProperDependencies(r'''
555 r'''
556 const A a = const A.foo(); 548 const A a = const A.foo();
557 class A { 549 class A {
558 const A.foo() : this.bar(); 550 const A.foo() : this.bar();
559 }''', 551 }''', [CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR]);
560 [CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR]);
561 } 552 }
562 553
563 test_dependencyOnNonFactoryRedirect_toNonConst() async { 554 test_dependencyOnNonFactoryRedirect_toNonConst() async {
564 // a depends on A.foo() which depends on nothing, since A.bar() is 555 // a depends on A.foo() which depends on nothing, since A.bar() is
565 // non-const. 556 // non-const.
566 await _assertProperDependencies(r''' 557 await _assertProperDependencies(r'''
567 const A a = const A.foo(); 558 const A a = const A.foo();
568 class A { 559 class A {
569 const A.foo() : this.bar(); 560 const A.foo() : this.bar();
570 A.bar(); 561 A.bar();
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 } 1693 }
1703 } 1694 }
1704 1695
1705 @reflectiveTest 1696 @reflectiveTest
1706 class StrongConstantValueComputerTest extends ConstantValueComputerTest { 1697 class StrongConstantValueComputerTest extends ConstantValueComputerTest {
1707 void setUp() { 1698 void setUp() {
1708 super.setUp(); 1699 super.setUp();
1709 resetWith(options: new AnalysisOptionsImpl()..strongMode = true); 1700 resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
1710 } 1701 }
1711 } 1702 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/dart/analysis/search_test.dart ('k') | pkg/analyzer/test/src/dart/element/element_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698