| 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.general_test; | 5 library test.src.task.general_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/engine.dart' | 7 import 'package:analyzer/src/generated/engine.dart' |
| 8 hide AnalysisTask, GetContentTask; | 8 hide AnalysisTask, GetContentTask; |
| 9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 import 'package:analyzer/src/task/general.dart'; | 10 import 'package:analyzer/src/task/general.dart'; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 Source target = new TestSource(); | 59 Source target = new TestSource(); |
| 60 GetContentTask task = new GetContentTask(context, target); | 60 GetContentTask task = new GetContentTask(context, target); |
| 61 when(context.getContents(target)) | 61 when(context.getContents(target)) |
| 62 .thenReturn(new TimestampedData<String>(42, 'foo')); | 62 .thenReturn(new TimestampedData<String>(42, 'foo')); |
| 63 task.perform(); | 63 task.perform(); |
| 64 expect(task.caughtException, isNull); | 64 expect(task.caughtException, isNull); |
| 65 expect(task.outputs, hasLength(2)); | 65 expect(task.outputs, hasLength(2)); |
| 66 expect(task.outputs[CONTENT], 'foo'); | 66 expect(task.outputs[CONTENT], 'foo'); |
| 67 expect(task.outputs[MODIFICATION_TIME], 42); | 67 expect(task.outputs[MODIFICATION_TIME], 42); |
| 68 } | 68 } |
| 69 |
| 70 void test_perform_exception() { |
| 71 AnalysisContext context = new _MockContext(); |
| 72 Source target = new TestSource(); |
| 73 GetContentTask task = new GetContentTask(context, target); |
| 74 when(context.getContents(target)).thenThrow('My exception!'); |
| 75 task.perform(); |
| 76 expect(task.caughtException, isNotNull); |
| 77 expect(task.outputs, isEmpty); |
| 78 } |
| 69 } | 79 } |
| 70 | 80 |
| 71 class _MockContext extends TypedMock implements AnalysisContext { | 81 class _MockContext extends TypedMock implements AnalysisContext { |
| 72 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 82 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 73 } | 83 } |
| OLD | NEW |