{
  "fixtureId": "fixture-loop-pass-counter",
  "contractName": "countLoopPasses",
  "lessonIds": [
    "check-zero-iteration-loop",
    "spot-infinite-loop-risk",
    "count-passes-with-loop-table"
  ],
  "invalidInputPolicy": "Reject negative remaining values (remaining < 0) with ERR_NEGATIVE_REMAINING and reject non-positive step values (step <= 0) when remaining > 0 with ERR_INFINITE_LOOP_RISK before executing any pass.",
  "cases": [
    {
      "caseId": "zero-iterations-empty-start",
      "kind": "boundary",
      "input": {
        "remaining": 0,
        "step": 1
      },
      "expected": 0,
      "reason": "Verifies a pretest loop runs 0 passes when remaining starts at 0.",
      "catchesBug": "Off-by-one post-test bug that always runs 1 pass even on empty input"
    },
    {
      "caseId": "typical-exact-batch-passes",
      "kind": "typical",
      "input": {
        "remaining": 4,
        "step": 2
      },
      "expected": 2,
      "reason": "Verifies exact pass count when remaining divides evenly by step.",
      "catchesBug": "Counting 1 extra pass after remaining reaches 0"
    },
    {
      "caseId": "boundary-partial-final-pass",
      "kind": "boundary",
      "input": {
        "remaining": 5,
        "step": 2
      },
      "expected": 3,
      "reason": "Verifies the final partial pass is counted when remaining = 1 before stopping.",
      "catchesBug": "Integer floor division 5 / 2 = 2 that drops the final pass"
    },
    {
      "caseId": "invalid-zero-step-infinite-risk",
      "kind": "invalid",
      "input": {
        "remaining": 3,
        "step": 0
      },
      "expectedError": "ERR_INFINITE_LOOP_RISK",
      "reason": "Zero step fails to reduce remaining > 0 and would cause an infinite loop.",
      "catchesBug": "Allowing a loop with no state progress to run forever"
    },
    {
      "caseId": "invalid-negative-step-wrong-direction",
      "kind": "invalid",
      "input": {
        "remaining": 3,
        "step": -1
      },
      "expectedError": "ERR_INFINITE_LOOP_RISK",
      "reason": "Negative decrement step increases remaining instead of reducing it toward 0.",
      "catchesBug": "Wrong-direction update moving away from the stop condition"
    },
    {
      "caseId": "invalid-negative-remaining",
      "kind": "invalid",
      "input": {
        "remaining": -1,
        "step": 1
      },
      "expectedError": "ERR_NEGATIVE_REMAINING",
      "reason": "Negative starting item count is invalid under the precondition guard.",
      "catchesBug": "Silently treating negative count as 0 without flagging bad input"
    }
  ]
}
