Module 3 – Design tests that challenge the draft
Choose cases from the requirement
Return to the at-least-70 rule. The corrected function below is paired with three checks: below the threshold, exactly at it, and above it. Their expectations come from the requirement. If the same AI wrote the function and the tests, still derive these outcomes yourself; the two artifacts can share the same misunderstanding.
pragma Assertion_Policy (Check);
with Ada.Text_IO;
procedure Main is
function Passed (Score : Integer) return Boolean is
begin
return Score >= 70;
end Passed;
begin
pragma Assert (not Passed (69));
pragma Assert (Passed (70));
pragma Assert (Passed (71));
Ada.Text_IO.Put_Line ("Threshold checks passed");
end Main;The assertion policy makes these checks active. A passing run prints Threshold checks passed. Change the comparison back to the original strict greater-than version and predict the failing check. Then restore it. This deliberate change helps establish that your test actually distinguishes the two behaviors.
Reference: GNAT: assertions and enabled checks.
Complete this lesson
Answer every check correctly to earn your lesson certificate. Feedback helps you review and try again.
Sign in · Save your progress and earn a certificate for this lesson.