| OLD | NEW |
| 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.inputs_test; | 5 library test.src.task.inputs_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/task/inputs.dart'; | 7 import 'package:analyzer/src/task/inputs.dart'; |
| 8 import 'package:analyzer/src/task/model.dart'; | 8 import 'package:analyzer/src/task/model.dart'; |
| 9 import 'package:analyzer/task/model.dart'; | 9 import 'package:analyzer/task/model.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 | 11 |
| 12 import '../../generated/test_support.dart'; | 12 import '../../generated/test_support.dart'; |
| 13 import '../../reflective_tests.dart'; | 13 import '../../reflective_tests.dart'; |
| 14 | 14 |
| 15 main() { | 15 main() { |
| 16 groupSep = ' | '; | 16 groupSep = ' | '; |
| 17 runReflectiveTests(ListTaskInputImplTest); |
| 17 runReflectiveTests(ListToListTaskInputTest); | 18 runReflectiveTests(ListToListTaskInputTest); |
| 18 runReflectiveTests(ListToListTaskInputBuilderTest); | 19 runReflectiveTests(ListToListTaskInputBuilderTest); |
| 19 runReflectiveTests(ListToMapTaskInputBuilderTest); | 20 runReflectiveTests(ListToMapTaskInputBuilderTest); |
| 20 runReflectiveTests(ListToMapTaskInputTest); | 21 runReflectiveTests(ListToMapTaskInputTest); |
| 21 runReflectiveTests(SimpleTaskInputTest); | 22 runReflectiveTests(SimpleTaskInputTest); |
| 22 runReflectiveTests(SimpleTaskInputBuilderTest); | 23 runReflectiveTests(SimpleTaskInputBuilderTest); |
| 23 runReflectiveTests(TopLevelTaskInputBuilderTest); | 24 runReflectiveTests(TopLevelTaskInputBuilderTest); |
| 24 } | 25 } |
| 25 | 26 |
| 26 @reflectiveTest | 27 @reflectiveTest |
| 28 class ListTaskInputImplTest extends EngineTestCase { |
| 29 static final AnalysisTarget target = new TestSource(); |
| 30 static final result1 = |
| 31 new ResultDescriptorImpl<List<AnalysisTarget>>('result1', null); |
| 32 static final result2 = new ResultDescriptorImpl<int>('result2', null); |
| 33 |
| 34 test_create() { |
| 35 var input = new ListTaskInputImpl<AnalysisTarget>(target, result1); |
| 36 expect(input, isNotNull); |
| 37 expect(input.target, target); |
| 38 expect(input.result, result1); |
| 39 } |
| 40 |
| 41 test_createBuilder() { |
| 42 var input = new ListTaskInputImpl<AnalysisTarget>(target, result1); |
| 43 expect(input.createBuilder(), new isInstanceOf<SimpleTaskInputBuilder>()); |
| 44 } |
| 45 |
| 46 test_toList() { |
| 47 var input = new ListTaskInputImpl<AnalysisTarget>(target, result1); |
| 48 TaskInput<List> input2 = input.toList((target) => 'name'); |
| 49 expect(input2, |
| 50 new isInstanceOf<ListToListTaskInput<AnalysisTarget, String>>()); |
| 51 } |
| 52 |
| 53 test_toListOf() { |
| 54 var input = new ListTaskInputImpl<AnalysisTarget>(target, result1); |
| 55 TaskInput<List> input2 = input.toListOf(result2); |
| 56 expect( |
| 57 input2, new isInstanceOf<ListToListTaskInput<AnalysisTarget, int>>()); |
| 58 } |
| 59 |
| 60 test_toMap() { |
| 61 var input = new ListTaskInputImpl<AnalysisTarget>(target, result1); |
| 62 TaskInput<Map> input2 = input.toMap((target) => 'name'); |
| 63 expect( |
| 64 input2, new isInstanceOf<ListToMapTaskInput<AnalysisTarget, String>>()); |
| 65 } |
| 66 |
| 67 test_toMapOf() { |
| 68 var input = new ListTaskInputImpl<AnalysisTarget>(target, result1); |
| 69 TaskInput<Map> input2 = input.toMapOf(result2); |
| 70 expect(input2, new isInstanceOf<ListToMapTaskInput<AnalysisTarget, int>>()); |
| 71 } |
| 72 } |
| 73 |
| 74 @reflectiveTest |
| 27 class ListToListTaskInputBuilderTest extends EngineTestCase { | 75 class ListToListTaskInputBuilderTest extends EngineTestCase { |
| 28 static final AnalysisTarget target1 = new TestSource(); | 76 static final AnalysisTarget target1 = new TestSource(); |
| 29 static final ResultDescriptorImpl result1 = | 77 static final ResultDescriptorImpl result1 = |
| 30 new ResultDescriptorImpl('result1', null); | 78 new ResultDescriptorImpl('result1', null); |
| 31 static final ResultDescriptorImpl result2 = | 79 static final ResultDescriptorImpl result2 = |
| 32 new ResultDescriptorImpl('result2', null); | 80 new ResultDescriptorImpl('result2', null); |
| 33 static final ListToListTaskInput input = new ListToListTaskInput( | 81 static final ListToListTaskInput input = new ListToListTaskInput( |
| 34 result1.of(target1), (element) => result2.of(element)); | 82 result1.of(target1), (element) => result2.of(element)); |
| 35 | 83 |
| 36 test_create() { | 84 test_create() { |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 test_moveNext_withSet() { | 594 test_moveNext_withSet() { |
| 547 Map<String, TaskInput> inputDescriptors = {'one': input1}; | 595 Map<String, TaskInput> inputDescriptors = {'one': input1}; |
| 548 TopLevelTaskInputBuilder builder = | 596 TopLevelTaskInputBuilder builder = |
| 549 new TopLevelTaskInputBuilder(inputDescriptors); | 597 new TopLevelTaskInputBuilder(inputDescriptors); |
| 550 expect(builder.moveNext(), true); | 598 expect(builder.moveNext(), true); |
| 551 builder.currentValue = 'value1'; | 599 builder.currentValue = 'value1'; |
| 552 expect(builder.moveNext(), false); | 600 expect(builder.moveNext(), false); |
| 553 expect(builder.moveNext(), false); | 601 expect(builder.moveNext(), false); |
| 554 } | 602 } |
| 555 } | 603 } |
| OLD | NEW |