PC04-L04 · guided challenge

Half-open range

Include the lower boundary and exclude the upper boundary.

Practical CEL4 test casesDocumented
What will I practise?

You can distinguish >=, >, <=, and < precisely with boundary tests.

How is it checked?

Your one expression must produce the expected result for all four JSON inputs.

When am I done?

When all tests pass and you can explain every condition in your expression.

Word problem

A score is valid in a half-open range: it may equal the minimum but must be strictly below the maximum.

Exact requirements

  1. Minimum is included.
  2. Values between the boundaries are included.
  3. Maximum is excluded.
  4. Values below minimum are excluded.

Required result

Write one CEL expression. It must return the expected value and type for all four prepared JSON inputs. Do not change the inputs to make an incomplete expression pass.

Recommended procedure

  1. Translate each numbered requirement into one small boolean condition.
  2. Run the starter expression and inspect which cases fail.
  3. Add one condition at a time and run the complete suite again.
  4. Mark the challenge complete only when you can explain every operator and every boundary.

Solve the challenge · browser test suite

Write one expression that passes every case

Edit the CEL expression, then run it against all prepared JSON inputs. A solution is complete only when every case passes.

4 test cases

Hint: The minimum is allowed; the maximum is not.

Tip: press Ctrl/⌘ + Enter to run all tests.
Exact minimumNot run yet
Expected: true · bool
Show JSON input
{
  "score": 10,
  "range": {
    "minimum": 10,
    "maximum": 20
  }
}
Inside rangeNot run yet
Expected: true · bool
Show JSON input
{
  "score": 15,
  "range": {
    "minimum": 10,
    "maximum": 20
  }
}
Exact maximumNot run yet
Expected: false · bool
Show JSON input
{
  "score": 20,
  "range": {
    "minimum": 10,
    "maximum": 20
  }
}
Below minimumNot run yet
Expected: false · bool
Show JSON input
{
  "score": 9,
  "range": {
    "minimum": 10,
    "maximum": 20
  }
}
Test result

Not run yet

The same expression runs against every case. Test data is fixed so that boundary and failure scenarios cannot be skipped.

Explained solution

Show the complete expression
score >= range.minimum && score < range.maximum

Why the solution works

  1. >= implements the inclusive lower boundary.
  2. < implements the exclusive upper boundary.
  3. && requires both comparisons to hold.
  4. The four cases test the two boundaries, an inside value, and an outside value.

What the test cases prove

  • Exact minimum: expected true (bool).
  • Inside range: expected true (bool).
  • Exact maximum: expected false (bool).
  • Below minimum: expected false (bool).

The cases are intentionally different. A solution that passes only the first case has not yet implemented the complete rule.

Common mistake

Do not optimise the expression for the first successful input. A requirement is implemented only when its positive case, negative case, and boundary case all produce the stated result.

Knowledge check

Can you point to the exact part of the solution that makes each false test case fail? If two different failures depend on the same condition, explain why.

Key takeaway

You can distinguish >=, >, <=, and < precisely with boundary tests.

Sources

  • CEL-DEV — official CEL overview.
  • CEL-LANG — official CEL language definition for operators, types, macros, presence, strings, and time values used in this challenge.