{
  "id": 19499695,
  "title": "How to prove an AI-converted COBOL program still behaves the same",
  "url": "https://urgent.news/2026/11/11/how-to-prove-an-ai-converted-cobol-program-still-behaves-the-same",
  "topic": "ai",
  "section": "AI",
  "published": "2026-11-11T13:18:11.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/samamderson/how-to-prove-an-ai-converted-cobol-program-still-behaves-the-same-552a"
  },
  "original_language": "en",
  "account": "To prove that an AI-converted COBOL program still behaves the same as the original code, follow these steps:\n\n1. The legacy COBOL code calculates monthly interest based on the account balance and a specific threshold. Balances above 10,000 earn 3.5% per year, while everything else earns 2.5%. The monthly interest is rounded to two decimal places, with half values rounded away from zero.\n\n2. A Java version of the code was created to match the COBOL logic. It uses BigDecimal instead of double, keeps the threshold and rates, and rounds the result using HALF_UP.\n\n3. While the Java code appears correct, it may not produce the same results as the COBOL code due to differences in handling negative balances and rounding. In the COBOL code, moving a signed value into an unsigned field stores its absolute value, whereas the Java code requires explicit conversion using the abs() method.\n\n4. To verify the correctness of the converted code, create a set of expected values based on the COBOL program's output for various input balances. These expected values should cover boundary conditions such as the threshold, zero, negative balances, maximum field values, and values where rounding and truncation differ.\n\n5. Write tests using a testing framework like JUnit 5 and the CsvFileSource annotation to load the expected values from a CSV file. The tests should compare the actual output of the converted Java code with the expected values for each input balance.\n\n6. If the tests fail, it indicates a discrepancy between the converted Java code and the original COBOL code. Investigate the differences, such as the sign rule and rounding mode, and apply the necessary fixes to align the Java code with the legacy behavior.\n\n7. Once confirmed that the converted code produces the same output as the original COBOL program for all test cases, you can have confidence that the AI conversion has faithfully preserved the original behavior.\n\nRemember to document the decision to keep the legacy sign rule and rounding behavior, as it may be a rule that production depends on. By following this process and using the original COBOL program's output as the source of truth, you can ensure that the AI-converted COBOL program behaves the same as the original code.",
  "summary": "AI can turn a COBOL program into Java that compiles on the first try. A clean compile tells you the syntax is valid. It says nothing about whether the Java produces the same numbers as the COBOL, and in financial code the numbers are the whole job. This post walks through one small interest calculation, shows where a faithful-looking conversion goes wrong, and builds the test that catches it. The…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}