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

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

Issue 1041283002: GetContentTask should catch exceptions and wrap them into AnalysisExceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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
« no previous file with comments | « pkg/analyzer/lib/src/task/general.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.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
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 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/general.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698