diff --git a/src/Cormas-Tests/CMColorTest.class.st b/src/Cormas-Tests/CMColorTest.class.st new file mode 100644 index 00000000..a6144684 --- /dev/null +++ b/src/Cormas-Tests/CMColorTest.class.st @@ -0,0 +1,54 @@ +Class { + #name : 'CMColorTest', + #superclass : 'TestCase', + #category : 'Cormas-Tests-Model', + #package : 'Cormas-Tests', + #tag : 'Model' +} + +{ #category : 'tests' } +CMColorTest >> testHexString [ + + | color hex | + + hex := 'B90E0A'. + color := CMColor fromHexString: hex. + + self assert: (color isKindOf: Color). + self assert: color asHexString equals: hex +] + +{ #category : 'tests' } +CMColorTest >> testRgbTriplet [ + + | rgb color otherColor | + + rgb := #(0.73 0.05 0.04). + color := CMColor fromRgbTriplet: rgb. + + otherColor := CMColor + r: rgb first + g: rgb second + b: rgb third. + + self assert: (color isKindOf: Color). + self assert: otherColor equals: color. + self assert: color rgbTriplet equals: rgb +] + +{ #category : 'tests' } +CMColorTest >> testUnderstandNamedColors [ + + self assert: (CMColor red isKindOf: Color). + self assert: (CMColor green isKindOf: Color). + self assert: (CMColor blue isKindOf: Color). + self assert: (CMColor cyan isKindOf: Color). + self assert: (CMColor yellow isKindOf: Color). + self assert: (CMColor pink isKindOf: Color). + self assert: (CMColor purple isKindOf: Color). + self assert: (CMColor orange isKindOf: Color). + self assert: (CMColor brown isKindOf: Color). + self assert: (CMColor gray isKindOf: Color). + self assert: (CMColor white isKindOf: Color). + self assert: (CMColor black isKindOf: Color) +] diff --git a/src/Cormas-UI/CMColor.class.st b/src/Cormas-UI/CMColor.class.st index 9bfc9345..b42c48cc 100644 --- a/src/Cormas-UI/CMColor.class.st +++ b/src/Cormas-UI/CMColor.class.st @@ -1,6 +1,6 @@ Class { #name : 'CMColor', - #superclass : 'Object', + #superclass : 'Color', #category : 'Cormas-UI', #package : 'Cormas-UI' }