From b3e82347b5bcd5c89d1cf39472faba90e8ea1aa7 Mon Sep 17 00:00:00 2001 From: Matthieu EVRIN Date: Sun, 18 Aug 2019 16:18:58 -0400 Subject: [PATCH] high-scores: validate that functions do not modify the list data --- exercises/high-scores/high_scores_test.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/exercises/high-scores/high_scores_test.py b/exercises/high-scores/high_scores_test.py index 9a35c6d99a..86fd31f3a5 100644 --- a/exercises/high-scores/high_scores_test.py +++ b/exercises/high-scores/high_scores_test.py @@ -41,6 +41,20 @@ def test_personal_top_when_there_is_only_one(self): expected = [40] self.assertEqual(personal_top_three(scores), expected) + def test_latest_not_modify_scores_data(self): + scores = [100, 0, 90, 30] + latest(scores) + self.assertEqual(scores, [100, 0, 90, 30]) + + def test_personal_best_not_modify_scores_data(self): + scores = [40, 100, 70] + personal_best(scores) + self.assertEqual(scores, [40, 100, 70]) + + def test_personal_top_three_not_modify_scores_data(self): + scores = [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70] + personal_top_three(scores) + self.assertEqual(scores, [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70]) if __name__ == "__main__": unittest.main()