Publication Type
Journal Article
Version
publishedVersion
Publication Date
10-2026
Abstract
Program migration, which involves translating software systems from one programming language to another, is essential for modernizing legacy systems and improving maintainability. Recent large language models (LLMs) have demonstrated strong performance in code translation; however, existing methods and benchmarks still exhibit key limitations. (1) They primarily focus on simple, self-contained snippets that fail to capture the complexity of real-world programs, and (2) they often assume that target-language test cases are readily available for evaluation and feedback, an unrealistic assumption given the difficulty of manually creating equivalent tests across languages. In this paper, we argue for a more practical setting, termed the Code–Test Co-Translation (CTCT) problem, where both the program and its associated test suite should be jointly translated to preserve semantic and functional consistency. Through an empirical study on real-world programs, we identify two major challenges in CTCT: (1) the difficulty of measuring test-case consistency in the absence of ground truth, and (2) the ineffectiveness of existing iterative translation–repair strategies, which suffer from state degradation and poor initialization traps when handling complex, real-world features.To address these issues, we propose CoTTrans, a state-quality–aware iterative translation–repair framework guided by a novel Test Case Consistency (TCC) metric. TCC quantifies both syntactic and semantic consistency between source and translated tests, enabling fine-grained feedback that drives LLM-based refinement. CoTTrans further integrates TCC with test pass rates to assess state quality and triggers adaptive backtracking when low-quality states are detected during the translation. Evaluated on the BigCodeBench dataset, CoTTrans improves the translation correctness score from 0.360 to 0.675 on DeepSeek-V3, substantially outperforming existing methods, while TCC demonstrates superior effectiveness in measuring test consistency compared with existing metrics. These results show that CoTTrans enhances translation stability and accuracy, establishing a practical foundation for reliable code–test co-evolution in real-world program migration.
Keywords
code translation, test case translation, program repair, large language models
Discipline
Artificial Intelligence and Robotics | Software Engineering
Research Areas
Intelligent Systems and Optimization
Areas of Excellence
Digital transformation
Publication
Proceedings of the ACM on Programming Languages
Volume
10
Issue
OOPSLA2
First Page
1217
Last Page
1244
ISSN
2475-1421
Identifier
10.1145/3839490
Publisher
Association for Computing Machinery (ACM)
Citation
LI, Xitao; XIE, Xiaofei; WU, Jiang; LIU, Ting; and WANG, Haijun.
Code-test co-translation: Towards practical and effective program migration in the wild. (2026). Proceedings of the ACM on Programming Languages. 10, (OOPSLA2), 1217-1244.
Available at: https://ink.library.smu.edu.sg/sis_research/11448
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-No Derivative Works 4.0 International License.
Additional URL
https://doi.org/10.1145/3839490