ContractEval: A Benchmark for Evaluating Contract-Satisfying Assertions in Code Generation
Not on the map. Why?
Abstract (arXiv)
Current code generation evaluation measures functional correctness on well-formed inputs that satisfy all input preconditions. This paradigm has a critical limitation: task descriptions often leave these preconditions implicit, while evaluation filters out inputs that violate them. As a result, generated code may achieve high pass@k scores while failing to enforce the preconditions that the task actually requires. To address this gap, we introduce ContractEval, a benchmark for evaluating whether generated code enforces such preconditions--commonly referred to as contracts. Built on HumanEval+ and MBPP+, ContractEval consists of 364 tasks, each with three components: (i) descriptions reconstructed to explicitly state the contracts, (ii) test cases synthesized through a neuro-symbolic pipeline that pairs an LLM with an SMT solver to evaluate whether generated code satisfies these contracts, and (iii) reference code combined with contracts. Using ContractEval to evaluate five representative open-source code LLMs, we reveal a stark disparity between functional correctness and contract satisfaction. Under standard prompting, these models achieve pass@1 of 75-82% with 0% contract satisfaction. Even when contracts are explicitly stated in the prompt, the satisfaction rate reaches only 23-41%. This indicates that current LLMs struggle to satisfy contracts in their generated code, establishing contract satisfaction as a crucial and previously overlooked axis of code generation quality. Our code is available at https://github.com/suhanmen/ContractEval.
Key facts. Cited by 2 papers in the map (data through 14 Oct 2026). Builds on 13 of its 25 references that are in the map. First posted on arXiv 14 Oct 2025.
Builds on
13 of 25 references.
References · 13
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
- 2021Measuring Coding Challenge Competence With APPScited by 902
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
- 2022CodeT: Code Generation with Generated Testscited by 384
- 2019SPoC: Search-based Pseudocode to Codecited by 176
- 2024TestGenEval: A Real World Unit Test Generation and Test Completion Benchmarkcited by 52
- 2024TESTEVAL: Benchmarking Large Language Models for Test Case Generationcited by 40
- 2025DSCodeBench: A Realistic Benchmark for Data Science Code Generationcited by 17
- 2024AssertionBench: A Benchmark to Evaluate Large-Language Models for Assertion Generationcited by 16
- 2025AsserT5: Test Assertion Generation Using a Fine-Tuned Code Language Modelcited by 7
1 more
Built on by
Citing papers per year: 2026: 2.
2 papers.