This repository has been archived by the owner on Apr 30, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --supermixins option, which enables DEP 34.
- Loading branch information
1 parent
a68aba9
commit 29b5e71
Showing
7 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
analyzer: | ||
exclude: | ||
- test/data/no_packages_file/sdk_ext_user.dart | ||
- test/data/super_mixin_example.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// 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. | ||
|
||
/// This produces errors normally, but --supermixin disables them. | ||
class Test extends Object with C { | ||
void foo() {} | ||
} | ||
|
||
abstract class B { | ||
void foo(); | ||
} | ||
|
||
abstract class C extends B { | ||
void bar() { | ||
super.foo(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// 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. | ||
|
||
@TestOn("vm") | ||
library analyzer_cli.test.super_mixin; | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:analyzer_cli/src/driver.dart' show Driver, errorSink, outSink; | ||
import 'package:path/path.dart' as path; | ||
import 'package:test/test.dart'; | ||
|
||
import 'utils.dart'; | ||
|
||
/// End-to-end test for --strong checking. | ||
/// | ||
/// Most StrongChecker tests are in dev_compiler/test/checker/*_test.dart, but | ||
/// this verifies the option is working and producing extra errors as expected. | ||
/// | ||
/// Generally we don't want a lot of cases here as it requires spinning up a | ||
/// full analysis context. | ||
void main() { | ||
group('--supermixins', () { | ||
StringSink savedOutSink, savedErrorSink; | ||
int savedExitCode; | ||
setUp(() { | ||
savedOutSink = outSink; | ||
savedErrorSink = errorSink; | ||
savedExitCode = exitCode; | ||
outSink = new StringBuffer(); | ||
errorSink = new StringBuffer(); | ||
}); | ||
tearDown(() { | ||
outSink = savedOutSink; | ||
errorSink = savedErrorSink; | ||
exitCode = savedExitCode; | ||
}); | ||
|
||
test('produces errors when option absent', () async { | ||
var testPath = path.join(testDirectory, 'data/super_mixin_example.dart'); | ||
new Driver().start([testPath]); | ||
|
||
expect(exitCode, 3); | ||
var stdout = outSink.toString(); | ||
expect( | ||
stdout, | ||
contains( | ||
"[error] The class 'C' cannot be used as a mixin because it extends a class other than Object")); | ||
expect( | ||
stdout, | ||
contains( | ||
"[error] The class 'C' cannot be used as a mixin because it references 'super'")); | ||
expect(stdout, contains('2 errors found.')); | ||
expect(errorSink.toString(), ''); | ||
}); | ||
|
||
test('produces no errors when option present', () async { | ||
var testPath = path.join(testDirectory, 'data/super_mixin_example.dart'); | ||
new Driver().start(['--supermixin', testPath]); | ||
|
||
expect(exitCode, 0); | ||
var stdout = outSink.toString(); | ||
expect(stdout, contains('No issues found')); | ||
}); | ||
}); | ||
} |