]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojo/tests/colors.js
Comment class stub
[eow] / static / dojo-release-1.1.1 / dojo / tests / colors.js
1 if(!dojo._hasResource["tests.colors"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["tests.colors"] = true;
3 dojo.provide("tests.colors");
4 dojo.require("dojo.colors");
5
6 (function(){
7         var verifyColor = function(t, source, expected){
8                 var source   = new dojo.Color(source);
9                 var expected = new dojo.Color(expected);
10                 t.is(expected.toRgba(), source.toRgba());
11                 dojo.forEach(source.toRgba(), function(n){ t.is("number", typeof(n)); });
12         }
13
14         doh.register("tests.colors", 
15                 [
16                         // all tests below are taken from #4.2 of the CSS3 Color Module
17                         function testColorEx01(t){ verifyColor(t, "black", [0, 0, 0]); },
18                         function testColorEx02(t){ verifyColor(t, "white", [255, 255, 255]); },
19                         function testColorEx03(t){ verifyColor(t, "maroon", [128, 0, 0]); },
20                         function testColorEx04(t){ verifyColor(t, "olive", [128, 128, 0]); },
21                         function testColorEx05(t){ verifyColor(t, "#f00", "red"); },
22                         function testColorEx06(t){ verifyColor(t, "#ff0000", "red"); },
23                         function testColorEx07(t){ verifyColor(t, "rgb(255, 0, 0)", "red"); },
24                         function testColorEx08(t){ verifyColor(t, "rgb(100%, 0%, 0%)", "red"); },
25                         function testColorEx09(t){ verifyColor(t, "rgb(300, 0, 0)", "red"); },
26                         function testColorEx10(t){ verifyColor(t, "rgb(255, -10, 0)", "red"); },
27                         function testColorEx11(t){ verifyColor(t, "rgb(110%, 0%, 0%)", "red"); },
28                         function testColorEx12(t){ verifyColor(t, "rgba(255, 0, 0, 1)", "red"); },
29                         function testColorEx13(t){ verifyColor(t, "rgba(100%, 0%, 0%, 1)", "red"); },
30                         function testColorEx14(t){ verifyColor(t, "rgba(0, 0, 255, 0.5)", [0, 0, 255, 0.5]); },
31                         function testColorEx15(t){ verifyColor(t, "rgba(100%, 50%, 0%, 0.1)", [255, 128, 0, 0.1]); },
32                         function testColorEx16(t){ verifyColor(t, "hsl(0, 100%, 50%)", "red"); },
33                         function testColorEx17(t){ verifyColor(t, "hsl(120, 100%, 50%)", "lime"); },
34                         function testColorEx18(t){ verifyColor(t, "hsl(120, 100%, 25%)", "green"); },
35                         function testColorEx19(t){ verifyColor(t, "hsl(120, 100%, 75%)", "#80ff80"); },
36                         function testColorEx20(t){ verifyColor(t, "hsl(120, 50%, 50%)", "#40c040"); },
37                         function testColorEx21(t){ verifyColor(t, "hsla(120, 100%, 50%, 1)", "lime"); },
38                         function testColorEx22(t){ verifyColor(t, "hsla(240, 100%, 50%, 0.5)", [0, 0, 255, 0.5]); },
39                         function testColorEx23(t){ verifyColor(t, "hsla(30, 100%, 50%, 0.1)", [255, 128, 0, 0.1]); },
40                         function testColorEx24(t){ verifyColor(t, "transparent", [0, 0, 0, 0]); },
41                         // all tests below test greyscale colors
42                         function testColorEx25(t){ verifyColor(t, dojo.colors.makeGrey(5), [5, 5, 5, 1]); },
43                         function testColorEx26(t){ verifyColor(t, dojo.colors.makeGrey(2, 0.3), [2, 2, 2, 0.3]); }
44                 ]
45         );
46 })();
47
48 }