Designing Reproducible Complex Instruction Test Cases for Code Generation Evaluation

    Simple Q&A-style tests can no longer distinguish the real capabilities of code generation models. Using a constrained geometric construction task as an example, this article explains how to design reproducible complex instruction test cases, how to evaluate models at both the result and process levels, and how to implement automated checks in practice.

    As code generation models become part of everyday development workflows, simple Q&A-style tests are no longer sufficient to distinguish their real capabilities. A model that produces runnable code does not necessarily follow multi-step, constraint-heavy instructions faithfully. Using a geometric construction task as an example, this article explains how to design reproducible complex instruction test cases, how to evaluate models at both the result and process levels, and how to implement practical verification methods.

    1. Why Simple Tasks Fail to Reflect Real Capability

    Common evaluation questions only ask the model to “implement a page” or “write a function.” These questions have a large solution space, and a model can score well simply by applying common templates. What really matters are two capabilities: understanding step ordering and constraints, and maintaining consistency throughout long-chain generation.

    Consider the task of “constructing a regular polygon with restricted tools.” The prompt specifies the order of operations: first construct auxiliary lines, then draw a circle centered at a specific point, then let the marked point of the restricted tool move along the circle until a certain intersection condition is met. Such a description looks intuitive, but it requires the model to map each textual step onto concrete drawing instructions. If any intermediate step is replaced or omitted, the final figure may still look correct, yet the process has already deviated from the prompt’s requirements.

    2. Principles for Test Case Design

    1. Make steps explicit. Break the task into a numbered sequence of operations, each with clear inputs and outputs. Avoid vague wording such as “complete using the standard method,” unless evaluating completion ability is itself the goal and the scoring rubric states this.
    2. Make constraints verifiable. Every constraint should be convertible into a boolean or numeric check. For example, “all sides are equal” can be converted into “the maximum relative deviation of side lengths is below a threshold.”
    3. Define the allowed operation set. If the task restricts available operations, state the prohibited approaches in the prompt—for example, forbidding the direct use of analytic formulas to generate the target figure’s vertices.
    4. Fix the output format. If an animation or image file is required, specify the resolution, frame rate, or file format so that automated verification is possible.

    3. Evaluation Dimensions

    An evaluation should cover at least the following five dimensions.

    Correctness: whether the final result satisfies the mathematical or engineering definition. For geometric tasks, check the vertex count, side length consistency, angle consistency, and circumradius consistency.

    Process consistency: whether the implementation path corresponds one-to-one with the steps described in the prompt. This dimension is most often overlooked, because the final figure may match the task exactly while the intermediate steps were invented by the model.

    Completeness: whether all parts the prompt asked to be completed are present, whether the output is truncated, and whether there is only internal reasoning with no visible output at all.

    Latency and stability: record the latency of the first valid output, the total completion time, and the distribution of intervals during output. Long pauses harm the interactive experience even if the final result is correct.

    Reproducibility: the variance of results across multiple runs of the same test case. A single success does not demonstrate stable capability. Run each case several times and report the pass rate.

    4. Automated Result Verification

    For a regular polygon task, extract the vertex coordinates from the final output and run a basic check with the following function.

    1. import math
    2. def check_regular_polygon(points, n, rel_tol=1e-3):
    3. """Check whether a set of vertices forms a regular n-gon.
    4. points is a list of (x, y) tuples."""
    5. if len(points) != n:
    6. return False, f"Expected {n} vertices, got {len(points)}"
    7. # Use the mean of vertex coordinates as the approximate center
    8. cx = sum(p[0] for p in points) / n
    9. cy = sum(p[1] for p in points) / n
    10. # Distances from each vertex to the center should be equal
    11. radii = [math.dist((cx, cy), p) for p in points]
    12. mean_r = sum(radii) / n
    13. if any(abs(r - mean_r) / mean_r > rel_tol for r in radii):
    14. return False, "Distances from vertices to center are inconsistent"
    15. # Adjacent side lengths should be equal
    16. sides = [math.dist(points[i], points[(i + 1) % n]) for i in range(n)]
    17. mean_s = sum(sides) / n
    18. if any(abs(s - mean_s) / mean_s > rel_tol for s in sides):
    19. return False, "Side lengths are inconsistent"
    20. return True, "Passed"

    This function cannot distinguish a convex regular polygon from a star polygon. If the task requires a convex regular polygon, also check that for sequentially ordered adjacent vertices, every polar angle increment equals 2π/n. In addition, this kind of check only verifies the result, not the process. Process verification requires comparing drawing instruction logs or code execution records against the prompt’s steps, one by one.

    5. Detecting “Result-Faking” Implementations

    “Result-faking” means reaching the target without following the operations specified in the prompt, by introducing intermediate quantities or shortcuts the prompt never defined. Common signs include:

    • Auxiliary circles, lines, or variables appear that the prompt never mentioned;
    • Vertices are generated directly with trigonometric functions or fixed coordinates, skipping the required construction process;
    • Step numbers do not map onto code sections, and some steps are missing from the implementation.

    For auditing, build a step-to-implementation mapping table. For each step, list the corresponding code lines or drawing commands. Steps with no corresponding implementation are marked as missing; operations present in the implementation with no corresponding step are marked as extra. Both types of deviation should count as deductions. Looking only at the final image without this comparison will never reveal such problems.

    6. Engineering Practice Recommendations

    When building an evaluation set, follow these practices.

    First, stratify test cases by difficulty—for example, basic geometric operations, single-constraint tasks, multi-constraint tasks, and comprehensive tasks—so that the model’s capability boundary can be located.

    Second, fix the evaluation parameters, including the prompt template, sampling temperature, maximum output length, and timeout, and document them in the report. Results obtained under different parameters are not directly comparable.

    Third, track latency metrics in a separate table. Latency data has different distribution characteristics from correctness data, and mixing them into a single table makes trends hard to read; keeping them separate simplifies statistical analysis and cross-model comparison.