From bcd282671a46467b98d5b3eac3b19d5f920f3706 Mon Sep 17 00:00:00 2001 From: Eric Willigers Date: Thu, 25 Jun 2026 14:00:36 +1000 Subject: [PATCH] pursers-pantry: test input unchanged --- .../pursers-pantry/pursers-pantry-tests.factor | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/exercises/concept/pursers-pantry/pursers-pantry/pursers-pantry-tests.factor b/exercises/concept/pursers-pantry/pursers-pantry/pursers-pantry-tests.factor index 6defc13b..17b707aa 100644 --- a/exercises/concept/pursers-pantry/pursers-pantry/pursers-pantry-tests.factor +++ b/exercises/concept/pursers-pantry/pursers-pantry/pursers-pantry-tests.factor @@ -1,4 +1,4 @@ -USING: exercism-tools pursers-pantry tools.test ; +USING: exercism-tools kernel pursers-pantry tools.test ; IN: pursers-pantry.tests TASK: 1 create-inventory @@ -15,6 +15,11 @@ TASK: 2 add-items H{ { "coal" 1 } } { "wood" "iron" "coal" "wood" } add-items ] unit-test +! the original inventory is left unmodified +{ H{ { "coal" 1 } } } [ + H{ { "coal" 1 } } dup { "wood" "iron" "coal" "wood" } add-items drop +] unit-test + TASK: 3 decrement-items { H{ { "coal" 2 } { "diamond" 0 } { "iron" 3 } } } [ H{ { "coal" 3 } { "diamond" 1 } { "iron" 5 } } @@ -30,6 +35,12 @@ TASK: 3 decrement-items H{ { "coal" 2 } } { "gold" "silver" } decrement-items ] unit-test +! the original inventory is left unmodified +{ H{ { "coal" 3 } { "diamond" 1 } { "iron" 5 } } } [ + H{ { "coal" 3 } { "diamond" 1 } { "iron" 5 } } dup + { "diamond" "coal" "iron" "iron" } decrement-items drop +] unit-test + TASK: 4 remove-item { H{ { "wood" 1 } { "diamond" 2 } } } [ H{ { "coal" 2 } { "wood" 1 } { "diamond" 2 } } "coal" remove-item @@ -39,6 +50,11 @@ TASK: 4 remove-item H{ { "coal" 2 } { "wood" 1 } { "diamond" 2 } } "gold" remove-item ] unit-test +! the original inventory is left unmodified +{ H{ { "coal" 2 } { "wood" 1 } { "diamond" 2 } } } [ + H{ { "coal" 2 } { "wood" 1 } { "diamond" 2 } } dup "coal" remove-item drop +] unit-test + TASK: 5 list-inventory { { { "coal" 7 } { "diamond" 2 } { "iron" 7 } { "wood" 11 } } } [ H{ { "coal" 7 } { "wood" 11 } { "diamond" 2 } { "iron" 7 } { "silver" 0 } }