HomeChallengesRepsProblemsLeaderboardTake a challenge

Rules, not examples

Some bugs no example finds. Assert the properties that must always hold.

Advanced22 min on the clock4 graded checks · 100 pointsTests That Catch BugsPro
Graded by running your code against real cases.

What you build

  • Assert the output order, using prices where text sorting differs from numeric
  • Assert nothing was lost, including duplicates
  • Assert the caller’s array was not modified
  • Assert a new array came back rather than the same one

Done means

Your suite passes a correct sortByPrice and fails four that each break one invariant.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. It catches the caller’s array being modified+30Rules that hold for every input
  2. It catches prices being compared as text+25Rules that hold for every input
  3. It catches the order being reversed+20Rules that hold for every input
  4. It catches duplicates being dropped+25Rules that hold for every input

What it teaches

The rest of Tests That Catch Bugs