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

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

Issue 812733004: Initial task support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.src.task.model_test;
6
7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
8 import 'package:analyzer/src/task/model.dart';
9 import 'package:analyzer/src/task/targets.dart';
10 import 'package:analyzer/task/model.dart';
11 import 'package:unittest/unittest.dart';
12
13 import '../../generated/test_support.dart';
14 import '../../reflective_tests.dart';
15 import 'test_support.dart';
16
17 main() {
18 groupSep = ' | ';
19 runReflectiveTests(ContributionPointImplTest);
20 runReflectiveTests(ResultDescriptorImplTest);
21 runReflectiveTests(TaskDescriptorImplTest);
22 }
23
24 @reflectiveTest
25 class ContributionPointImplTest extends EngineTestCase {
26 test_contributors_empty() {
27 ContributionPointImpl point = new ContributionPointImpl('point');
28 List<ResultDescriptor> contributors = point.contributors;
29 expect(contributors, isNotNull);
scheglov 2015/01/21 14:50:48 isEmpty already checks for null.
Brian Wilkerson 2015/01/26 04:54:52 Done
30 expect(contributors, isEmpty);
31 }
32
33 test_contributors_nonEmpty() {
34 ResultDescriptorImpl result1 = new ResultDescriptorImpl('result1');
35 ResultDescriptorImpl result2 = new ResultDescriptorImpl('result2');
36 ContributionPointImpl point = new ContributionPointImpl('point');
37 point.recordContributor(result1);
38 point.recordContributor(result2);
39 List<ResultDescriptor> contributors = point.contributors;
40 expect(contributors, isNotNull);
41 expect(contributors.length, 2);
scheglov 2015/01/21 14:50:47 hasLength(2) would print elements of contributors,
Brian Wilkerson 2015/01/26 04:54:52 Done
42 if (!(contributors[0] == result1 && contributors[1] == result2) ||
43 (contributors[0] == result2 && contributors[1] == result1)) {
scheglov 2015/01/21 14:50:48 Should negation be extracted to be applied to both
Brian Wilkerson 2015/01/26 04:54:52 I find it easier to read this way, but don't feel
44 fail("Invalid contributors: $contributors");
45 }
46 }
47
48 test_create() {
49 expect(new ContributionPointImpl('name'), isNotNull);
50 }
51
52 test_name() {
53 String name = 'point';
54 ContributionPointImpl point = new ContributionPointImpl(name);
55 expect(point.name, name);
56 }
57 }
58
59 @reflectiveTest
60 class ResultDescriptorImplTest extends EngineTestCase {
61 test_create_withContribution() {
62 ContributionPointImpl point = new ContributionPointImpl('point');
63 ResultDescriptorImpl result =
64 new ResultDescriptorImpl('result', contributesTo: point);
65 expect(result, isNotNull);
66 List<ResultDescriptor> contributors = point.contributors;
67 expect(contributors, isNotNull);
68 expect(contributors.length, 1);
69 expect(contributors[0], result);
scheglov 2015/01/21 14:50:47 unorderedEquals could be used here.
Brian Wilkerson 2015/01/26 04:54:52 Done
70 }
71
72 test_create_withoutContribution() {
73 expect(new ResultDescriptorImpl('name'), isNotNull);
74 }
75
76 test_inputFor() {
77 SourceTarget target = new SourceTarget(null);
78 ResultDescriptorImpl result = new ResultDescriptorImpl('result');
79 TaskInput input = result.inputFor(target);
80 expect(input, isNotNull);
81 }
82
83 test_name() {
84 String name = 'result';
85 ResultDescriptorImpl result = new ResultDescriptorImpl(name);
86 expect(result.name, name);
87 }
88 }
89
90 @reflectiveTest
91 class TaskDescriptorImplTest extends EngineTestCase {
92 test_create() {
93 String name = 'name';
94 BuildTask buildTask = (context, target) {};
95 CreateTaskInputs createTaskInputs = (target) {};
96 List<ResultDescriptor> results = <ResultDescriptor>[];
97 TaskDescriptorImpl descriptor = new TaskDescriptorImpl(name, buildTask, crea teTaskInputs, results);
98 expect(descriptor, isNotNull);
99 expect(descriptor.name, name);
100 expect(descriptor.buildTask, equals(buildTask));
101 expect(descriptor.createTaskInputs, equals(createTaskInputs));
102 expect(descriptor.results, results);
103 }
104
105 test_createTask() {
106 BuildTask buildTask = (context, target) => new TestAnalysisTask(context, tar get);
107 CreateTaskInputs createTaskInputs = (target) {};
108 List<ResultDescriptor> results = <ResultDescriptor>[];
109 TaskDescriptorImpl descriptor = new TaskDescriptorImpl('name', buildTask, cr eateTaskInputs, results);
110 AnalysisContext context = null;
111 SourceTarget target = new SourceTarget(null);
112 Map<String, dynamic> inputs = {};
113 AnalysisTask createTask = descriptor.createTask(context, target, inputs);
114 expect(createTask, isNotNull);
115 expect(createTask.context, context);
116 expect(createTask.inputs, inputs);
117 expect(createTask.target, target);
118 }
119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698