Skip to content

Commit 987a1e8

Browse files
kytrinyxkotp
authored andcommitted
Add immutibility test cases for high-scores
When I was originally updating this exercise from problem-specifications I misunderstood the meaning of the test cases that have properties named `*After*`. I completely missed that these were tagged with the `immutable` scenario. These are not actual properties, but named scenarios that describe expectations around immutability. I have now implemented these test cases, since the Ruby implementation would allow students to create an implementation that mutates internal state in a way that would break the expectations around `.latest` and `personal_best`.
1 parent 9ac4132 commit 987a1e8

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

exercises/practice/high-scores/.meta/tests.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,12 @@ description = "Top 3 scores -> Personal top when there is only one"
3535

3636
[2df075f9-fec9-4756-8f40-98c52a11504f]
3737
description = "Top 3 scores -> Latest score after personal top scores"
38-
include = false
3938

4039
[809c4058-7eb1-4206-b01e-79238b9b71bc]
4140
description = "Top 3 scores -> Scores after personal top scores"
42-
include = false
4341

4442
[ddb0efc0-9a86-4f82-bc30-21ae0bdc6418]
4543
description = "Top 3 scores -> Latest score after personal best"
46-
include = false
4744

4845
[6a0fd2d1-4cc4-46b9-a5bb-2fb667ca2364]
4946
description = "Top 3 scores -> Scores after personal best"
50-
include = false

exercises/practice/high-scores/high_scores_test.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,34 @@ def test_top_3_scores_personal_top_when_there_is_only_one
5050
assert_equal [40], HighScores.new(scores).personal_top_three
5151
end
5252

53+
def test_top_3_scores_latest_score_after_personal_top_scores
54+
skip
55+
high_scores = HighScores.new([70, 50, 20, 30])
56+
high_scores.personal_top_three
57+
assert_equal 30, high_scores.latest
58+
end
59+
60+
def test_top_3_scores_scores_after_personal_top_scores
61+
skip
62+
high_scores = HighScores.new([30, 50, 20, 70])
63+
high_scores.personal_top_three
64+
assert_equal [30, 50, 20, 70], high_scores.scores
65+
end
66+
67+
def test_top_3_scores_latest_score_after_personal_best
68+
skip
69+
high_scores = HighScores.new([20, 70, 15, 25, 30])
70+
high_scores.personal_best
71+
assert_equal 30, high_scores.latest
72+
end
73+
74+
def test_top_3_scores_scores_after_personal_best
75+
skip
76+
high_scores = HighScores.new([20, 70, 15, 25, 30])
77+
high_scores.personal_best
78+
assert_equal [20, 70, 15, 25, 30], high_scores.scores
79+
end
80+
5381
def test_latest_score_is_not_the_personal_best
5482
skip
5583
scores = [100, 40, 10, 70]

0 commit comments

Comments
 (0)