# Do Code Language Models Follow Tests? Paired Interventions on Program Behavior

arXiv: https://arxiv.org/abs/2607.26244 · HTML: https://mlsanity.com/paper/2607.26244/

## Key facts

- Cited by 3 papers in the map (data through 26 Nov 2026).
- Submitted 28 Jul 2026.

## Built on by (most cited first, 3 of 3)

- [GTDD: Generative Test-Driven Development for AI Coding Agents with Adversarial Testing](https://mlsanity.com/paper/2610.02952/) (2026)
- [Test-Driven Approaches to Software Engineering with Large Language Models: A Survey of Phases, Tasks, and Agent Skills](https://mlsanity.com/paper/2609.12012/) (2026)
- [Do LMs Know What Variables Do? Interpreting Code Representations via Variable Roles](https://mlsanity.com/paper/2610.24118/) (2026)

## Abstract (arXiv)

Visible tests specify concrete program behavior, but an improvement in benchmark accuracy does not establish that a model follows the rule expressed by those tests. We study test utilization through matched prompting controls, paired semantic interventions, and test suites selected by fault detection. Our semantic intervention holds an underspecified description and its example inputs fixed while changing the correct outputs to express one of two valid rules. Evaluation on unseen inputs measures whether both generated programs follow their respective rules. Across five models and three runs of 120 paired instances from 20 specification families, mean switching rates range from 11.1% to 65.8%. Qwen3.8-27B has the highest point estimate, followed by Qwen3.6-27B at 60.6%; their paired difference remains uncertain. Explicit descriptions elicit both rules from these two models on every instance, exposing a gap between implementation capability and adoption of test-specified rules. Correct expected outputs improve MBPP+ accuracy beyond inputs alone for all five models. On 180 tasks with fixed three-test suites, high-detection suites detect 30.3 percentage points more errors in a held-out pool dominated by reference mutants. The corresponding generation differences range from -0.6 to +1.1 points; all intervals include zero and remain compatible with some benefit. Paired interventions make test-specified rule changes measurable alongside implementation capability and benchmark correctness.
