1- USING: exercism-tools pursers-pantry tools.test ;
1+ USING: exercism-tools kernel pursers-pantry tools.test ;
22IN: pursers-pantry.tests
33
44TASK: 1 create-inventory
@@ -15,6 +15,11 @@ TASK: 2 add-items
1515 H{ { "coal" 1 } } { "wood" "iron" "coal" "wood" } add-items
1616] unit-test
1717
18+ ! the original inventory is left unmodified
19+ { H{ { "coal" 1 } } } [
20+ H{ { "coal" 1 } } dup { "wood" "iron" "coal" "wood" } add-items drop
21+ ] unit-test
22+
1823TASK: 3 decrement-items
1924{ H{ { "coal" 2 } { "diamond" 0 } { "iron" 3 } } } [
2025 H{ { "coal" 3 } { "diamond" 1 } { "iron" 5 } }
@@ -30,6 +35,12 @@ TASK: 3 decrement-items
3035 H{ { "coal" 2 } } { "gold" "silver" } decrement-items
3136] unit-test
3237
38+ ! the original inventory is left unmodified
39+ { H{ { "coal" 3 } { "diamond" 1 } { "iron" 5 } } } [
40+ H{ { "coal" 3 } { "diamond" 1 } { "iron" 5 } } dup
41+ { "diamond" "coal" "iron" "iron" } decrement-items drop
42+ ] unit-test
43+
3344TASK: 4 remove-item
3445{ H{ { "wood" 1 } { "diamond" 2 } } } [
3546 H{ { "coal" 2 } { "wood" 1 } { "diamond" 2 } } "coal" remove-item
@@ -39,6 +50,11 @@ TASK: 4 remove-item
3950 H{ { "coal" 2 } { "wood" 1 } { "diamond" 2 } } "gold" remove-item
4051] unit-test
4152
53+ ! the original inventory is left unmodified
54+ { H{ { "coal" 2 } { "wood" 1 } { "diamond" 2 } } } [
55+ H{ { "coal" 2 } { "wood" 1 } { "diamond" 2 } } dup "coal" remove-item drop
56+ ] unit-test
57+
4258TASK: 5 list-inventory
4359{ { { "coal" 7 } { "diamond" 2 } { "iron" 7 } { "wood" 11 } } } [
4460 H{ { "coal" 7 } { "wood" 11 } { "diamond" 2 } { "iron" 7 } { "silver" 0 } }
0 commit comments