]> gitweb.factorcode.org Git - factor.git/commitdiff
colors: adding some tests rgba to color to rgba roundtrips.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 18 Sep 2013 23:20:20 +0000 (16:20 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 18 Sep 2013 23:20:20 +0000 (16:20 -0700)
extra/colors/cmyk/cmyk-tests.factor [new file with mode: 0644]
extra/colors/hsl/hsl-tests.factor [new file with mode: 0644]
extra/colors/ryb/ryb-tests.factor
extra/colors/yiq/yiq-tests.factor [new file with mode: 0644]

diff --git a/extra/colors/cmyk/cmyk-tests.factor b/extra/colors/cmyk/cmyk-tests.factor
new file mode 100644 (file)
index 0000000..c85b556
--- /dev/null
@@ -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 <range> [| r |
+        0.0 1.0 0.1 <range> [| g |
+            0.0 1.0 0.1 <range> [| b |
+                r g b 1.0 <rgba> 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 (file)
index 0000000..6ca9a98
--- /dev/null
@@ -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 <range> [| r |
+        0.0 1.0 0.1 <range> [| g |
+            0.0 1.0 0.1 <range> [| b |
+                r g b 1.0 <rgba> dup rgba>hsla >rgba
+                [ >rgba-components 4array ] bi@
+                [ 0.00000001 ~ ] 2all?
+            ] all?
+        ] all?
+    ] all?
+] unit-test
index 8e2473106ae2649a53f51e4e339c502ffc539e14..615df956b48e4689bc30e598585a6833fe1d0bb6 100644 (file)
@@ -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 <range> [| r |
+        0.0 1.0 0.1 <range> [| g |
+            0.0 1.0 0.1 <range> [| b |
+                r g b 1.0 <rgba> 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 (file)
index 0000000..8da58bf
--- /dev/null
@@ -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 <range> [| r |
+        0.0 1.0 0.1 <range> [| g |
+            0.0 1.0 0.1 <range> [| b |
+                r g b 1.0 <rgba> dup rgba>yiqa >rgba
+                [ >rgba-components 4array ] bi@
+                [ 0.00000001 ~ ] 2all?
+            ] all?
+        ] all?
+    ] all?
+] unit-test