|
| 1 | +// Copyright (c) 2022, 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 | +import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 6 | + |
| 7 | +import '../fix_processor.dart'; |
| 8 | +import 'data_driven_test_support.dart'; |
| 9 | + |
| 10 | +void main() { |
| 11 | + defineReflectiveSuite(() { |
| 12 | + defineReflectiveTests(TestUseCaseTest); |
| 13 | + }); |
| 14 | +} |
| 15 | + |
| 16 | +@reflectiveTest |
| 17 | +class TestUseCaseTest extends DataDrivenFixProcessorTest { |
| 18 | + @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/23067') |
| 19 | + Future<void> test_expect_export_deprecated() async { |
| 20 | + newFile('$workspaceRootPath/p/lib/lib.dart', ''' |
| 21 | +library p; |
| 22 | +@deprecated |
| 23 | +export 'package:matcher/expect.dart' show expect; |
| 24 | +'''); |
| 25 | + newFile('$workspaceRootPath/matcher/lib/expect.dart', ''' |
| 26 | +void expect(actual, matcher) {} |
| 27 | +'''); |
| 28 | + |
| 29 | + writeTestPackageConfig( |
| 30 | + config: PackageConfigFileBuilder() |
| 31 | + ..add(name: 'matcher', rootPath: '$workspaceRootPath/matcher') |
| 32 | + ..add(name: 'p', rootPath: '$workspaceRootPath/p'), |
| 33 | + ); |
| 34 | + |
| 35 | + addPackageDataFile(''' |
| 36 | +version: 1 |
| 37 | +transforms: |
| 38 | + - title: 'Replace expect' |
| 39 | + date: 2022-05-12 |
| 40 | + bulkApply: false |
| 41 | + element: |
| 42 | + uris: ['$importUri'] |
| 43 | + function: 'expect' |
| 44 | + changes: |
| 45 | + - kind: 'replacedBy' |
| 46 | + newElement: |
| 47 | + uris: ['package:matcher/expect.dart'] |
| 48 | + function: 'expect' |
| 49 | +'''); |
| 50 | + await resolveTestCode(''' |
| 51 | +import '$importUri'; |
| 52 | +
|
| 53 | +main() { |
| 54 | + expect(true, true); |
| 55 | +} |
| 56 | +'''); |
| 57 | + await assertHasFix(''' |
| 58 | +import 'package:matcher/expect.dart'; |
| 59 | +import '$importUri'; |
| 60 | +
|
| 61 | +main() { |
| 62 | + expect(true, true); |
| 63 | +} |
| 64 | +'''); |
| 65 | + } |
| 66 | + |
| 67 | + Future<void> test_expect_removed() async { |
| 68 | + setPackageContent(''' |
| 69 | +'''); |
| 70 | + |
| 71 | + addPackageDataFile(''' |
| 72 | +version: 1 |
| 73 | +transforms: |
| 74 | + - title: 'Replace expect' |
| 75 | + date: 2022-05-12 |
| 76 | + bulkApply: false |
| 77 | + element: |
| 78 | + uris: ['$importUri'] |
| 79 | + function: 'expect' |
| 80 | + changes: |
| 81 | + - kind: 'replacedBy' |
| 82 | + newElement: |
| 83 | + uris: ['package:matcher/expect.dart'] |
| 84 | + function: 'expect' |
| 85 | +'''); |
| 86 | + await resolveTestCode(''' |
| 87 | +import '$importUri'; |
| 88 | +
|
| 89 | +main() { |
| 90 | + expect(true, true); |
| 91 | +} |
| 92 | +'''); |
| 93 | + await assertHasFix(''' |
| 94 | +import 'package:matcher/expect.dart'; |
| 95 | +import '$importUri'; |
| 96 | +
|
| 97 | +main() { |
| 98 | + expect(true, true); |
| 99 | +} |
| 100 | +''', errorFilter: ignoreUnusedImport); |
| 101 | + } |
| 102 | +} |
0 commit comments