Skip to content

Commit 1916cc3

Browse files
gabriel376cmccandless
authored andcommitted
high-scores: update test suite to v4.0.0 (exercism#1681)
1 parent a2225fd commit 1916cc3

File tree

3 files changed

+15
-48
lines changed

3 files changed

+15
-48
lines changed

exercises/high-scores/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Manage a game player's High Score list.
44

5-
Your task is to build a high-score component of the classic Frogger game, one of the highest selling and addictive games of all time, and a classic of the arcade era. Your task is to write methods that return the highest score from the list, the last added score, the three highest scores, and a report on the difference between the last and the highest scores.
5+
Your task is to build a high-score component of the classic Frogger game, one of the highest selling and addictive games of all time, and a classic of the arcade era. Your task is to write methods that return the highest score from the list, the last added score and the three highest scores.
66

77
## Submitting Exercises
88

exercises/high-scores/example.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,5 @@ def latest(self):
88
def personal_best(self):
99
return max(self.scores)
1010

11-
def personal_top(self):
11+
def personal_top_three(self):
1212
return sorted(self.scores, reverse=True)[:3]
13-
14-
def report(self):
15-
difference = self.personal_best() - self.latest()
16-
result_qualifier = (
17-
"" if difference <= 0 else "{} short of ".format(difference)
18-
)
19-
return "Your latest score was {}. That's {}your personal best!".format(
20-
self.latest(), result_qualifier
21-
)

exercises/high-scores/high_scores_test.py

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from high_scores import HighScores
44

55

6-
# Tests adapted from `problem-specifications//canonical-data.json` @ v2.0.0
6+
# Tests adapted from `problem-specifications//canonical-data.json` @ v4.0.0
77

88

99
class HighScoreTest(unittest.TestCase):
@@ -22,54 +22,30 @@ def test_personal_best(self):
2222
expected = 100
2323
self.assertEqual(HighScores(scores).personal_best(), expected)
2424

25-
def test_personal_top(self):
26-
scores = [50, 30, 10]
27-
expected = [50, 30, 10]
28-
self.assertEqual(HighScores(scores).personal_top(), expected)
25+
def test_personal_top_three_from_a_long_list(self):
26+
scores = [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70]
27+
expected = [100, 90, 70]
28+
self.assertEqual(HighScores(scores).personal_top_three(), expected)
2929

30-
def test_personal_top_highest_to_lowest(self):
30+
def test_personal_top_three_highest_to_lowest(self):
3131
scores = [20, 10, 30]
3232
expected = [30, 20, 10]
33-
self.assertEqual(HighScores(scores).personal_top(), expected)
33+
self.assertEqual(HighScores(scores).personal_top_three(), expected)
3434

35-
def test_personal_top_when_there_is_a_tie(self):
35+
def test_personal_top_three_when_there_is_a_tie(self):
3636
scores = [40, 20, 40, 30]
3737
expected = [40, 40, 30]
38-
self.assertEqual(HighScores(scores).personal_top(), expected)
38+
self.assertEqual(HighScores(scores).personal_top_three(), expected)
3939

40-
def test_personal_top_when_there_are_less_than_3(self):
40+
def test_personal_top_three_when_there_are_less_than_3(self):
4141
scores = [30, 70]
4242
expected = [70, 30]
43-
self.assertEqual(HighScores(scores).personal_top(), expected)
43+
self.assertEqual(HighScores(scores).personal_top_three(), expected)
4444

45-
def test_personal_top_when_there_is_only_one(self):
45+
def test_personal_top_three_when_there_is_only_one(self):
4646
scores = [40]
4747
expected = [40]
48-
self.assertEqual(HighScores(scores).personal_top(), expected)
49-
50-
def test_personal_top_from_a_long_list(self):
51-
scores = [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70]
52-
expected = [100, 90, 70]
53-
self.assertEqual(HighScores(scores).personal_top(), expected)
54-
55-
def test_message_for_new_personal_best(self):
56-
scores = [20, 40, 0, 30, 70]
57-
expected = "Your latest score was 70. That's your personal best!"
58-
self.assertEqual(HighScores(scores).report(), expected)
59-
60-
def test_message_when_latest_score_is_not_the_highest_score(self):
61-
scores = [20, 100, 0, 30, 70]
62-
expected = (
63-
"Your latest score was 70. That's 30 short of your personal best!"
64-
)
65-
self.assertEqual(HighScores(scores).report(), expected)
66-
67-
def test_message_for_repeated_personal_best(self):
68-
scores = [20, 70, 50, 70, 30]
69-
expected = (
70-
"Your latest score was 30. That's 40 short of your personal best!"
71-
)
72-
self.assertEqual(HighScores(scores).report(), expected)
48+
self.assertEqual(HighScores(scores).personal_top_three(), expected)
7349

7450

7551
if __name__ == "__main__":

0 commit comments

Comments
 (0)