This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
190 additions
and
88 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
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,40 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../rule_test_support.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(NullClosuresTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class NullClosuresTest extends LintRuleTest { | ||
@override | ||
String get lintRule => 'null_closures'; | ||
|
||
///https://github.com/dart-lang/linter/issues/1414 | ||
test_recursiveInterfaceInheritance() async { | ||
await assertDiagnostics(r''' | ||
class A extends B { | ||
A(int x); | ||
} | ||
class B extends A {} | ||
void test_cycle() { | ||
A(null); | ||
} | ||
''', [ | ||
// No lint | ||
error(CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 6, 1), | ||
error(CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 41, 1), | ||
error(CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT, 41, 1), | ||
error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 81, 4), | ||
]); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
test/rules/prefer_const_literals_to_create_immutables.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../rule_test_support.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(PreferConstLiteralsToCreateImmutablesTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class PreferConstLiteralsToCreateImmutablesTest extends LintRuleTest { | ||
@override | ||
bool get addMetaPackageDep => true; | ||
|
||
@override | ||
String get lintRule => 'prefer_const_literals_to_create_immutables.dart'; | ||
|
||
test_missingRequiredArgument() async { | ||
await assertDiagnostics(r''' | ||
import 'package:meta/meta.dart'; | ||
@immutable | ||
class K { | ||
final List<K> children; | ||
const K({required this.children}); | ||
} | ||
final k = K( | ||
children: <K>[for (var i = 0; i < 5; ++i) K()], // OK | ||
); | ||
''', [ | ||
// No lint | ||
error(CompileTimeErrorCode.MISSING_REQUIRED_ARGUMENT, 178, 1), | ||
]); | ||
} | ||
|
||
test_newWithNonType() async { | ||
await assertDiagnostics(r''' | ||
var e1 = new B([]); // OK | ||
''', [ | ||
// No lint | ||
error(CompileTimeErrorCode.NEW_WITH_NON_TYPE, 13, 1), | ||
]); | ||
} | ||
} |
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,31 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../rule_test_support.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(UnawaitedFuturesTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class UnawaitedFuturesTest extends LintRuleTest { | ||
@override | ||
String get lintRule => 'unawaited_futures'; | ||
|
||
test_undefinedIdentifier() async { | ||
await assertDiagnostics(r''' | ||
f() async { | ||
Duration d = Duration(); | ||
Future.delayed(d, bar); | ||
} | ||
''', [ | ||
// No lint | ||
error(CompileTimeErrorCode.UNDEFINED_IDENTIFIER, 59, 3), | ||
]); | ||
} | ||
} |
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
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
Oops, something went wrong.