OLD | NEW |
(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 @TestOn("vm") |
| 6 library analyzer_cli.test.super_mixin; |
| 7 |
| 8 import 'dart:io'; |
| 9 |
| 10 import 'package:analyzer_cli/src/driver.dart' show Driver, errorSink, outSink; |
| 11 import 'package:path/path.dart' as path; |
| 12 import 'package:test/test.dart'; |
| 13 |
| 14 import 'utils.dart'; |
| 15 |
| 16 /// End-to-end test for --supermixins. |
| 17 /// |
| 18 /// Most super mixin tests are in Analyzer, but this verifies the option is |
| 19 /// working and producing extra errors as expected. |
| 20 /// |
| 21 /// Generally we don't want a lot of cases here as it requires spinning up a |
| 22 /// full analysis context. |
| 23 void main() { |
| 24 group('--supermixins', () { |
| 25 StringSink savedOutSink, savedErrorSink; |
| 26 int savedExitCode; |
| 27 setUp(() { |
| 28 savedOutSink = outSink; |
| 29 savedErrorSink = errorSink; |
| 30 savedExitCode = exitCode; |
| 31 outSink = new StringBuffer(); |
| 32 errorSink = new StringBuffer(); |
| 33 }); |
| 34 tearDown(() { |
| 35 outSink = savedOutSink; |
| 36 errorSink = savedErrorSink; |
| 37 exitCode = savedExitCode; |
| 38 }); |
| 39 |
| 40 test('produces errors when option absent', () async { |
| 41 var testPath = path.join(testDirectory, 'data/super_mixin_example.dart'); |
| 42 new Driver().start([testPath]); |
| 43 |
| 44 expect(exitCode, 3); |
| 45 var stdout = outSink.toString(); |
| 46 expect( |
| 47 stdout, |
| 48 contains( |
| 49 "[error] The class 'C' cannot be used as a mixin because it extend
s a class other than Object")); |
| 50 expect( |
| 51 stdout, |
| 52 contains( |
| 53 "[error] The class 'C' cannot be used as a mixin because it refere
nces 'super'")); |
| 54 expect(stdout, contains('2 errors found.')); |
| 55 expect(errorSink.toString(), ''); |
| 56 }); |
| 57 |
| 58 test('produces no errors when option present', () async { |
| 59 var testPath = path.join(testDirectory, 'data/super_mixin_example.dart'); |
| 60 new Driver().start(['--supermixin', testPath]); |
| 61 |
| 62 expect(exitCode, 0); |
| 63 var stdout = outSink.toString(); |
| 64 expect(stdout, contains('No issues found')); |
| 65 }); |
| 66 }); |
| 67 } |
OLD | NEW |