ContractEval: A Benchmark for Evaluating Contract-Satisfying Assertions in Code Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Lim, Soohan, Hahn, Joonghyuk, Park, Hyunwoo, Ko, Sang-Ki, Han, Yo-Sub
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866908979034062848
author Lim, Soohan
Hahn, Joonghyuk
Park, Hyunwoo
Ko, Sang-Ki
Han, Yo-Sub
author_facet Lim, Soohan
Hahn, Joonghyuk
Park, Hyunwoo
Ko, Sang-Ki
Han, Yo-Sub
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2510_12047
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle ContractEval: A Benchmark for Evaluating Contract-Satisfying Assertions in Code Generation
Lim, Soohan
Hahn, Joonghyuk
Park, Hyunwoo
Ko, Sang-Ki
Han, Yo-Sub
Artificial Intelligence
Software Engineering
68T01
I.2.7
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.
title ContractEval: A Benchmark for Evaluating Contract-Satisfying Assertions in Code Generation
topic Artificial Intelligence
Software Engineering
68T01
I.2.7
url https://arxiv.org/abs/2510.12047