Check source for fastmath/non-fastmath versions
(source, mathop_name, expect_fastmath=False)
| 21 | |
| 22 | |
| 23 | def check_fastmath_usage(source, mathop_name, expect_fastmath=False): |
| 24 | """Check source for fastmath/non-fastmath versions""" |
| 25 | fastmath_pattern = rf"__({mathop_name}f?)\b" |
| 26 | non_fastmath_pattern = rf"(?<!__)({mathop_name}f?)\b" |
| 27 | |
| 28 | fastmath_matches = re.findall(fastmath_pattern, source) |
| 29 | non_fastmath_matches = re.findall(non_fastmath_pattern, source) |
| 30 | |
| 31 | print(f"Found {len(fastmath_matches)} fastmath calls, {len(non_fastmath_matches)} non-fastmath calls") |
| 32 | if len(fastmath_matches) > 0: |
| 33 | print(f"Fastmath calls found: {fastmath_matches}") |
| 34 | if len(non_fastmath_matches) > 0: |
| 35 | print(f"Non-fastmath calls found: {non_fastmath_matches}") |
| 36 | print(f"Source preview for {mathop_name}:") |
| 37 | print(get_mathop_lines(source, mathop_name)) |
| 38 | |
| 39 | if expect_fastmath: |
| 40 | assert len(fastmath_matches) > 0, "Expected fastmath calls but found none" |
| 41 | print(f"✓ {mathop_name} correctly uses fastmath versions") |
| 42 | else: |
| 43 | assert len(fastmath_matches) == 0, f"Found unexpected fastmath calls: {fastmath_matches}" |
| 44 | assert len(non_fastmath_matches) > 0, f"No {mathop_name} calls found" |
| 45 | print(f"✓ {mathop_name} correctly uses non-fastmath versions") |
| 46 | |
| 47 | |
| 48 | def check_non_fastmath_usage(source, mathop_name): |
no test coverage detected
searching dependent graphs…