diff --git a/dev/src/Exercise@ResistorColorDuo/ResistorColorDuoTest.class.st b/dev/src/Exercise@ResistorColorDuo/ResistorColorDuoTest.class.st index 047129c5..3b605454 100644 --- a/dev/src/Exercise@ResistorColorDuo/ResistorColorDuoTest.class.st +++ b/dev/src/Exercise@ResistorColorDuo/ResistorColorDuoTest.class.st @@ -76,44 +76,82 @@ ResistorColorDuoTest >> setUp [ { #category : #tests } ResistorColorDuoTest >> test01_BrownAndBlack [ + "Tip: Remember to review the class [Comment] tab" + + + | result | - result := resistorColorDuoCalculator valueWithColors: #('brown' 'black' ) . + result := resistorColorDuoCalculator valueWithColors: #('brown' 'black') . self assert: result equals: 10 ] { #category : #tests } ResistorColorDuoTest >> test02_BlueAndGrey [ + + + | result | - result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey' ) . + result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey') . self assert: result equals: 68 ] { #category : #tests } ResistorColorDuoTest >> test03_YellowAndViolet [ + + + | result | - result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet' ) . + result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet') . self assert: result equals: 47 ] { #category : #tests } -ResistorColorDuoTest >> test04_OrangeAndOrange [ +ResistorColorDuoTest >> test04_WhiteAndRed [ + + + | result | - result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange' ) . + result := resistorColorDuoCalculator valueWithColors: #('white' 'red') . + self assert: result equals: 92 +] + +{ #category : #tests } +ResistorColorDuoTest >> test05_OrangeAndOrange [ + + + + | result | + + result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange') . self assert: result equals: 33 ] { #category : #tests } -ResistorColorDuoTest >> test05_IgnoreExtraColors [ +ResistorColorDuoTest >> test06_IgnoreAdditionalColors [ + + + | result | - result := resistorColorDuoCalculator valueWithColors: #('green' 'brown' 'orange' ) . + result := resistorColorDuoCalculator valueWithColors: #('green' 'brown' 'orange') . self assert: result equals: 51 ] +{ #category : #tests } +ResistorColorDuoTest >> test07_BlackAndBrownOnedigit [ + + + + | result | + + result := resistorColorDuoCalculator valueWithColors: #('black' 'brown') . + self assert: result equals: 1 +] + { #category : #extra } ResistorColorDuoTest >> testDetectInvalidColors [ "first color" diff --git a/exercises/practice/resistor-color-duo/.docs/instructions.md b/exercises/practice/resistor-color-duo/.docs/instructions.md index 85cf1130..bdcd549b 100644 --- a/exercises/practice/resistor-color-duo/.docs/instructions.md +++ b/exercises/practice/resistor-color-duo/.docs/instructions.md @@ -3,8 +3,8 @@ If you want to build something using a Raspberry Pi, you'll probably use _resistors_. For this exercise, you need to know two things about them: -* Each resistor has a resistance value. -* Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read. +- Each resistor has a resistance value. +- Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read. To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values. Each band has a position and a numeric value. @@ -31,4 +31,3 @@ The band colors are encoded as follows: From the example above: brown-green should return 15 brown-green-violet should return 15 too, ignoring the third color. - diff --git a/exercises/practice/resistor-color-duo/.meta/tests.toml b/exercises/practice/resistor-color-duo/.meta/tests.toml index 862b5770..9036fc78 100644 --- a/exercises/practice/resistor-color-duo/.meta/tests.toml +++ b/exercises/practice/resistor-color-duo/.meta/tests.toml @@ -1,6 +1,13 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [ce11995a-5b93-4950-a5e9-93423693b2fc] description = "Brown and black" @@ -11,8 +18,14 @@ description = "Blue and grey" [f1886361-fdfd-4693-acf8-46726fe24e0c] description = "Yellow and violet" +[b7a6cbd2-ae3c-470a-93eb-56670b305640] +description = "White and red" + [77a8293d-2a83-4016-b1af-991acc12b9fe] description = "Orange and orange" [0c4fb44f-db7c-4d03-afa8-054350f156a8] description = "Ignore additional colors" + +[4a8ceec5-0ab4-4904-88a4-daf953a5e818] +description = "Black and brown, one-digit" diff --git a/exercises/practice/resistor-color-duo/ResistorColorDuoTest.class.st b/exercises/practice/resistor-color-duo/ResistorColorDuoTest.class.st index c24da5ed..3b605454 100644 --- a/exercises/practice/resistor-color-duo/ResistorColorDuoTest.class.st +++ b/exercises/practice/resistor-color-duo/ResistorColorDuoTest.class.st @@ -76,32 +76,95 @@ ResistorColorDuoTest >> setUp [ { #category : #tests } ResistorColorDuoTest >> test01_BrownAndBlack [ + "Tip: Remember to review the class [Comment] tab" + + + | result | - result := resistorColorDuoCalculator valueWithColors: #('brown' 'black' ) . + result := resistorColorDuoCalculator valueWithColors: #('brown' 'black') . self assert: result equals: 10 ] { #category : #tests } ResistorColorDuoTest >> test02_BlueAndGrey [ + + + | result | - result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey' ) . + result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey') . self assert: result equals: 68 ] { #category : #tests } ResistorColorDuoTest >> test03_YellowAndViolet [ + + + | result | - result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet' ) . + result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet') . self assert: result equals: 47 ] { #category : #tests } -ResistorColorDuoTest >> test04_OrangeAndOrange [ +ResistorColorDuoTest >> test04_WhiteAndRed [ + + + + | result | + + result := resistorColorDuoCalculator valueWithColors: #('white' 'red') . + self assert: result equals: 92 +] + +{ #category : #tests } +ResistorColorDuoTest >> test05_OrangeAndOrange [ + + + | result | - result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange' ) . + result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange') . self assert: result equals: 33 ] + +{ #category : #tests } +ResistorColorDuoTest >> test06_IgnoreAdditionalColors [ + + + + | result | + + result := resistorColorDuoCalculator valueWithColors: #('green' 'brown' 'orange') . + self assert: result equals: 51 +] + +{ #category : #tests } +ResistorColorDuoTest >> test07_BlackAndBrownOnedigit [ + + + + | result | + + result := resistorColorDuoCalculator valueWithColors: #('black' 'brown') . + self assert: result equals: 1 +] + +{ #category : #extra } +ResistorColorDuoTest >> testDetectInvalidColors [ + "first color" + self + should: [resistorColorDuoCalculator valueWithColors: #('unknown' 'black' )] + raise: Error + whoseDescriptionIncludes: 'Invalid color' + description: 'Should get an error with an unknown color'. + + "second color" + self + should: [resistorColorDuoCalculator valueWithColors: #('black' 'unknown' )] + raise: Error + whoseDescriptionIncludes: 'Invalid color' + description: 'Should get an error with an unknown color' +]