|
1 | 1 | # amaranth: UnusedElaboratable=no
|
2 | 2 |
|
| 3 | +import sys |
3 | 4 | from collections import OrderedDict
|
4 | 5 |
|
5 | 6 | from amaranth.hdl.ast import *
|
@@ -324,27 +325,28 @@ def test_If_wide(self):
|
324 | 325 | )
|
325 | 326 | """)
|
326 | 327 |
|
327 |
| - def test_If_signed_suspicious(self): |
328 |
| - m = Module() |
329 |
| - with self.assertWarnsRegex(SyntaxWarning, |
330 |
| - (r"^Signed values in If\/Elif conditions usually result from inverting Python " |
| 328 | + if sys.version_info < (3, 12): # upstream warning in 3.12! |
| 329 | + def test_If_signed_suspicious(self): |
| 330 | + m = Module() |
| 331 | + with self.assertWarnsRegex(SyntaxWarning, |
| 332 | + r"^Signed values in If\/Elif conditions usually result from inverting Python " |
331 | 333 | r"booleans with ~, which leads to unexpected results\. Replace `~flag` with "
|
332 | 334 | r"`not flag`\. \(If this is a false positive, silence this warning with "
|
333 |
| - r"`m\.If\(x\)` → `m\.If\(x\.bool\(\)\)`\.\)$")): |
334 |
| - with m.If(~True): |
335 |
| - pass |
| 335 | + r"`m\.If\(x\)` → `m\.If\(x\.bool\(\)\)`\.\)$"): |
| 336 | + with m.If(~True): |
| 337 | + pass |
336 | 338 |
|
337 |
| - def test_Elif_signed_suspicious(self): |
338 |
| - m = Module() |
339 |
| - with m.If(0): |
340 |
| - pass |
341 |
| - with self.assertWarnsRegex(SyntaxWarning, |
342 |
| - (r"^Signed values in If\/Elif conditions usually result from inverting Python " |
| 339 | + def test_Elif_signed_suspicious(self): |
| 340 | + m = Module() |
| 341 | + with m.If(0): |
| 342 | + pass |
| 343 | + with self.assertWarnsRegex(SyntaxWarning, |
| 344 | + r"^Signed values in If\/Elif conditions usually result from inverting Python " |
343 | 345 | r"booleans with ~, which leads to unexpected results\. Replace `~flag` with "
|
344 | 346 | r"`not flag`\. \(If this is a false positive, silence this warning with "
|
345 |
| - r"`m\.If\(x\)` → `m\.If\(x\.bool\(\)\)`\.\)$")): |
346 |
| - with m.Elif(~True): |
347 |
| - pass |
| 347 | + r"`m\.If\(x\)` → `m\.If\(x\.bool\(\)\)`\.\)$"): |
| 348 | + with m.Elif(~True): |
| 349 | + pass |
348 | 350 |
|
349 | 351 | def test_if_If_Elif_Else(self):
|
350 | 352 | m = Module()
|
|
0 commit comments