Testing LLMs on Complex Code Generation: A Single-Case Practice Record

    This article documents a single-case test of how large language models handle complex code generation. The task asks a model to build an HTML animation of a regular heptagon drawn with a two-mark ruler, with GIF export. The author compares a lightweight model and a large-parameter model on the same prompt, finds that a page can look correct while violating the required construction method, and offers a checklist for evaluating instruction following.

    Introduction: Why Tests for Complex Code Generation Need to Be Harder

    Simple tasks such as “Hello World” or a basic form can hardly separate one model from another. Most models complete these tasks, and the results look much the same. Developers care more about whether a model follows instructions when a task has multiple constraints and multi-step requirements, and whether its reasoning is reliable.

    This article documents one such test. The test asks a model to implement, in HTML, an animation of a regular heptagon constructed with a two-mark ruler, with support for exporting a GIF. The article explains the design of the test case, describes the problems found during scoring, and provides a practical checklist.

    Test Case: Regular Heptagon with a Two-Mark Ruler

    A two-mark ruler is a straightedge with only two marks on it. It can transfer a fixed length onto paper, and it is used in some compass-and-straightedge constructions. This test case requires the model to carry out the construction in a fixed order. The model must first fill in the standard compass-and-straightedge steps that the prompt leaves out. Then it must find the intersection of the perpendicular bisector with the circle. Finally, it must move the two-mark ruler so that its marks pass through the specified points.

    The difficulty comes from three areas. First, the model must translate geometric operations into coordinate calculations. Second, the steps must follow a required order. The compass should produce only the necessary point movement traces, and extra lines violate the requirements. Third, the code must run in a browser, the animation must be smooth, and the output must be exportable as a GIF.

    The test case can expose problems only when the evaluator has the complete prompt, runnable code, and clear acceptance criteria. Without any one of these, the conclusions are hard to reproduce.

    Single-Case Observation: Two Models Compared

    This test used only one prompt and compared a lightweight model with a large-parameter model. The names, versions, and parameters of the two models are not covered here. The focus is on how each model produced its output.

    The lightweight model spent noticeably longer in its thinking phase. It spent an initial period reasoning without producing any code. The author observed a total time of about 34 minutes. In the generated result, the code follows the construction steps. The perpendicular bisector, the circle, and the intersection points of the ruler marks all correspond to the steps. The point movements in the animation leave traces only where necessary.

    The large-parameter model took about 20 minutes. The page it returned draws a regular heptagon. However, when the author read the code, they found that the model did not build the figure using the two-mark ruler steps. Instead, it calculated the polar coordinates of each vertex directly with trigonometric functions and then connected them. The visual result is the same, but the implementation path does not meet the requirements. This is an instruction-following failure. The page passed the visual check but failed the constraint check.

    Both timing figures come from a single observation. There was no consistent timing method and no repeated experiment, so the figures cannot be used to compare speed. The original code and run logs are not attached to this article.

    Evaluation Takeaways: A Correct Result Is Not a Correct Process

    First, when evaluating code generation, do not look only at the final output. A result that matches the expected visual only shows that the output looks correct. The evaluator must also check whether the code implements the constraints. In business systems, code that bypasses constraints can create hidden maintenance costs or security problems.

    Second, score instruction following separately. When a task has multiple conditions, whether the model executes each step reflects its reliability more accurately than the final page does.

    Third, a single test case is not enough to draw conclusions. This experiment shows only that, on this one prompt, the lightweight model’s steps were closer to the requirements. It does not show that the lightweight model is stronger overall, and it does not prove that the large-parameter model is weaker overall. Reliable conclusions require multiple test cases, repeated runs, and blind review.

    Practical Checklist

    When you design or use prompts for complex code generation, you can follow these five steps:

    1. Constraint list: Write every allowed and forbidden operation as a list. For example: “leave traces only where necessary” and “do not compute vertices directly with angle formulas.”
    2. Step acceptance: Set one check for each construction step. The reviewer must confirm that the code contains a matching implementation, not just a similar-looking picture.
    3. Code review: Read the core functions and confirm where the geometric calculations come from. If key points are computed directly with trigonometric functions, decide whether that violates the constraints.
    4. Repeated runs: Run the same prompt at least several times, and record the pass rate, time taken, and failure types. Define the timing method in advance. For example, measure from submitting the request to receiving the complete code.
    5. Failure archive: Save the full prompt, code, logs, and screenshots. In later tests, use past failures as regression cases.

    You can also ask the model to output its derivation steps first and write the code only after the derivation checks out. This adds an extra round of interaction, but it surfaces logic errors earlier.

    Risk Notice

    This article is a single-case practice record. It is not a model ranking. A result from one prompt should not be used as the basis for production model selection. Selection also requires weighing cost, response latency, security, and long-term stability, and validating on real business data.