From 9c7919bcf96683874fc4b0c0f5bdbcea735721a1 Mon Sep 17 00:00:00 2001 From: tedin7 Date: Thu, 26 Nov 2026 03:21:54 +0100 Subject: [PATCH] test: count the s_mul_hi templates that refuse a short source list by themselves #2405 added an operand-count refusal to s_mul_hi_u32 and s_mul_hi_i32, so the arity control's single exception (s_bfm_b32) no longer holds and main fails startup_gfx2hlsl_scalar_table_arity_check. Name the three self-checking templates and assert the rest still raise IndexError without the generic guard. --- ...tartup_gfx2hlsl_scalar_table_arity_check.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/startup_gfx2hlsl_scalar_table_arity_check.py b/tests/startup_gfx2hlsl_scalar_table_arity_check.py index 7a2d86ebcf..177c4cf942 100644 --- a/tests/startup_gfx2hlsl_scalar_table_arity_check.py +++ b/tests/startup_gfx2hlsl_scalar_table_arity_check.py @@ -91,17 +91,19 @@ def refusal(module, op, sources): changed.append(op) check('a complete form is never refused for its operand count', not changed, repr(changed[:4])) -# Negative control: with the guard removed the short form raises IndexError again. One template keeps its own -# arity check (s_bfm_b32 spells "expected 3" in its body), so it refuses either way and is excluded here rather -# than counted as a survivor. +# Negative control: with the guard removed the short form raises IndexError again. A few templates keep their own +# arity check (s_bfm_b32 and s_mul_hi_{u,i}32 spell "expected 3" in their bodies), so they refuse either way and are +# excluded here rather than counted as survivors. +OWN_ARITY = {'s_bfm_b32', 's_mul_hi_u32', 's_mul_hi_i32'} stripped = load(SOURCE.read_text(encoding='utf-8').replace(' if len(srcs) < needed:', ' if False:')) control = [op for op in TWO_SOURCE if refusal(stripped, op, needed_sources(stripped, op) - 1) == 'IndexError'] -check('control: without the guard the short form raises IndexError', len(control) >= len(TWO_SOURCE) - 1, - '%d of %d' % (len(control), len(TWO_SOURCE))) -kept = [op for op in TWO_SOURCE if op not in control] -check('the one template with its own arity check still refuses without the guard', - all(refusal(stripped, op, needed_sources(stripped, op) - 1).startswith(op) for op in kept), repr(kept)) +expected_control = [op for op in TWO_SOURCE if op not in OWN_ARITY] +check('control: without the guard the short form raises IndexError', control == expected_control, + 'missing %r, extra %r' % (sorted(set(expected_control) - set(control)), sorted(set(control) - set(expected_control)))) +kept = [op for op in TWO_SOURCE if op in OWN_ARITY] +check('the templates with their own arity check still refuse without the guard', + kept and all(refusal(stripped, op, needed_sources(stripped, op) - 1).startswith(op) for op in kept), repr(kept)) print('scalar table arity checks: %d failed' % len(failures)) sys.exit(1 if failures else 0)