From 0de857e1fe4ebe7d6eefb792d9b031d8c7d8e453 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 18 Sep 2013 16:20:20 -0700 Subject: [PATCH] colors: adding some tests rgba to color to rgba roundtrips. --- extra/colors/cmyk/cmyk-tests.factor | 19 +++++++++++++++++++ extra/colors/hsl/hsl-tests.factor | 19 +++++++++++++++++++ extra/colors/ryb/ryb-tests.factor | 27 +++++++++++++++------------ extra/colors/yiq/yiq-tests.factor | 19 +++++++++++++++++++ 4 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 extra/colors/cmyk/cmyk-tests.factor create mode 100644 extra/colors/hsl/hsl-tests.factor create mode 100644 extra/colors/yiq/yiq-tests.factor diff --git a/extra/colors/cmyk/cmyk-tests.factor b/extra/colors/cmyk/cmyk-tests.factor new file mode 100644 index 0000000000..c85b556954 --- /dev/null +++ b/extra/colors/cmyk/cmyk-tests.factor @@ -0,0 +1,19 @@ +! Copyright (C) 2013 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: arrays colors kernel locals math.functions math.ranges +sequences tools.test ; + +IN: colors.cmyk + +{ t } [ + 0.0 1.0 0.1 [| r | + 0.0 1.0 0.1 [| g | + 0.0 1.0 0.1 [| b | + r g b 1.0 dup rgba>cmyka >rgba + [ >rgba-components 4array ] bi@ + [ 0.00000001 ~ ] 2all? + ] all? + ] all? + ] all? +] unit-test diff --git a/extra/colors/hsl/hsl-tests.factor b/extra/colors/hsl/hsl-tests.factor new file mode 100644 index 0000000000..6ca9a98fb4 --- /dev/null +++ b/extra/colors/hsl/hsl-tests.factor @@ -0,0 +1,19 @@ +! Copyright (C) 2013 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: arrays colors kernel locals math.functions math.ranges +sequences tools.test ; + +IN: colors.hsl + +{ t } [ + 0.0 1.0 0.1 [| r | + 0.0 1.0 0.1 [| g | + 0.0 1.0 0.1 [| b | + r g b 1.0 dup rgba>hsla >rgba + [ >rgba-components 4array ] bi@ + [ 0.00000001 ~ ] 2all? + ] all? + ] all? + ] all? +] unit-test diff --git a/extra/colors/ryb/ryb-tests.factor b/extra/colors/ryb/ryb-tests.factor index 8e2473106a..615df956b4 100644 --- a/extra/colors/ryb/ryb-tests.factor +++ b/extra/colors/ryb/ryb-tests.factor @@ -1,16 +1,19 @@ -USING: assocs colors kernel tools.test ; +! Copyright (C) 2013 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: arrays colors kernel locals math.functions math.ranges +sequences tools.test ; + IN: colors.ryb { t } [ - { - { T{ rgba f 1.0 0.0 0.0 } T{ ryba f 1.0 0.0 0.0 } } - { T{ rgba f 0.0 1.0 0.0 } T{ ryba f 0.0 1.0 1.0 } } - { T{ rgba f 0.0 0.0 1.0 } T{ ryba f 0.0 0.0 1.0 } } - { T{ rgba f 0.0 1.0 1.0 } T{ ryba f 0.0 0.5 1.0 } } - { T{ rgba f 1.0 0.0 1.0 } T{ ryba f 1.0 0.0 1.0 } } - { T{ rgba f 1.0 1.0 0.0 } T{ ryba f 0.0 1.0 0.0 } } - { T{ rgba f 0.0 0.0 0.0 } T{ ryba f 0.0 0.0 0.0 } } - { T{ rgba f 1.0 1.0 1.0 } T{ ryba f 1.0 1.0 1.0 } } - } - [ [ >rgba = ] [ swap rgba>ryba = ] 2bi and ] assoc-all? + 0.0 1.0 0.1 [| r | + 0.0 1.0 0.1 [| g | + 0.0 1.0 0.1 [| b | + r g b 1.0 dup rgba>ryba >rgba + [ >rgba-components 4array ] bi@ + [ 0.00000001 ~ ] 2all? + ] all? + ] all? + ] all? ] unit-test diff --git a/extra/colors/yiq/yiq-tests.factor b/extra/colors/yiq/yiq-tests.factor new file mode 100644 index 0000000000..8da58bfe54 --- /dev/null +++ b/extra/colors/yiq/yiq-tests.factor @@ -0,0 +1,19 @@ +! Copyright (C) 2013 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: arrays colors kernel locals math.functions math.ranges +sequences tools.test ; + +IN: colors.yiq + +{ t } [ + 0.0 1.0 0.1 [| r | + 0.0 1.0 0.1 [| g | + 0.0 1.0 0.1 [| b | + r g b 1.0 dup rgba>yiqa >rgba + [ >rgba-components 4array ] bi@ + [ 0.00000001 ~ ] 2all? + ] all? + ] all? + ] all? +] unit-test