Skip to content

Commit

Permalink
[factory-sensors] Add test for temperature of 0 degrees (#2538)
Browse files Browse the repository at this point in the history
This exercise should reject solutions with `!temperature`.

1) In the story `null` is a special signal that the sensor is
broken. That means in-universe the sensor will needlesly be
replaced if it happens to encounter temperatures of 0 degrees.

2) In our world, the assignment requires that students make
distinction between nulls and numbers. 0 is a valid number.
There is no reason to have it _intentionally_ be handled
differently than -1 or 1 and lumped with `null`.
  • Loading branch information
themetar authored Sep 12, 2024
1 parent 43d02cf commit 7dcdd63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion exercises/concept/factory-sensors/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
],
"contributors": [
"SleeplessByte",
"junedev"
"junedev",
"themetar"
],
"files": {
"solution": [
Expand Down
4 changes: 4 additions & 0 deletions exercises/concept/factory-sensors/factory-sensors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ describe('reportOverheating', () => {
expect(() => reportOverheating(null)).toThrow(ArgumentError);
});

test('should not throw if the temperature is 0°C', () => {
expect(() => reportOverheating(0)).not.toThrow();
});

test('should throw an OverheatingError if the temperature is 501°C', () => {
expect(() => reportOverheating(501)).toThrow(OverheatingError);

Expand Down

0 comments on commit 7dcdd63

Please sign in to comment.