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

Side by Side Diff: pkg/analyzer/test/src/task/driver_test.dart

Issue 1131383008: Generate the proper error when a constant refers to itself. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « pkg/analyzer/test/src/task/dart_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 test.src.task.driver_test; 5 library test.src.task.driver_test;
6 6
7 import 'package:analyzer/src/context/cache.dart'; 7 import 'package:analyzer/src/context/cache.dart';
8 import 'package:analyzer/src/generated/engine.dart' 8 import 'package:analyzer/src/generated/engine.dart'
9 hide 9 hide
10 AnalysisCache, 10 AnalysisCache,
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 expect(workOrder, priorityTarget ? isNotNull : isNull); 447 expect(workOrder, priorityTarget ? isNotNull : isNull);
448 } else { 448 } else {
449 expect(workOrder, isNotNull); 449 expect(workOrder, isNotNull);
450 } 450 }
451 } 451 }
452 } 452 }
453 453
454 @reflectiveTest 454 @reflectiveTest
455 class CycleAwareDependencyWalkerTest { 455 class CycleAwareDependencyWalkerTest {
456 void checkGraph(Map<int, List<int>> graph, int startingNode, 456 void checkGraph(Map<int, List<int>> graph, int startingNode,
457 List<List<int>> expectedResults) { 457 List<StronglyConnectedComponent<int>> expectedResults) {
458 List<Set<int>> expectedResultsDisregardingOrder = 458 List<Set<int>> expectedResultsDisregardingOrder =
459 expectedResults.map((nodes) => nodes.toSet()).toList(); 459 expectedResults.map((component) => component.nodes.toSet()).toList();
460 List<bool> expectedCycleIndicators =
461 expectedResults.map((component) => component.containsCycle).toList();
460 List<Set<int>> results = <Set<int>>[]; 462 List<Set<int>> results = <Set<int>>[];
463 List<bool> cycleIndicators = <bool>[];
461 _TestCycleAwareDependencyWalker walker = 464 _TestCycleAwareDependencyWalker walker =
462 new _TestCycleAwareDependencyWalker(graph, startingNode); 465 new _TestCycleAwareDependencyWalker(graph, startingNode);
463 while (true) { 466 while (true) {
464 List<int> nextResult = walker.getNextStronglyConnectedComponent(); 467 StronglyConnectedComponent<int> nextStronglyConnectedComponent =
465 if (nextResult == null) { 468 walker.getNextStronglyConnectedComponent();
469 if (nextStronglyConnectedComponent == null) {
466 break; 470 break;
467 } 471 }
468 results.add(nextResult.toSet()); 472 results.add(nextStronglyConnectedComponent.nodes.toSet());
469 walker.evaluatedNodes.addAll(nextResult); 473 cycleIndicators.add(nextStronglyConnectedComponent.containsCycle);
474 walker.evaluatedNodes.addAll(nextStronglyConnectedComponent.nodes);
470 } 475 }
471 expect(results, expectedResultsDisregardingOrder); 476 expect(results, expectedResultsDisregardingOrder);
477 expect(cycleIndicators, expectedCycleIndicators);
472 } 478 }
473 479
480 StronglyConnectedComponent<int> cycle(List<int> nodes) =>
481 new StronglyConnectedComponent(nodes, true);
482
483 StronglyConnectedComponent<int> singleton(int node) =>
484 new StronglyConnectedComponent(<int>[node], false);
485
474 void test_complex_graph() { 486 void test_complex_graph() {
475 checkGraph({ 487 checkGraph({
476 1: [2, 3], 488 1: [2, 3],
477 2: [3, 4], 489 2: [3, 4],
478 3: [], 490 3: [],
479 4: [3, 5], 491 4: [3, 5],
480 5: [2, 6], 492 5: [2, 6],
481 6: [3, 4] 493 6: [3, 4]
482 }, 1, [[3], [2, 4, 5, 6], [1]]); 494 }, 1, [singleton(3), cycle([2, 4, 5, 6]), singleton(1)]);
483 } 495 }
484 496
485 void test_cycle_depends_on_other_nodes() { 497 void test_cycle_depends_on_other_nodes() {
486 checkGraph({1: [2, 3], 2: [4, 1], 3: [], 4: []}, 1, [[4], [3], [1, 2]]); 498 checkGraph({1: [2, 3], 2: [4, 1], 3: [], 4: []}, 1, [
499 singleton(4),
500 singleton(3),
501 cycle([1, 2])
502 ]);
487 } 503 }
488 504
489 void test_initial_node_depends_on_cycle() { 505 void test_initial_node_depends_on_cycle() {
490 checkGraph({1: [2], 2: [3], 3: [2]}, 1, [[2, 3], [1]]); 506 checkGraph({1: [2], 2: [3], 3: [2]}, 1, [cycle([2, 3]), singleton(1)]);
491 } 507 }
492 508
493 void test_simple_cycle() { 509 void test_simple_cycle() {
494 checkGraph({1: [2], 2: [1]}, 1, [[1, 2]]); 510 checkGraph({1: [2], 2: [1]}, 1, [cycle([1, 2])]);
495 } 511 }
496 512
497 void test_simple_dependency_chain() { 513 void test_simple_dependency_chain() {
498 checkGraph({1: [2], 2: []}, 1, [[2], [1]]); 514 checkGraph({1: [2], 2: []}, 1, [singleton(2), singleton(1)]);
499 } 515 }
500 516
501 void test_single_node() { 517 void test_single_node() {
502 checkGraph({1: []}, 1, [[1]]); 518 checkGraph({1: []}, 1, [singleton(1)]);
519 }
520
521 void test_single_node_cycle() {
522 checkGraph({1: [1]}, 1, [cycle([1])]);
503 } 523 }
504 } 524 }
505 525
506 @reflectiveTest 526 @reflectiveTest
507 class WorkItemTest extends AbstractDriverTest { 527 class WorkItemTest extends AbstractDriverTest {
508 test_buildTask_complete() { 528 test_buildTask_complete() {
509 AnalysisTarget target = new TestSource(); 529 AnalysisTarget target = new TestSource();
510 TaskDescriptor descriptor = new TaskDescriptor('task', 530 TaskDescriptor descriptor = new TaskDescriptor('task',
511 (context, target) => new TestAnalysisTask(context, target), 531 (context, target) => new TestAnalysisTask(context, target),
512 (target) => {}, [new ResultDescriptor('output', null)]); 532 (target) => {}, [new ResultDescriptor('output', null)]);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 return dependency; 680 return dependency;
661 } 681 }
662 } 682 }
663 return null; 683 return null;
664 } 684 }
665 } 685 }
666 686
667 class _WorkManagerMock extends TypedMock implements WorkManager { 687 class _WorkManagerMock extends TypedMock implements WorkManager {
668 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 688 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
669 } 689 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/dart_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698