|
21 | 21 | import au.com.integradev.delphi.builders.DelphiTestUnitBuilder;
|
22 | 22 | import au.com.integradev.delphi.checks.verifier.CheckVerifier;
|
23 | 23 | import au.com.integradev.delphi.compiler.CompilerVersion;
|
| 24 | +import au.com.integradev.delphi.compiler.Toolchain; |
24 | 25 | import org.junit.jupiter.params.ParameterizedTest;
|
25 | 26 | import org.junit.jupiter.params.provider.ValueSource;
|
26 | 27 |
|
@@ -207,4 +208,78 @@ void testNativeIntArgumentToNativeIntParameterShouldNotAddIssue(String versionSy
|
207 | 208 | .appendImpl("end;"))
|
208 | 209 | .verifyNoIssues();
|
209 | 210 | }
|
| 211 | + |
| 212 | + @ParameterizedTest |
| 213 | + @ValueSource(strings = {VERSION_ALEXANDRIA, VERSION_ATHENS}) |
| 214 | + void testNativeIntAssignmentInBinaryExpressionShouldNotAddIssue(String versionSymbol) { |
| 215 | + CheckVerifier.newVerifier() |
| 216 | + .withCheck(new PlatformDependentTruncationCheck()) |
| 217 | + .withCompilerVersion(CompilerVersion.fromVersionSymbol(versionSymbol)) |
| 218 | + .withToolchain(Toolchain.DCC64) |
| 219 | + .onFile( |
| 220 | + new DelphiTestUnitBuilder() |
| 221 | + .appendImpl("procedure Foo;") |
| 222 | + .appendImpl("var") |
| 223 | + .appendImpl(" Nat: NativeInt;") |
| 224 | + .appendImpl("begin") |
| 225 | + .appendImpl(" Nat := Nat + 1;") |
| 226 | + .appendImpl("end;")) |
| 227 | + .verifyNoIssues(); |
| 228 | + } |
| 229 | + |
| 230 | + @ParameterizedTest |
| 231 | + @ValueSource(strings = {VERSION_ALEXANDRIA, VERSION_ATHENS}) |
| 232 | + void testNativeIntArgumentInBinaryExpressionShouldNotAddIssue(String versionSymbol) { |
| 233 | + CheckVerifier.newVerifier() |
| 234 | + .withCheck(new PlatformDependentTruncationCheck()) |
| 235 | + .withCompilerVersion(CompilerVersion.fromVersionSymbol(versionSymbol)) |
| 236 | + .withToolchain(Toolchain.DCC64) |
| 237 | + .onFile( |
| 238 | + new DelphiTestUnitBuilder() |
| 239 | + .appendDecl("procedure Bar(Nat: NativeInt);") |
| 240 | + .appendImpl("procedure Foo;") |
| 241 | + .appendImpl("var") |
| 242 | + .appendImpl(" Nat: NativeInt;") |
| 243 | + .appendImpl("begin") |
| 244 | + .appendImpl(" Bar(Nat + 1);") |
| 245 | + .appendImpl("end;")) |
| 246 | + .verifyNoIssues(); |
| 247 | + } |
| 248 | + |
| 249 | + @ParameterizedTest |
| 250 | + @ValueSource(strings = {VERSION_ALEXANDRIA, VERSION_ATHENS}) |
| 251 | + void testNativeIntAssignmentInNestedBinaryExpressionShouldNotAddIssue(String versionSymbol) { |
| 252 | + CheckVerifier.newVerifier() |
| 253 | + .withCheck(new PlatformDependentTruncationCheck()) |
| 254 | + .withCompilerVersion(CompilerVersion.fromVersionSymbol(versionSymbol)) |
| 255 | + .withToolchain(Toolchain.DCC64) |
| 256 | + .onFile( |
| 257 | + new DelphiTestUnitBuilder() |
| 258 | + .appendImpl("procedure Foo;") |
| 259 | + .appendImpl("var") |
| 260 | + .appendImpl(" Nat: NativeInt;") |
| 261 | + .appendImpl("begin") |
| 262 | + .appendImpl(" Nat := (Nat + 1) + 1;") |
| 263 | + .appendImpl("end;")) |
| 264 | + .verifyNoIssues(); |
| 265 | + } |
| 266 | + |
| 267 | + @ParameterizedTest |
| 268 | + @ValueSource(strings = {VERSION_ALEXANDRIA, VERSION_ATHENS}) |
| 269 | + void testPlatformDependentCastInBinaryExpressionShouldNotAddIssue(String versionSymbol) { |
| 270 | + CheckVerifier.newVerifier() |
| 271 | + .withCheck(new PlatformDependentTruncationCheck()) |
| 272 | + .withCompilerVersion(CompilerVersion.fromVersionSymbol(versionSymbol)) |
| 273 | + .withToolchain(Toolchain.DCC64) |
| 274 | + .onFile( |
| 275 | + new DelphiTestUnitBuilder() |
| 276 | + .appendImpl("procedure Foo;") |
| 277 | + .appendImpl("var") |
| 278 | + .appendImpl(" Int: Integer;") |
| 279 | + .appendImpl(" Nat: NativeInt;") |
| 280 | + .appendImpl("begin") |
| 281 | + .appendImpl(" Int := Integer(Nat) + 1;") |
| 282 | + .appendImpl("end;")) |
| 283 | + .verifyNoIssues(); |
| 284 | + } |
210 | 285 | }
|
0 commit comments