Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Analyzer: Move NON_BOOL_* tests to diagnostics/
Change-Id: I5bc58d78bf4f15e860759176d2e6abc670666e46 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153260 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
- Loading branch information
Showing
6 changed files
with
158 additions
and
141 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
49 changes: 49 additions & 0 deletions
49
pkg/analyzer/test/src/diagnostics/non_bool_expression_test.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,49 @@ | ||
// Copyright (c) 2020, 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:analyzer/src/error/codes.dart'; | ||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../dart/resolution/driver_resolution.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(NonBoolExpressionTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class NonBoolExpressionTest extends DriverResolutionTest { | ||
test_functionType_bool() async { | ||
await assertErrorsInCode(r''' | ||
bool makeAssertion() => true; | ||
f() { | ||
assert(makeAssertion); | ||
} | ||
''', [ | ||
error(StaticTypeWarningCode.NON_BOOL_EXPRESSION, 45, 13), | ||
]); | ||
} | ||
|
||
test_functionType_int() async { | ||
await assertErrorsInCode(r''' | ||
int makeAssertion() => 1; | ||
f() { | ||
assert(makeAssertion); | ||
} | ||
''', [ | ||
error(StaticTypeWarningCode.NON_BOOL_EXPRESSION, 41, 13), | ||
]); | ||
} | ||
|
||
test_interfaceType() async { | ||
await assertErrorsInCode(r''' | ||
f() { | ||
assert(0); | ||
} | ||
''', [ | ||
error(StaticTypeWarningCode.NON_BOOL_EXPRESSION, 15, 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
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