Skip to content

Commit 7dcdd63

Browse files
authored
[factory-sensors] Add test for temperature of 0 degrees (#2538)
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`.
1 parent 43d02cf commit 7dcdd63

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

exercises/concept/factory-sensors/.meta/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
],
55
"contributors": [
66
"SleeplessByte",
7-
"junedev"
7+
"junedev",
8+
"themetar"
89
],
910
"files": {
1011
"solution": [

exercises/concept/factory-sensors/factory-sensors.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ describe('reportOverheating', () => {
2525
expect(() => reportOverheating(null)).toThrow(ArgumentError);
2626
});
2727

28+
test('should not throw if the temperature is 0°C', () => {
29+
expect(() => reportOverheating(0)).not.toThrow();
30+
});
31+
2832
test('should throw an OverheatingError if the temperature is 501°C', () => {
2933
expect(() => reportOverheating(501)).toThrow(OverheatingError);
3034

0 commit comments

Comments
 (0)