|
7 | 7 |
|
8 | 8 | import unittest |
9 | 9 |
|
10 | | -from ..input_filters.doxygen_strip_comments import strip_block_comments |
| 10 | +from ..input_filters.doxygen_strip_comments import ( |
| 11 | + strip_block_comments, |
| 12 | + strip_deprecated_msg, |
| 13 | +) |
11 | 14 |
|
12 | 15 |
|
13 | 16 | class TestDoxygenStripComments(unittest.TestCase): |
@@ -67,5 +70,51 @@ def test_handles_no_comments(self): |
67 | 70 | self.assertEqual(result, content) |
68 | 71 |
|
69 | 72 |
|
| 73 | +class TestStripDeprecatedMsg(unittest.TestCase): |
| 74 | + def test_strips_deprecated_msg(self): |
| 75 | + content = '- (void)oldMethod __deprecated_msg("Use newMethod instead.");' |
| 76 | + result = strip_deprecated_msg(content) |
| 77 | + self.assertEqual(result, "- (void)oldMethod ;") |
| 78 | + |
| 79 | + def test_strips_standalone_deprecated(self): |
| 80 | + content = "- (instancetype)initWithBundleURL:(NSURL *)bundleURL launchOptions:(nullable NSDictionary *)launchOptions __deprecated;" |
| 81 | + result = strip_deprecated_msg(content) |
| 82 | + self.assertEqual( |
| 83 | + result, |
| 84 | + "- (instancetype)initWithBundleURL:(NSURL *)bundleURL launchOptions:(nullable NSDictionary *)launchOptions ;", |
| 85 | + ) |
| 86 | + |
| 87 | + def test_standalone_deprecated_does_not_match_deprecated_msg(self): |
| 88 | + content = '__deprecated_msg("msg") and __deprecated' |
| 89 | + result = strip_deprecated_msg(content) |
| 90 | + self.assertEqual(result, "and ") |
| 91 | + |
| 92 | + def test_preserves_deprecated_in_identifiers(self): |
| 93 | + content = ( |
| 94 | + "- (void)findComponentViewWithTag_DO_NOT_USE_DEPRECATED:(NSInteger)tag;" |
| 95 | + ) |
| 96 | + result = strip_deprecated_msg(content) |
| 97 | + self.assertEqual(result, content) |
| 98 | + |
| 99 | + def test_preserves_DEPRECATED_suffix_in_names(self): |
| 100 | + content = "@property (weak) RCTViewRegistry *viewRegistry_DEPRECATED;" |
| 101 | + result = strip_deprecated_msg(content) |
| 102 | + self.assertEqual(result, content) |
| 103 | + |
| 104 | + def test_handles_no_deprecated(self): |
| 105 | + content = "- (void)normalMethod;" |
| 106 | + result = strip_deprecated_msg(content) |
| 107 | + self.assertEqual(result, content) |
| 108 | + |
| 109 | + def test_handles_empty_content(self): |
| 110 | + result = strip_deprecated_msg("") |
| 111 | + self.assertEqual(result, "") |
| 112 | + |
| 113 | + def test_strips_deprecated_before_interface(self): |
| 114 | + content = '__deprecated_msg("This API will be removed.") @interface RCTSurface : NSObject' |
| 115 | + result = strip_deprecated_msg(content) |
| 116 | + self.assertEqual(result, "@interface RCTSurface : NSObject") |
| 117 | + |
| 118 | + |
70 | 119 | if __name__ == "__main__": |
71 | 120 | unittest.main() |
0 commit comments