-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for default
typeCheckingMode
- Loading branch information
1 parent
652aa39
commit 47d6df3
Showing
2 changed files
with
42 additions
and
22 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
42 changes: 42 additions & 0 deletions
42
packages/pyright-internal/src/tests/typeEvaluatorBased.test.ts
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,42 @@ | ||
import { BasedConfigOptions, ConfigOptions } from '../common/configOptions'; | ||
import { DiagnosticRule } from '../common/diagnosticRules'; | ||
import { Uri } from '../common/uri/uri'; | ||
import { typeAnalyzeSampleFiles, validateResultsButBased } from './testUtils'; | ||
|
||
test('reportUnreachable', () => { | ||
const configOptions = new ConfigOptions(Uri.empty()); | ||
configOptions.diagnosticRuleSet.reportUnreachable = 'error'; | ||
const analysisResults = typeAnalyzeSampleFiles(['unreachable1.py'], configOptions); | ||
validateResultsButBased(analysisResults, { | ||
errors: [78, 89, 106, 110].map((line) => ({ code: DiagnosticRule.reportUnreachable, line })), | ||
infos: [{ line: 95 }, { line: 98 }], | ||
unusedCodes: [{ line: 102 }], | ||
}); | ||
}); | ||
|
||
test('reportUnreachable TYPE_CHECKING', () => { | ||
const configOptions = new ConfigOptions(Uri.empty()); | ||
configOptions.diagnosticRuleSet.reportUnreachable = 'error'; | ||
const analysisResults = typeAnalyzeSampleFiles(['unreachable2.py'], configOptions); | ||
|
||
validateResultsButBased(analysisResults, { | ||
unreachableCodes: [{ line: 3 }, { line: 8 }], | ||
}); | ||
}); | ||
|
||
test('default typeCheckingMode=all', () => { | ||
const configOptions = new BasedConfigOptions(Uri.empty()); | ||
const analysisResults = typeAnalyzeSampleFiles(['unreachable1.py'], configOptions); | ||
validateResultsButBased(analysisResults, { | ||
errors: [ | ||
...[78, 89, 106, 110].map((line) => ({ code: DiagnosticRule.reportUnreachable, line })), | ||
{ line: 16, code: DiagnosticRule.reportUninitializedInstanceVariable }, | ||
{ line: 19, code: DiagnosticRule.reportUnknownParameterType }, | ||
{ line: 33, code: DiagnosticRule.reportUnknownParameterType }, | ||
{ line: 94, code: DiagnosticRule.reportUnnecessaryComparison }, | ||
{ line: 102, code: DiagnosticRule.reportUnusedVariable }, | ||
], | ||
infos: [{ line: 95 }, { line: 98 }], | ||
unusedCodes: [{ line: 102 }], | ||
}); | ||
}); |