Grade 9 · lesson 1 of 4

Choose tests that catch a rule error

Use ordinary and boundary inputs to check a small function.

Download the grade pack

Supplied materials

  • Pseudocode for a fictional ticket classifier: if age < 12, return “child”; otherwise return “standard.” The supplied rule says ages below 12 are child tickets; age 12 and above are standard.
  • Use only invented integer ages; do not submit your age or anyone else’s.

Learn the idea

A test combines an input with an expected output. Choose an ordinary example and examples at a boundary where the rule changes. A passing ordinary case does not prove that the boundary is implemented correctly.

The comparison < excludes the boundary; ≤ includes it. If a programmer accidentally replaces < 12 with ≤ 12, age 11 and age 13 still pass, but age 12 reveals the error.

  1. Write expected outputs for invented ages 11, 12 and 13.
  2. Trace the supplied < 12 classifier for each.
  3. Change the comparison to ≤ 12 and repeat.
  4. Identify the smallest test set here that distinguishes the two comparisons.
Worked example

See the method in action

Correct rule: 11 → child, 12 → standard, 13 → standard. The mistaken ≤ rule labels 12 as child, so the test 12 → standard exposes the boundary error.

Your turn

Check your reasoning

Your answer is temporary and is not saved to an account. Download your current answer before leaving or reloading. Written work on paper or in another app stays in your own file.

Which test specifically detects changing < 12 into ≤ 12?

Feedback appears here after you check. This is practice, not a graded school assessment.

See the answer and explanation

Age 12 should return standard.

Only the boundary input 12 has a different result under those two comparisons. Both rules classify the other supplied ages the same way.

Take it further

Add a requirement that negative ages are rejected rather than classified. Write a test for −1 and describe the new validation step needed.

Nothing here is saved to an account or sent to a teacher. The answer download includes your current choice and any checked feedback.

Longer courses for learners ages 14+

These related courses have their own preparation and projects. They are not early-grade assignments.

Check the subject sources

These LifeStarter passages, scenarios and exercises are authored for this Academy with AI assistance and review. External resources keep their publishers’ terms. A grade label suggests a starting level; it does not establish alignment with your school’s complete requirements.