@@ -77,4 +77,97 @@ void testClassDestructorShouldNotAddIssue() {
7777 .appendImpl ("end;" ))
7878 .verifyNoIssues ();
7979 }
80+
81+ @ Test
82+ void testDestructorLikeWithInheritedShouldNotAddIssue () {
83+ var check = new DestructorWithoutInheritedCheck ();
84+ check .destructorLikes = "Foo,Bar" ;
85+
86+ CheckVerifier .newVerifier ()
87+ .withCheck (check )
88+ .onFile (
89+ new DelphiTestUnitBuilder ()
90+ .appendDecl ("type" )
91+ .appendDecl (" TTestDestructorLike = class(TObject)" )
92+ .appendDecl (" public" )
93+ .appendDecl (" procedure Foo; override;" )
94+ .appendDecl (" procedure Bar; override;" )
95+ .appendDecl (" end;" )
96+ .appendImpl ("procedure TTestDestructorLike.Foo;" )
97+ .appendImpl ("begin" )
98+ .appendImpl (" inherited;" )
99+ .appendImpl (" WriteLn('do something');" )
100+ .appendImpl ("end;" )
101+ .appendImpl ("procedure TTestDestructorLike.Bar;" )
102+ .appendImpl ("begin" )
103+ .appendImpl (" inherited;" )
104+ .appendImpl (" WriteLn('do something');" )
105+ .appendImpl ("end;" ))
106+ .verifyNoIssues ();
107+ }
108+
109+ @ Test
110+ void testDestructorLikeWithoutInheritedShouldAddIssue () {
111+ var check = new DestructorWithoutInheritedCheck ();
112+ check .destructorLikes = "Foo,Bar" ;
113+
114+ CheckVerifier .newVerifier ()
115+ .withCheck (check )
116+ .onFile (
117+ new DelphiTestUnitBuilder ()
118+ .appendDecl ("type" )
119+ .appendDecl (" TTestDestructorLike = class(TObject)" )
120+ .appendDecl (" public" )
121+ .appendDecl (" procedure Foo; override;" )
122+ .appendDecl (" procedure Bar; override;" )
123+ .appendDecl (" end;" )
124+ .appendImpl ("procedure TTestDestructorLike.Foo; // Noncompliant" )
125+ .appendImpl ("begin" )
126+ .appendImpl (" WriteLn('do something');" )
127+ .appendImpl ("end;" )
128+ .appendImpl ("procedure TTestDestructorLike.Bar; // Noncompliant" )
129+ .appendImpl ("begin" )
130+ .appendImpl (" WriteLn('do something');" )
131+ .appendImpl ("end;" ))
132+ .verifyIssues ();
133+ }
134+
135+ @ Test
136+ void testDestructorLikeWithoutInheritedOrOverrideShouldNotAddIssue () {
137+ var check = new DestructorWithoutInheritedCheck ();
138+ check .destructorLikes = "Foo" ;
139+
140+ CheckVerifier .newVerifier ()
141+ .withCheck (check )
142+ .onFile (
143+ new DelphiTestUnitBuilder ()
144+ .appendDecl ("type" )
145+ .appendDecl (" TTestDestructorLike = class(TObject)" )
146+ .appendDecl (" public" )
147+ .appendDecl (" procedure Foo;" )
148+ .appendDecl (" end;" )
149+ .appendImpl ("procedure TTestDestructorLike.Foo;" )
150+ .appendImpl ("begin" )
151+ .appendImpl (" WriteLn('do something');" )
152+ .appendImpl ("end;" ))
153+ .verifyNoIssues ();
154+ }
155+
156+ @ Test
157+ void testRandomMethodWithoutInheritedShouldNotAddIssue () {
158+ CheckVerifier .newVerifier ()
159+ .withCheck (new DestructorWithoutInheritedCheck ())
160+ .onFile (
161+ new DelphiTestUnitBuilder ()
162+ .appendDecl ("type" )
163+ .appendDecl (" TFoo = class(TObject)" )
164+ .appendDecl (" public" )
165+ .appendDecl (" procedure Bar; override;" )
166+ .appendDecl (" end;" )
167+ .appendImpl ("procedure TTestDestructorLike.Bar;" )
168+ .appendImpl ("begin" )
169+ .appendImpl (" WriteLn('do something');" )
170+ .appendImpl ("end;" ))
171+ .verifyNoIssues ();
172+ }
80173}
0 commit comments