Skip to content

Commit

Permalink
Document using 'null' in hint tests
Browse files Browse the repository at this point in the history
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
  • Loading branch information
david-a-wheeler committed Feb 1, 2025
1 parent 4614921 commit 176da69
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions docs/labs/create_checker.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,18 +442,18 @@ hints: [
absent: ", $",
text: "This is a parameter, it must end with a comma.",
examples: [
[ " " ]
]
[ " " ],
],
},
{
present: "(isint|Isint|IsInt|ISINT)",
text: "JavaScript is case-sensitive. Use isInt instead.",
examples: [
[ " query('id').isint()," ],
[ " query('id').IsInt()," ],
]
}
]
],
},
],
~~~~

The first hint triggers when the user attempt does *not* contain the
Expand All @@ -475,12 +475,17 @@ make smaller changes, test them, and once they work
check them in. That way you won't need to debug a long complicated
set of changes.

Please create tests! You can create test cases for attempts
(`successes` should pass, `failures` should fail), and test cases
to ensure the hints work correctly.
Please create tests! You should create test cases for full attempts
(`successes` should pass, `failures` should fail) and test cases
for hints (`examples`).
Remember, hints are checked in order - it's possible to create a hint
that won't trigger because something earlier would always match.
These tests are automatically checked every time the page is (re)loaded.
All tests are automatically re-run every time the page is (re)loaded.

In a hint, `examples` is an array of examples that should trigger the hint.
Each example is an array of answers. If you use an index, the other index
values aren't considered. We suggest using `null` for array entries
that aren't relevant for the test.

### Debugging

Expand Down

0 comments on commit 176da69

Please sign in to comment.