Chromium Code Reviews| Index: pkg/analyzer/test/src/task/model_test.dart |
| diff --git a/pkg/analyzer/test/src/task/model_test.dart b/pkg/analyzer/test/src/task/model_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c5a8ccafeacd8fc74f87b3eb150c5e1bd259df60 |
| --- /dev/null |
| +++ b/pkg/analyzer/test/src/task/model_test.dart |
| @@ -0,0 +1,119 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library test.src.task.model_test; |
| + |
| +import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| +import 'package:analyzer/src/task/model.dart'; |
| +import 'package:analyzer/src/task/targets.dart'; |
| +import 'package:analyzer/task/model.dart'; |
| +import 'package:unittest/unittest.dart'; |
| + |
| +import '../../generated/test_support.dart'; |
| +import '../../reflective_tests.dart'; |
| +import 'test_support.dart'; |
| + |
| +main() { |
| + groupSep = ' | '; |
| + runReflectiveTests(ContributionPointImplTest); |
| + runReflectiveTests(ResultDescriptorImplTest); |
| + runReflectiveTests(TaskDescriptorImplTest); |
| +} |
| + |
| +@reflectiveTest |
| +class ContributionPointImplTest extends EngineTestCase { |
| + test_contributors_empty() { |
| + ContributionPointImpl point = new ContributionPointImpl('point'); |
| + List<ResultDescriptor> contributors = point.contributors; |
| + expect(contributors, isNotNull); |
|
scheglov
2015/01/21 14:50:48
isEmpty already checks for null.
Brian Wilkerson
2015/01/26 04:54:52
Done
|
| + expect(contributors, isEmpty); |
| + } |
| + |
| + test_contributors_nonEmpty() { |
| + ResultDescriptorImpl result1 = new ResultDescriptorImpl('result1'); |
| + ResultDescriptorImpl result2 = new ResultDescriptorImpl('result2'); |
| + ContributionPointImpl point = new ContributionPointImpl('point'); |
| + point.recordContributor(result1); |
| + point.recordContributor(result2); |
| + List<ResultDescriptor> contributors = point.contributors; |
| + expect(contributors, isNotNull); |
| + 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
|
| + if (!(contributors[0] == result1 && contributors[1] == result2) || |
| + (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
|
| + fail("Invalid contributors: $contributors"); |
| + } |
| + } |
| + |
| + test_create() { |
| + expect(new ContributionPointImpl('name'), isNotNull); |
| + } |
| + |
| + test_name() { |
| + String name = 'point'; |
| + ContributionPointImpl point = new ContributionPointImpl(name); |
| + expect(point.name, name); |
| + } |
| +} |
| + |
| +@reflectiveTest |
| +class ResultDescriptorImplTest extends EngineTestCase { |
| + test_create_withContribution() { |
| + ContributionPointImpl point = new ContributionPointImpl('point'); |
| + ResultDescriptorImpl result = |
| + new ResultDescriptorImpl('result', contributesTo: point); |
| + expect(result, isNotNull); |
| + List<ResultDescriptor> contributors = point.contributors; |
| + expect(contributors, isNotNull); |
| + expect(contributors.length, 1); |
| + 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
|
| + } |
| + |
| + test_create_withoutContribution() { |
| + expect(new ResultDescriptorImpl('name'), isNotNull); |
| + } |
| + |
| + test_inputFor() { |
| + SourceTarget target = new SourceTarget(null); |
| + ResultDescriptorImpl result = new ResultDescriptorImpl('result'); |
| + TaskInput input = result.inputFor(target); |
| + expect(input, isNotNull); |
| + } |
| + |
| + test_name() { |
| + String name = 'result'; |
| + ResultDescriptorImpl result = new ResultDescriptorImpl(name); |
| + expect(result.name, name); |
| + } |
| +} |
| + |
| +@reflectiveTest |
| +class TaskDescriptorImplTest extends EngineTestCase { |
| + test_create() { |
| + String name = 'name'; |
| + BuildTask buildTask = (context, target) {}; |
| + CreateTaskInputs createTaskInputs = (target) {}; |
| + List<ResultDescriptor> results = <ResultDescriptor>[]; |
| + TaskDescriptorImpl descriptor = new TaskDescriptorImpl(name, buildTask, createTaskInputs, results); |
| + expect(descriptor, isNotNull); |
| + expect(descriptor.name, name); |
| + expect(descriptor.buildTask, equals(buildTask)); |
| + expect(descriptor.createTaskInputs, equals(createTaskInputs)); |
| + expect(descriptor.results, results); |
| + } |
| + |
| + test_createTask() { |
| + BuildTask buildTask = (context, target) => new TestAnalysisTask(context, target); |
| + CreateTaskInputs createTaskInputs = (target) {}; |
| + List<ResultDescriptor> results = <ResultDescriptor>[]; |
| + TaskDescriptorImpl descriptor = new TaskDescriptorImpl('name', buildTask, createTaskInputs, results); |
| + AnalysisContext context = null; |
| + SourceTarget target = new SourceTarget(null); |
| + Map<String, dynamic> inputs = {}; |
| + AnalysisTask createTask = descriptor.createTask(context, target, inputs); |
| + expect(createTask, isNotNull); |
| + expect(createTask.context, context); |
| + expect(createTask.inputs, inputs); |
| + expect(createTask.target, target); |
| + } |
| +} |