OSDN Git Service

Rmove a frame property from the object
[sie/sie.git] / tool / Spec / spec / SvgDomSpec.js
1 /*SIE-SVG without Plugin under LGPL2.1 & GPL2.0 & Mozilla Public Lisence\r
2  *公式ページは http://sie.sourceforge.jp/\r
3  */\r
4 /* ***** BEGIN LICENSE BLOCK *****\r
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1\r
6  *\r
7  * The contents of this file are subject to the Mozilla Public License Version\r
8  * 1.1 (the "License"); you may not use this file except in compliance with\r
9  * the License. You may obtain a copy of the License at\r
10  * http://www.mozilla.org/MPL/\r
11  *\r
12  * Software distributed under the License is distributed on an "AS IS" basis,\r
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\r
14  * for the specific language governing rights and limitations under the\r
15  * License.\r
16  *\r
17  * The Original Code is the Mozilla SVG Cairo Renderer project.\r
18  *\r
19  * The Initial Developer of the Original Code is IBM Corporation.\r
20  * Portions created by the Initial Developer are Copyright (C) 2004\r
21  * the Initial Developer. All Rights Reserved.\r
22  *\r
23  * Parts of this file contain code derived from the following files(s)\r
24  * of the Mozilla SVG project (these parts are Copyright (C) by their\r
25  * respective copyright-holders):\r
26  *    layout/svg/renderer/src/libart/nsSVGLibartBPathBuilder.cpp\r
27  *\r
28  * Contributor(s):DHRNAME revulo bellbind\r
29  *\r
30  * Alternatively, the contents of this file may be used under the terms of\r
31  * either of the GNU General Public License Version 2 or later (the "GPL"),\r
32  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),\r
33  * in which case the provisions of the GPL or the LGPL are applicable instead\r
34  * of those above. If you wish to allow use of your version of this file only\r
35  * under the terms of either the GPL or the LGPL, and not to allow others to\r
36  * use your version of this file under the terms of the MPL, indicate your\r
37  * decision by deleting the provisions above and replace them with the notice\r
38  * and other provisions required by the GPL or the LGPL. If you do not delete\r
39  * the provisions above, a recipient may use your version of this file under\r
40  * the terms of any one of the MPL, the GPL or the LGPL.\r
41  *\r
42  * ***** END LICENSE BLOCK ***** */\r
43 /*\r
44  * Copyright (c) 2000 World Wide Web Consortium,\r
45  * (Massachusetts Institute of Technology, Institut National de\r
46  * Recherche en Informatique et en Automatique, Keio University). All\r
47  * Rights Reserved. This program is distributed under the W3C's Software\r
48  * Intellectual Property License. This program is distributed in the\r
49  * hope that it will be useful, but WITHOUT ANY WARRANTY; without even\r
50  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
51  * PURPOSE.\r
52  * See W3C License http://www.w3.org/Consortium/Legal/ for more details.\r
53  */\r
54 /*\r
55  *Copyright (c) 2008-2010 Pivotal Labs\r
56 \r
57 Permission is hereby granted, free of charge, to any person obtaining\r
58 a copy of this software and associated documentation files (the\r
59 "Software"), to deal in the Software without restriction, including\r
60 without limitation the rights to use, copy, modify, merge, publish,\r
61 distribute, sublicense, and/or sell copies of the Software, and to\r
62 permit persons to whom the Software is furnished to do so, subject to\r
63 the following conditions:\r
64 \r
65 The above copyright notice and this permission notice shall be\r
66 included in all copies or substantial portions of the Software.\r
67 \r
68 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
69 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
70 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
71 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
72 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
73 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
74 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
75  */\r
76 \r
77 describe("SVG Spec in JavaScript", function() {\r
78   /*Refer to W3C SVG1.1 (second edition)*/\r
79   var doc, svg;\r
80   beforeEach(function() {\r
81     /*前もって実行しておく変数(The variable 'doc' is a document node, and the 'svg' is a root element node.)*/\r
82     doc = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg");\r
83     svg = doc.documentElement;\r
84   });\r
85   describe("SVG Unit :: SVG Length", function() {\r
86     var s;\r
87     beforeEach(function() {\r
88       s = svg.createSVGLength();\r
89     });\r
90     /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a SVGLength interface.)*/\r
91     it("for the default value on the property of SVGLength", function() {\r
92       /*See http://www.w3.org/TR/SVG/struct.html#InterfaceSVGDocument\r
93        * *createSVGLength()\r
94        * *Creates an SVGLength object outside of any document trees. The object is initialized to the value of 0 user units.\r
95        *see also http://www.w3.org/TR/SVG/types.html#InterfaceSVGLength\r
96        * *SVG_LENGTHTYPE_NUMBER (unsigned short)\r
97        * *No unit type was provided (i.e., a unitless value was specified), which indicates a value in user units.\r
98        */\r
99       expect(s.value).toEqual(0);\r
100       expect(s.valueInSpecifiedUnits).toEqual(0);\r
101       expect(s.unitType).toEqual(1);\r
102     });\r
103     /*境界条件を調べておく (limit value analysis)*/\r
104     it("should be this for the value, when it calls a newValueSpecifiedUnits method", function() {\r
105       var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, -Number.MIN_VALUE];\r
106       for (var i=0,tli=t.length;i<tli;++i) {\r
107         s.newValueSpecifiedUnits(1, t[i]);\r
108         expect(s.valueInSpecifiedUnits).toEqual(t[i]);\r
109         expect(s.value).toEqual(t[i]);\r
110         expect(s.valueAsString).toEqual(t[i]+"");\r
111         expect(s.unitType).toEqual(1);\r
112       }\r
113       t = null;\r
114     });\r
115     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
116     it("should be this for the value, when it calls a newValueSpecifiedUnits method", function() {\r
117       var t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく\r
118       for (var i=1;i<num;++i) {\r
119         t[t.length] = Math.pow(10, i);\r
120         t[t.length] = Math.pow(10, -i);\r
121         t[t.length] = Math.pow(10, i);\r
122         t[t.length] = Math.pow(10, -i);\r
123       }\r
124       for (var i=0,tli=t.length;i<tli;++i) {\r
125         s.newValueSpecifiedUnits(1, t[i]);\r
126         expect(s.valueInSpecifiedUnits).toEqual(t[i]);\r
127         expect(s.value).toEqual(t[i]);\r
128         expect(s.valueAsString).toEqual(t[i]+"");\r
129         expect(s.unitType).toEqual(1);\r
130       }\r
131       t = null;\r
132     });\r
133     /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
134     it("should throw a DOMException 'Not Supported Error', when it calls a newValueSpecifiedUnits method", function() {\r
135       var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
136       for (var i=0,tli=t.length;i<tli;++i) {\r
137         var ti = t[i], sn = function() {\r
138           s.newValueSpecifiedUnits(ti, 0);\r
139         };\r
140         expect(sn).toThrow();\r
141         ti = sn = null;\r
142       }\r
143       t = null;\r
144     });\r
145     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
146     it("should be this for the value, when it calls a convertToSpecifiedUnits method", function() {\r
147       var unit = ["", "%", "em", "ex", "px", "cm", "mm", "in", "pt", "pc"];\r
148       for (var i=1,tli=11;i<tli;++i) {\r
149         s.convertToSpecifiedUnits(i);\r
150         expect(s.valueInSpecifiedUnits).toEqual(0);\r
151         expect(s.value).toEqual(0);\r
152         expect(s.valueAsString).toEqual("0" + unit[i-1]);\r
153         expect(s.unitType).toEqual(i);\r
154       }\r
155       /*2cmにまず設定しておいて、その後、convertToSpecifiedUnitsメソッドで"mm"単位に変換する。\r
156        * (The 's' value set to "2cm", and convert from "cm" to "mm" unit in convertToSpecifiedUnits method.\r
157        */\r
158       s.newValueSpecifiedUnits(6, 2);\r
159       var sv = s.value;\r
160       s.convertToSpecifiedUnits(7);\r
161       expect(s.valueInSpecifiedUnits).toEqual(20);\r
162       expect(s.value).toEqual(sv);\r
163       expect(s.valueAsString).toEqual("20mm");\r
164       expect(s.unitType).toEqual(7);\r
165       unit = sv = null;\r
166     });\r
167     /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
168     it("should throw a DOMException 'Not Supported Error', when it calls a convertToSpecifiedUnits method", function() {\r
169       var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
170       for (var i=0,tli=t.length;i<tli;++i) {\r
171         var ti = t[i], sn = function() {\r
172           s.convertToSpecifiedUnits(ti);\r
173         };\r
174         expect(sn).toThrow();\r
175         ti = sn = null;\r
176       }\r
177       t = null;\r
178     });\r
179   });\r
180   describe("SVG Unit :: SVG Matrix", function() {\r
181     var s;\r
182     beforeEach(function() {\r
183       s = svg.createSVGMatrix();\r
184     });\r
185     it("for the default value on the property of SVGMatrix", function() {\r
186       /*See http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement\r
187        * *The object is initialized to the identity matrix.\r
188        *以下では、createSVGElementが単位行列を返しているかどうかをチェック\r
189        */\r
190       expect(s.a).toEqual(1);\r
191       expect(s.b).toEqual(0);\r
192       expect(s.c).toEqual(0);\r
193       expect(s.d).toEqual(1);\r
194       expect(s.e).toEqual(0);\r
195       expect(s.f).toEqual(0);\r
196     });\r
197     /*境界条件を調べておく (limit value analysis about a 'multiply')*/\r
198     it("should be this for the value, when it calls a 'multiply' method", function() {\r
199       var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, Number.MIN_VALUE, 0];\r
200       for (var i=0,tli=t.length;i<tli;++i) {\r
201         var n = svg.createSVGMatrix();\r
202         n.a = t[i];\r
203         n.b = t[i];\r
204         n.c = t[i];\r
205         n.d = t[i];\r
206         n.e = t[i];\r
207         s.multiply(n);\r
208         n = null;\r
209       }\r
210       t = null;\r
211     });\r
212     it("should return the SVGMatrix Object, when it calls a 'multiply' method", function() {\r
213       var t = s.multiply(svg.createSVGMatrix());\r
214       expect(t.a).toEqual(1);\r
215       expect(t.b).toEqual(0);\r
216       expect(t.c).toEqual(0);\r
217       expect(t.d).toEqual(1);\r
218       expect(t.e).toEqual(0);\r
219       expect(t.f).toEqual(0);\r
220       /*See http://www.w3.org/TR/SVG/coords.html#InterfaceSVGMatrix\r
221        * *..returning the resulting new matrix.\r
222        *以下では新しいSVGMatrixオブジェクトを返しているかどうかをチェック\r
223        */\r
224       expect(t).toNotBe(s);\r
225       var u = svg.createSVGMatrix();\r
226       t.a = u.a = 2;\r
227       t.b = u.b = 2;\r
228       t.c = u.c = 2;\r
229       t.d = u.d = 2;\r
230       t.e = u.e = 2;\r
231       t.f = u.f = 2;\r
232       var m = t.multiply(u);\r
233       expect(m.a).toEqual(8);\r
234       expect(m.b).toEqual(8);\r
235       expect(m.c).toEqual(8);\r
236       expect(m.d).toEqual(8);\r
237       expect(m.e).toEqual(10);\r
238       expect(m.f).toEqual(10);\r
239     });\r
240     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
241     it("should be this for the value", function() {\r
242       var t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく\r
243       for (var i=1;i<num;++i) {\r
244         t[t.length] = Math.pow(10, i);\r
245         t[t.length] = Math.pow(10, -i);\r
246         t[t.length] = Math.pow(10, i);\r
247         t[t.length] = Math.pow(10, -i);\r
248       }\r
249       for (var i=0,tli=t.length;i<tli;++i) {\r
250         var n = svg.createSVGMatrix(), ti = t[i];\r
251         n.a = ti;\r
252         n.b = ti;\r
253         n.c = ti;\r
254         n.d = ti;\r
255         n.e = ti;\r
256         n.f = ti;\r
257         var d = s.multiply(n);\r
258         /*注:sが単位行列であることに注意すること (Note that the variable 's' is a identity matrix)*/\r
259         expect(d.a).toEqual(ti);\r
260         expect(d.b).toEqual(ti);\r
261         expect(d.c).toEqual(ti);\r
262         expect(d.d).toEqual(ti);\r
263         expect(d.e).toEqual(ti);\r
264         expect(d.f).toEqual(ti);\r
265         n = d = null;\r
266       }\r
267       t = null;\r
268     });\r
269     /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
270     it("should throw an Error, when it calls a 'multiply' method", function() {\r
271       var t = [Number.NEGATIVE_INFINITY,\r
272                Number.POSITIVE_INFINITY,\r
273                Number.NaN,\r
274                undefined];\r
275       for (var i=0,tli=t.length;i<tli;++i) {\r
276         var ti = t[i], sn = function() {\r
277           var n = svg.createSVGMatrix();\r
278           n.a = 0;\r
279           n.b = 0;\r
280           n.c = 0;\r
281           n.d = 0;\r
282           n.e = 0;\r
283           n.f = ti;\r
284           s.multiply(n);\r
285         };\r
286         expect(sn).toThrow();\r
287         ti = sn = null;\r
288       }\r
289       t = null;\r
290     });\r
291     /*逆行列に関する境界条件を調べておく (limit value analysis about a 'inverse')*/\r
292     it("should be this for the value, when it calls a 'inverse' method ((limit value analysis)", function() {\r
293       var si = s.inverse(), t = [s.multiply(si), si.multiply(s)];\r
294       s.a = -1;\r
295       si = s.inverse();\r
296       t[t.length] = s.multiply(si);\r
297       t[t.length] = si.multiply(s);\r
298       s.a = 1;\r
299       s.d = -1;\r
300       si = s.inverse();\r
301       t[t.length] = s.multiply(si);\r
302       t[t.length] = si.multiply(s);\r
303       s.b = -1;\r
304       s.c = 1;\r
305       s.d = 1;\r
306       si = s.inverse();\r
307       t[t.length] = s.multiply(si);\r
308       t[t.length] = si.multiply(s);\r
309       s.b = 1;\r
310       s.c = -1;\r
311       si = s.inverse();\r
312       t[t.length] = s.multiply(si);\r
313       t[t.length] = si.multiply(s);\r
314       for (var i=0;i<t.length;++i) {\r
315         var d = t[i];\r
316         expect(d.a).toEqual(1);\r
317         expect(d.b).toEqual(0);\r
318         expect(d.c).toEqual(0);\r
319         expect(d.d).toEqual(1);\r
320         expect(d.e).toEqual(0);\r
321         expect(d.f).toEqual(0);\r
322         d = null;\r
323       }\r
324       si = t = null;\r
325     });\r
326     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
327     it("should be this for the value, when it calls a 'inverse' method (Equivalence partitioning, the following is the valid partion)", function() {\r
328       var si = s.inverse(), t = [];\r
329       s.a = -1;\r
330       s.e = 0;\r
331       s.f = 1;\r
332       si = s.inverse();\r
333       t[t.length] = s.multiply(si);\r
334       t[t.length] = si.multiply(s);\r
335       s.a = 1;\r
336       s.d = -1;\r
337       s.e = 10000;\r
338       s.f = -10000;\r
339       si = s.inverse();\r
340       t[t.length] = s.multiply(si);\r
341       t[t.length] = si.multiply(s);\r
342       s.b = -1;\r
343       s.c = 1;\r
344       s.d = 1;\r
345       s.e = 0.0001;\r
346       s.f = -0.0001;\r
347       si = s.inverse();\r
348       t[t.length] = s.multiply(si);\r
349       t[t.length] = si.multiply(s);\r
350       s.b = 1;\r
351       s.c = -1;\r
352       s.d = 1;\r
353       s.e = 1;\r
354       s.f = 1;\r
355       si = s.inverse();\r
356       t[t.length] = s.multiply(si);\r
357       t[t.length] = si.multiply(s);\r
358       for (var i=0;i<t.length;++i) {\r
359         var d = t[i];\r
360         expect(d.a).toEqual(1);\r
361         expect(d.b).toEqual(0);\r
362         expect(d.c).toEqual(0);\r
363         expect(d.d).toEqual(1);\r
364         expect(d.e).toEqual(0);\r
365         expect(d.f).toEqual(0);\r
366         d = null;\r
367       }\r
368       si = t = null;\r
369     });\r
370     it("should throw an Error, when it calls a 'inverse' method", function() {\r
371       /*以下では行列式が0なので、逆行列が成り立たない (it is invalid in these cases because the determint is zero)*/\r
372       var t = [1, 1, 1, 1,\r
373                0, 0, 0, 0,\r
374                2, 4, 2, 4,\r
375                2.5, -1, 2.5, -1];\r
376       for (var i=0;i<t.length;i+=4) {\r
377         s.a = t[i];\r
378         s.b = t[i+1];\r
379         s.c = t[i+2];\r
380         s.d = t[i+3];\r
381       };\r
382       expect(s.inverse).toThrow();\r
383       t = null;\r
384     });\r
385     /*併進変換に関する境界条件を調べておく (limit value analysis about the 'translate')*/\r
386     it("should be this for the value, when it calls the 'translate' method", function() {\r
387       var t = [0, 0,\r
388                -1, 0,\r
389                1, -1,\r
390                Number.MAX_VALUE, Number.MIN_VALUE];\r
391       for (var i=0;i<t.length;i+=2) {\r
392         var d = s.translate(t[i], t[i+1]);\r
393         expect(d.a).toEqual(1);\r
394         expect(d.b).toEqual(0);\r
395         expect(d.c).toEqual(0);\r
396         expect(d.d).toEqual(1);\r
397         expect(d.e).toEqual(t[i]);\r
398         expect(d.f).toEqual(t[i+1]);\r
399         expect(d).toNotBe(s);\r
400       }\r
401     });\r
402     /*伸縮変換に関する境界条件を調べておく (limit value analysis about the 'scale')*/\r
403     it("should be this for the value, when it calls the 'scale' method", function() {\r
404       var t = [0,\r
405                -1,\r
406                1,\r
407                Number.MAX_VALUE,\r
408                Number.MIN_VALUE];\r
409       for (var i=0;i<t.length;i+=2) {\r
410         var d = s.scale(t[i]);\r
411         expect(d.a).toEqual(t[i]);\r
412         expect(d.b).toEqual(0);\r
413         expect(d.c).toEqual(0);\r
414         expect(d.d).toEqual(t[i]);\r
415         expect(d.e).toEqual(0);\r
416         expect(d.f).toEqual(0);\r
417         expect(d).toNotBe(s);\r
418       }\r
419     });\r
420     /*比率の違う伸縮変換に関する境界条件を調べておく (limit value analysis about the 'scaleNonUniform')*/\r
421     it("should be this for the value, when it calls the 'scaleNonUniform' method", function() {\r
422       var t = [0, 0,\r
423                -1, 0,\r
424                1, -1,\r
425                Number.MAX_VALUE, Number.MIN_VALUE];\r
426       for (var i=0;i<t.length;i+=2) {\r
427         var d = s.scaleNonUniform(t[i], t[i+1]);\r
428         expect(d.a).toEqual(t[i]);\r
429         expect(d.b).toEqual(0);\r
430         expect(d.c).toEqual(0);\r
431         expect(d.d).toEqual(t[i+1]);\r
432         expect(d.e).toEqual(0);\r
433         expect(d.f).toEqual(0);\r
434         expect(d).toNotBe(s);\r
435       }\r
436     });\r
437     /*回転変換に関する境界条件を調べておく (limit value analysis about the 'rotate')*/\r
438     it("should be this for the value, when it calls the 'rotate' method", function() {\r
439       var t = [0,\r
440                -1,\r
441                1,\r
442                Number.MAX_VALUE,\r
443                Number.MIN_VALUE];\r
444       for (var i=0;i<t.length;i+=2) {\r
445         var d = s.rotate(t[i]);\r
446         expect(d.a).toEqual(Math.cos(t[i] / 180 * Math.PI));\r
447         expect(d.b).toEqual(Math.sin(t[i] / 180 * Math.PI));\r
448         expect(d.c).toEqual(-Math.sin(t[i] / 180 * Math.PI));\r
449         expect(d.d).toEqual(Math.cos(t[i] / 180 * Math.PI));\r
450         expect(d.e).toEqual(0);\r
451         expect(d.f).toEqual(0);\r
452         expect(d).toNotBe(s);\r
453       }\r
454     });\r
455     /*座標指定による回転変換に関する境界条件を調べておく (limit value analysis about the 'rotateFromVector')*/\r
456     it("should be this for the value, when it calls the 'rotateFromVector'", function() {\r
457       var t = [1, 1,\r
458                -1, -1,\r
459                1, -1,\r
460                -1, 1,\r
461                Number.MAX_VALUE, Number.MIN_VALUE];\r
462       for (var i=0;i<t.length;i+=2) {\r
463         var d = s.rotateFromVector(t[i], t[i+1]);\r
464         expect(d.a).toEqual(Math.cos(Math.atan2(t[i+1], t[i])));\r
465         expect(d.b).toEqual(Math.sin(Math.atan2(t[i+1], t[i])));\r
466         expect(d.c).toEqual(-Math.sin(Math.atan2(t[i+1], t[i])));\r
467         expect(d.d).toEqual(Math.cos(Math.atan2(t[i+1], t[i])));\r
468         expect(d.e).toEqual(0);\r
469         expect(d.f).toEqual(0);\r
470         expect(d).toNotBe(s);\r
471       }\r
472     });\r
473     /*座標指定による回転変換に関して同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
474     it("should throw an SVG Invalid Value Error, when it calls the 'rotateFromVector' method", function() {\r
475       var t = [0,\r
476                Number.NEGATIVE_INFINITY,\r
477                Number.POSITIVE_INFINITY,\r
478                Number.NaN,\r
479                undefined];\r
480       for (var i=0;i<t.length;++i) {\r
481         var f = function() {\r
482           var d = s.rotateFromVector(t[i], 1);\r
483         };\r
484         expect(f).toThrow();\r
485         f = function() {\r
486           var d = s.rotateFromVector(1, t[i]);\r
487         };\r
488         expect(f).toThrow();\r
489       }\r
490       t = f = null;\r
491     });\r
492     /*x軸によって向き合わせとなる変換に関する境界条件を調べておく (limit value analysis about the 'flipX')*/\r
493     it("should be this for the value, when it calls the 'flipX' method", function() {\r
494       var t = [0,\r
495                -1,\r
496                1,\r
497                Number.MAX_VALUE,\r
498                Number.MIN_VALUE];\r
499       for (var i=0;i<t.length;++i) {\r
500         s.a = t[i];\r
501         s.d = t[i];\r
502         var d = s.flipX();\r
503         expect(d.a).toEqual(-t[i]);\r
504         expect(d.b).toEqual(0);\r
505         expect(d.c).toEqual(0);\r
506         expect(d.d).toEqual(t[i]);\r
507         expect(d.e).toEqual(0);\r
508         expect(d.f).toEqual(0);\r
509         expect(d).toNotBe(s);\r
510       }\r
511     });\r
512     /*y軸によって向き合わせとなる変換に関する境界条件を調べておく (limit value analysis about the 'flipY')*/\r
513     it("should be this for the value, when it calls the 'flipY' method", function() {\r
514       var t = [0,\r
515                -1,\r
516                1,\r
517                Number.MAX_VALUE,\r
518                Number.MIN_VALUE];\r
519       for (var i=0;i<t.length;++i) {\r
520         s.a = t[i];\r
521         s.d = t[i];\r
522         var d = s.flipY();\r
523         expect(d.a).toEqual(t[i]);\r
524         expect(d.b).toEqual(0);\r
525         expect(d.c).toEqual(0);\r
526         expect(d.d).toEqual(-t[i]);\r
527         expect(d.e).toEqual(0);\r
528         expect(d.f).toEqual(0);\r
529         expect(d).toNotBe(s);\r
530       }\r
531     });\r
532     /*横の傾き変換に関する境界条件を調べておく (limit value analysis about the 'skewX')*/\r
533     it("should be this for the value, when it calls the 'skewX' method", function() {\r
534       var t = [0,\r
535                -1,\r
536                1,\r
537                Number.MAX_VALUE,\r
538                Number.MIN_VALUE];\r
539       for (var i=0;i<t.length;i+=2) {\r
540         var d = s.skewX(t[i]);\r
541         expect(d.a).toEqual(1);\r
542         expect(d.b).toEqual(0);\r
543         expect(d.c).toEqual(Math.tan(t[i] / 180 * Math.PI));\r
544         expect(d.d).toEqual(1);\r
545         expect(d.e).toEqual(0);\r
546         expect(d.f).toEqual(0);\r
547         expect(d).toNotBe(s);\r
548       }\r
549     });\r
550     /*縦の傾き変換に関する境界条件を調べておく (limit value analysis about the 'skewY')*/\r
551     it("should be this for the value, when it calls the 'skewY' method", function() {\r
552       var t = [0,\r
553                -1,\r
554                1,\r
555                Number.MAX_VALUE,\r
556                Number.MIN_VALUE];\r
557       for (var i=0;i<t.length;i+=2) {\r
558         var d = s.skewY(t[i]);\r
559         expect(d.a).toEqual(1);\r
560         expect(d.b).toEqual(Math.tan(t[i] / 180 * Math.PI));\r
561         expect(d.c).toEqual(0);\r
562         expect(d.d).toEqual(1);\r
563         expect(d.e).toEqual(0);\r
564         expect(d.f).toEqual(0);\r
565         expect(d).toNotBe(s);\r
566       }\r
567     });\r
568   });\r
569   describe("SVG Unit :: SVG Transform", function() {\r
570     var s;\r
571     beforeEach(function() {\r
572       s = svg.createSVGTransform();\r
573     });\r
574     it("for the default value on the property of SVGTransform", function() {\r
575       /*5.11.2 Interface SVGSVGElement\r
576        *http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement\r
577        *\r
578        * *The object is initialized to an identity matrix transform (SVG_TRANSFORM_MATRIX).\r
579        */\r
580       expect(s.type).toEqual(1); //SVG_TRANSFORM_MATRIX = 1\r
581       expect(s.angle).toEqual(0);\r
582       var d = s.matrix;\r
583       expect(d.a).toEqual(1);\r
584       expect(d.b).toEqual(0);\r
585       expect(d.c).toEqual(0);\r
586       expect(d.d).toEqual(1);\r
587       expect(d.e).toEqual(0);\r
588       expect(d.f).toEqual(0);\r
589       d = null;\r
590     });\r
591     /*境界条件を調べておく (limit value analysis about the 'setMatrix')*/\r
592     it("should be this for the value, when it calls the 'setMatrix' method", function() {\r
593       /*7.14.4 Interface SVGTransform\r
594        *http://www.w3.org/TR/SVG/coords.html#InterfaceSVGTransform\r
595        *\r
596        * *void setMatrix(in SVGMatrix matrix)\r
597        * *values from the parameter matrix are copied, the matrix parameter does not replace SVGTransform::matrix.\r
598        */\r
599       var m = svg.createSVGMatrix(), t = [0,\r
600                                           -1,\r
601                                           1,\r
602                                           Number.MAX_VALUE,\r
603                                           Number.MIN_VALUE,\r
604                                           -Number.MIN_VALUE];\r
605       for (var i=0;i<t.length;++i) {\r
606         m.a = t[i];\r
607         m.b = t[i];\r
608         m.c = t[i];\r
609         m.d = t[i];\r
610         m.e = t[i];\r
611         m.f = t[i];\r
612         s.setMatrix(m);\r
613         expect(s.type).toEqual(1);\r
614         expect(s.angle).toEqual(0);\r
615         var d = s.matrix;\r
616         expect(d.a).toEqual(m.a);\r
617         expect(d.b).toEqual(m.b);\r
618         expect(d.c).toEqual(m.c);\r
619         expect(d.d).toEqual(m.d);\r
620         expect(d.e).toEqual(m.e);\r
621         expect(d.f).toEqual(m.f);\r
622         expect(d).toNotBe(m);\r
623       }\r
624       d = m = null;\r
625     });\r
626     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
627     it("should be this for the value, when it calls a 'setMatrix' method", function() {\r
628       var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
629       for (var i=1;i<num;++i) {\r
630         t[t.length] = Math.pow(10, i);\r
631         t[t.length] = Math.pow(10, -i);\r
632         t[t.length] = Math.pow(10, i);\r
633         t[t.length] = Math.pow(10, -i);\r
634       }\r
635       for (var i=0,tli=t.length;i<tli;++i) {\r
636         var n = svg.createSVGMatrix(), ti = t[i];\r
637         n.a = ti;\r
638         n.b = ti;\r
639         n.c = ti;\r
640         n.d = ti;\r
641         n.e = ti;\r
642         n.f = ti;\r
643         s.setMatrix(n);\r
644         s.setMatrix(n); //二重に指定しても問題はないはず (No problem is to call the 'setMatirx' method twice)\r
645         expect(s.type).toEqual(1);\r
646         expect(s.angle).toEqual(0);\r
647         var d = s.matrix;\r
648         /*注:sが単位行列であることに注意すること (Note that the variable 's' is a identity matrix)*/\r
649         expect(d.a).toEqual(ti);\r
650         expect(d.b).toEqual(ti);\r
651         expect(d.c).toEqual(ti);\r
652         expect(d.d).toEqual(ti);\r
653         expect(d.e).toEqual(ti);\r
654         expect(d.f).toEqual(ti);\r
655         expect(d).toNotBe(n);\r
656         n = d = null;\r
657       }\r
658       t = null;\r
659     });\r
660     /*境界条件を調べておく (limit value analysis about the 'setTranslate')*/\r
661     it("should be this for the value, when it calls the 'setTranslate' method", function() {\r
662       var t = [0,\r
663                -1,\r
664                1,\r
665                Number.MAX_VALUE,\r
666                Number.MIN_VALUE,\r
667                -Number.MIN_VALUE];\r
668       for (var i=0;i<t.length;++i) {\r
669         s.setTranslate(t[i], t[i]);\r
670         expect(s.type).toEqual(2); //SVG_TRANSFORM_TRANSLATE = 2\r
671         expect(s.angle).toEqual(0);\r
672         var d = s.matrix;\r
673         expect(d.a).toEqual(1);\r
674         expect(d.b).toEqual(0);\r
675         expect(d.c).toEqual(0);\r
676         expect(d.d).toEqual(1);\r
677         expect(d.e).toEqual(t[i]);\r
678         expect(d.f).toEqual(t[i]);\r
679       }\r
680       d = m = null;\r
681     });\r
682     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
683     it("should be this for the value, when it calls a 'setTranslate' method", function() {\r
684       var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
685       for (var i=1;i<num;++i) {\r
686         t[t.length] = Math.pow(10, i);\r
687         t[t.length] = Math.pow(10, -i);\r
688         t[t.length] = Math.pow(10, i);\r
689         t[t.length] = Math.pow(10, -i);\r
690       }\r
691       for (var i=0,tli=t.length;i<tli;++i) {\r
692         var ti = t[i];\r
693         s.setTranslate(ti, ti);\r
694         s.setTranslate(ti, ti);\r
695         expect(s.type).toEqual(2);\r
696         expect(s.angle).toEqual(0);\r
697         var d = s.matrix;\r
698         expect(d.a).toEqual(1);\r
699         expect(d.b).toEqual(0);\r
700         expect(d.c).toEqual(0);\r
701         expect(d.d).toEqual(1);\r
702         expect(d.e).toEqual(ti);\r
703         expect(d.f).toEqual(ti);\r
704         ti = n = d = null;\r
705       }\r
706       t = null;\r
707     });\r
708     /*境界条件を調べておく (limit value analysis about the 'setScale')*/\r
709     it("should be this for the value, when it calls the 'setScale' method", function() {\r
710       var t = [0,\r
711                -1,\r
712                1,\r
713                Number.MAX_VALUE,\r
714                Number.MIN_VALUE,\r
715                -Number.MIN_VALUE];\r
716       for (var i=0;i<t.length;++i) {\r
717         s.setScale(t[i], t[i]);\r
718         expect(s.type).toEqual(3); //SVG_TRANSFORM_SCALE = 3\r
719         expect(s.angle).toEqual(0);\r
720         var d = s.matrix;\r
721         expect(d.a).toEqual(t[i]);\r
722         expect(d.b).toEqual(0);\r
723         expect(d.c).toEqual(0);\r
724         expect(d.d).toEqual(t[i]);\r
725         expect(d.e).toEqual(0);\r
726         expect(d.f).toEqual(0);\r
727       }\r
728       d = null;\r
729     });\r
730     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
731     it("should be this for the value, when it calls a 'setScale' method", function() {\r
732       var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
733       for (var i=1;i<num;++i) {\r
734         t[t.length] = Math.pow(10, i);\r
735         t[t.length] = Math.pow(10, -i);\r
736         t[t.length] = Math.pow(10, i);\r
737         t[t.length] = Math.pow(10, -i);\r
738       }\r
739       for (var i=0,tli=t.length;i<tli;++i) {\r
740         var ti = t[i];\r
741         s.setScale(ti, ti);\r
742         s.setScale(ti, ti);\r
743         expect(s.type).toEqual(3);\r
744         expect(s.angle).toEqual(0);\r
745         var d = s.matrix;\r
746         expect(d.a).toEqual(ti);\r
747         expect(d.b).toEqual(0);\r
748         expect(d.c).toEqual(0);\r
749         expect(d.d).toEqual(ti);\r
750         expect(d.e).toEqual(0);\r
751         expect(d.f).toEqual(0);\r
752         ti = n = d = null;\r
753       }\r
754       t = null;\r
755     });\r
756     /*境界条件を調べておく (limit value analysis about the 'setRotate')*/\r
757     it("should be this for the value, when it calls the 'setRotate' method", function() {\r
758       var t = [0,\r
759                -1,\r
760                1];\r
761       for (var i=0;i<t.length;++i) {\r
762         s.setRotate(10, t[i], t[i]);\r
763         var m = svg.createSVGMatrix();\r
764         m = m.rotate(10);\r
765         m.e = (1-m.a)*t[i] - m.c*t[i];\r
766         m.f = -m.b*t[i] + (1-m.d)*t[i];\r
767         expect(s.type).toEqual(4); //SVG_TRANSFORM_ROTATE = 4\r
768         expect(s.angle).toEqual(10);\r
769         var d = s.matrix;\r
770         expect(d.a).toEqual(m.a);\r
771         expect(d.b).toEqual(m.b);\r
772         expect(d.c).toEqual(m.c);\r
773         expect(d.d).toEqual(m.d);\r
774         expect(d.e).toEqual(m.e);\r
775         expect(d.f).toEqual(m.f);\r
776       }\r
777       d = m = null;\r
778     });\r
779     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
780     it("should be this for the value, when it calls a 'setRotate' method", function() {\r
781       var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
782       for (var i=1;i<num;++i) {\r
783         t[t.length] = Math.pow(10, i);\r
784         t[t.length] = Math.pow(10, -i);\r
785         t[t.length] = Math.pow(10, i);\r
786         t[t.length] = Math.pow(10, -i);\r
787       }\r
788       for (var i=0,tli=t.length;i<tli;++i) {\r
789         var ti = t[i], m = svg.createSVGMatrix();\r
790         m = m.rotate(10);\r
791         m.e = (1-m.a)*ti - m.c*ti;\r
792         m.f = -m.b*ti + (1-m.d)*ti;\r
793         s.setRotate(10, ti, ti);\r
794         s.setRotate(10, ti, ti);\r
795         expect(s.type).toEqual(4);\r
796         expect(s.angle).toEqual(10);\r
797         var d = s.matrix;\r
798         expect(d.a).toEqual(m.a);\r
799         expect(d.b).toEqual(m.b);\r
800         expect(d.c).toEqual(m.c);\r
801         expect(d.d).toEqual(m.d);\r
802         expect(d.e).toEqual(m.e);\r
803         expect(d.f).toEqual(m.f);\r
804         ti = n = d = null;\r
805       }\r
806       t = null;\r
807     });\r
808     /*境界条件を調べておく (limit value analysis about the 'setSkewX')*/\r
809     it("should be this for the value, when it calls the 'setSkewX' method", function() {\r
810       var t = [0,\r
811                -1,\r
812                1,\r
813                Number.MAX_VALUE,\r
814                Number.MIN_VALUE,\r
815                -Number.MIN_VALUE];\r
816       for (var i=0;i<t.length;++i) {\r
817         s.setSkewX(t[i]);\r
818         var m = svg.createSVGMatrix();\r
819         m = m.skewX(t[i]);\r
820         expect(s.type).toEqual(5); //SVG_TRANSFORM_SKEWX = 5\r
821         expect(s.angle).toEqual(t[i]);\r
822         var d = s.matrix;\r
823         expect(d.a).toEqual(m.a);\r
824         expect(d.b).toEqual(m.b);\r
825         expect(d.c).toEqual(m.c);\r
826         expect(d.d).toEqual(m.d);\r
827         expect(d.e).toEqual(m.e);\r
828         expect(d.f).toEqual(m.f);\r
829       }\r
830       t = null;\r
831     });\r
832     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
833     it("should be this for the value, when it calls a 'setSkewX' method", function() {\r
834       var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
835       for (var i=1;i<num;++i) {\r
836         t[t.length] = Math.pow(10, i);\r
837         t[t.length] = Math.pow(10, -i);\r
838         t[t.length] = Math.pow(10, i);\r
839         t[t.length] = Math.pow(10, -i);\r
840       }\r
841       for (var i=0,tli=t.length;i<tli;++i) {\r
842         var ti = t[i], m = svg.createSVGMatrix();\r
843         m = m.skewX(ti);\r
844         s.setSkewX(ti);\r
845         s.setSkewX(ti);\r
846         expect(s.type).toEqual(5);\r
847         expect(s.angle).toEqual(ti);\r
848         var d = s.matrix;\r
849         expect(d.a).toEqual(m.a);\r
850         expect(d.b).toEqual(m.b);\r
851         expect(d.c).toEqual(m.c);\r
852         expect(d.d).toEqual(m.d);\r
853         expect(d.e).toEqual(m.e);\r
854         expect(d.f).toEqual(m.f);\r
855         ti = n = d = null;\r
856       }\r
857       t = null;\r
858     });\r
859     /*境界条件を調べておく (limit value analysis about the 'setSkewY')*/\r
860     it("should be this for the value, when it calls the 'setSkewY' method", function() {\r
861       var t = [0,\r
862                -1,\r
863                1,\r
864                Number.MAX_VALUE,\r
865                Number.MIN_VALUE,\r
866                -Number.MIN_VALUE];\r
867       for (var i=0;i<t.length;++i) {\r
868         s.setSkewY(t[i]);\r
869         var m = svg.createSVGMatrix();\r
870         m = m.skewY(t[i]);\r
871         expect(s.type).toEqual(6); //SVG_TRANSFORM_SKEWY = 6\r
872         expect(s.angle).toEqual(t[i]);\r
873         var d = s.matrix;\r
874         expect(d.a).toEqual(m.a);\r
875         expect(d.b).toEqual(m.b);\r
876         expect(d.c).toEqual(m.c);\r
877         expect(d.d).toEqual(m.d);\r
878         expect(d.e).toEqual(m.e);\r
879         expect(d.f).toEqual(m.f);\r
880       }\r
881       t = null;\r
882     });\r
883     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
884     it("should be this for the value, when it calls a 'setSkewY' method", function() {\r
885       var t = [Math.PI, 10/3], num = (t[0]+"").length - 1;\r
886       for (var i=1;i<num;++i) {\r
887         t[t.length] = Math.pow(10, i);\r
888         t[t.length] = Math.pow(10, -i);\r
889         t[t.length] = Math.pow(10, i);\r
890         t[t.length] = Math.pow(10, -i);\r
891       }\r
892       for (var i=0,tli=t.length;i<tli;++i) {\r
893         var ti = t[i], m = svg.createSVGMatrix();\r
894         m = m.skewY(ti);\r
895         s.setSkewY(ti);\r
896         s.setSkewY(ti);\r
897         expect(s.type).toEqual(6);\r
898         expect(s.angle).toEqual(ti);\r
899         var d = s.matrix;\r
900         expect(d.a).toEqual(m.a);\r
901         expect(d.b).toEqual(m.b);\r
902         expect(d.c).toEqual(m.c);\r
903         expect(d.d).toEqual(m.d);\r
904         expect(d.e).toEqual(m.e);\r
905         expect(d.f).toEqual(m.f);\r
906         ti = n = d = null;\r
907       }\r
908       t = null;\r
909     });\r
910   });\r
911   describe("SVG Unit :: SVGNumber", function() {\r
912     var s;\r
913     beforeEach(function() {\r
914       s = svg.createSVGNumber();\r
915     });\r
916     /*デフォルト値かどうかをチェックしていく(Checking the default value of a SVGNumber interface.)*/\r
917     it("for the default value on the property of SVGNumber", function() {\r
918       expect(s.value).toEqual(0);\r
919     });\r
920   });\r
921   describe("SVG Unit :: SVGAngle", function() {\r
922     var s;\r
923     beforeEach(function() {\r
924       s = svg.createSVGAngle();\r
925     });\r
926     /*デフォルト値かどうかをチェックしていく(Checking the default value of a SVGNumber interface.)*/\r
927     it("for the default value on the property of SVGAngle", function() {\r
928       expect(s.value).toEqual(0);\r
929       expect(s.valueInSpecifiedUnits).toEqual(0);\r
930       expect(s.unitType).toEqual(1);\r
931     });\r
932     /*境界条件を調べておく (limit value analysis)*/\r
933     it("should be this for the value, when it calls a newValueSpecifiedUnits method (limit value analysis)", function() {\r
934       var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, -Number.MIN_VALUE];\r
935       for (var i=0,tli=t.length;i<tli;++i) {\r
936         s.newValueSpecifiedUnits(1, t[i]);\r
937         expect(s.valueInSpecifiedUnits).toEqual(t[i]);\r
938         expect(s.value).toEqual(t[i]);\r
939         expect(s.valueAsString).toEqual(t[i]+"");\r
940         expect(s.unitType).toEqual(1);\r
941       }\r
942       t = null;\r
943     });\r
944     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
945     it("should be this for the value, when it calls a newValueSpecifiedUnits method (the valid partion)", function() {\r
946       var t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく\r
947       for (var i=1;i<num;++i) {\r
948         t[t.length] = Math.pow(10, i);\r
949         t[t.length] = Math.pow(10, -i);\r
950         t[t.length] = Math.pow(10, i);\r
951         t[t.length] = Math.pow(10, -i);\r
952       }\r
953       for (var i=0,tli=t.length;i<tli;++i) {\r
954         s.newValueSpecifiedUnits(1, t[i]);\r
955         expect(s.valueInSpecifiedUnits).toEqual(t[i]);\r
956         expect(s.value).toEqual(t[i]);\r
957         expect(s.valueAsString).toEqual(t[i]+"");\r
958         expect(s.unitType).toEqual(1);\r
959       }\r
960       t = null;\r
961     });\r
962     /*同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
963     it("should throw a DOMException 'Not Supported Error', when it calls a newValueSpecifiedUnits method (the invalid partion)", function() {\r
964       var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
965       for (var i=0,tli=t.length;i<tli;++i) {\r
966         var ti = t[i],\r
967             sn = function() {\r
968               s.newValueSpecifiedUnits(ti, 0);\r
969             };\r
970         expect(sn).toThrow();\r
971         ti = sn = null;\r
972       }\r
973       t = null;\r
974     });\r
975     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
976     it("should be this for the value, when it calls a convertToSpecifiedUnits method (the valid partion)", function() {\r
977       var unit = ["", "deg", "rad", "grad"];\r
978       for (var i=1,tli=4;i<tli;++i) {\r
979         s.convertToSpecifiedUnits(i);\r
980         expect(s.valueInSpecifiedUnits).toEqual(0);\r
981         expect(s.value).toEqual(0);\r
982         expect(s.valueAsString).toEqual("0" + unit[i-1]);\r
983         expect(s.unitType).toEqual(i);\r
984       }\r
985       /*2gradにまず設定しておいて、その後、convertToSpecifiedUnitsメソッドで"deg"単位に変換する。\r
986        * (The 's' value set to "2cm", and convert from "cm" to "mm" unit in convertToSpecifiedUnits method.\r
987        */\r
988       s.newValueSpecifiedUnits(4, 2);\r
989       var sv = s.value;\r
990       s.convertToSpecifiedUnits(2);\r
991       expect(s.valueInSpecifiedUnits).toEqual(1.8);\r
992       expect(s.value).toEqual(sv);\r
993       expect(s.valueAsString).toEqual("1.8deg");\r
994       expect(s.unitType).toEqual(2);\r
995       unit = sv = null;\r
996     });\r
997     /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
998     it("should throw a DOMException 'Not Supported Error', when it calls a convertToSpecifiedUnits method (the invalid partion)", function() {\r
999       var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
1000       for (var i=0,tli=t.length;i<tli;++i) {\r
1001         var ti = t[i], sn = function() {\r
1002           s.convertToSpecifiedUnits(ti);\r
1003         };\r
1004         expect(sn).toThrow();\r
1005         ti = sn = null;\r
1006       }\r
1007       t = null;\r
1008     });\r
1009   });\r
1010   describe("SVG Unit :: SVGColor (the SVGColor interface is deprecated by W3C)", function() {\r
1011     /*SVGColorインターフェースは廃止予定 (The SVGColor interface is deprecated by W3C.)*/\r
1012     var s;\r
1013     beforeEach(function() {\r
1014       svg.style.setProperty("stop-color", "white");\r
1015       s = svg.style.getPropertyCSSValue("stop-color"); //stop-colorプロパティはSVGColor型オブジェクトを返す\r
1016     });\r
1017     /*デフォルト値かどうかをチェックしていく(Checking the default value of the SVGColor interface.)*/\r
1018     it("for the default value on the property of SVGColor", function() {\r
1019       expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);\r
1020       expect(s.rgbColor.green.getFloatValue(1)).toEqual(255);\r
1021       expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);\r
1022       expect(s.colorType).toEqual(1);\r
1023     });\r
1024     /*境界条件を調べておく (limit value analysis, when it calls a setRGBColor method)*/\r
1025     it("should be this for the value, when it calls a setRGBColor method (limit value analysis)", function() {\r
1026       var cls = ["black", "rgb(0, 0, 0)", "#000000", "#000", "rgb(0%, 0%, 0%)", "white", "rgb(255, 255, 255)", "#ffffff", "#fff", "rgb(100%, 100%, 100%)"];\r
1027       for (var i=0;i<5;++i) {\r
1028         /*すべて黒色を示す値  (All value indicate a black color)*/\r
1029         s.setRGBColor(cls[i]);\r
1030         expect(s.rgbColor.red.getFloatValue(1)).toEqual(0);\r
1031         expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);\r
1032         expect(s.rgbColor.blue.getFloatValue(1)).toEqual(0);\r
1033         expect(s.colorType).toEqual(1);\r
1034       }\r
1035       for (var i=5;i<10;++i) {\r
1036         /*すべて白色を示す値  (All value indicate a white color)*/\r
1037         s.setRGBColor(cls[i]);\r
1038         expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);\r
1039         expect(s.rgbColor.green.getFloatValue(1)).toEqual(255);\r
1040         expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);\r
1041         expect(s.colorType).toEqual(1);\r
1042       }\r
1043     });\r
1044     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion, when it calls a setRGBColor method)*/\r
1045     it("should be this for the value, when it calls a setRGBColor method (the valid partion)", function() {\r
1046       var cls = ["gainsboro", "rgb(220, 220, 220)", "#dcdcdc", "magenta", "rgb(255, 0, 255)", "#ff00ff", "#f0f", "rgb(100%, 0%, 100%)"];\r
1047       for (var i=0;i<3;++i) {\r
1048         /*すべてgainsboro色を示す値  (All value indicate a gainsboro color)*/\r
1049         s.setRGBColor(cls[i]);\r
1050         expect(s.rgbColor.red.getFloatValue(1)).toEqual(220);\r
1051         expect(s.rgbColor.green.getFloatValue(1)).toEqual(220);\r
1052         expect(s.rgbColor.blue.getFloatValue(1)).toEqual(220);\r
1053         expect(s.colorType).toEqual(1);\r
1054       }\r
1055       for (var i=3;i<8;++i) {\r
1056         /*すべてgainsboro色を示す値  (All value indicate a gainsboro color)*/\r
1057         s.setRGBColor(cls[i]);\r
1058         expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);\r
1059         expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);\r
1060         expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);\r
1061         expect(s.colorType).toEqual(1);\r
1062       }\r
1063       s.setRGBColor("rgb(20%, 40%, 99%)");\r
1064       expect(s.rgbColor.red.getFloatValue(1)).toEqual(51);\r
1065       expect(s.rgbColor.green.getFloatValue(1)).toEqual(102);\r
1066       expect(s.rgbColor.blue.getFloatValue(1)).toEqual(252);\r
1067       expect(s.colorType).toEqual(1);\r
1068     });\r
1069     /*setRGBColorメソッドの同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
1070     it("should throw a DOMException 'SVG_INVALID_VALUE_ERR', when it calls a setRGBColor method (the invalid partion)", function() {\r
1071       var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
1072       for (var i=0,tli=t.length;i<tli;++i) {\r
1073         var ti = t[i], sn = function() {\r
1074           s.setRGBColor(ti);\r
1075         };\r
1076         expect(sn).toThrow();\r
1077         ti = sn = null;\r
1078       }\r
1079       t = null;\r
1080     });\r
1081     /*setColorメソッドの境界条件を調べておく (limit value analysis, when it calls a setColor method)*/\r
1082     it("should be this for the value, when it calls a setColor method (limit value analysis)", function() {\r
1083       var cls = ["black", "rgb(0, 0, 0)", "#000000", "#000", "rgb(0%, 0%, 0%)", "white", "rgb(255, 255, 255)", "#ffffff", "#fff", "rgb(100%, 100%, 100%)"];\r
1084       for (var i=0;i<5;++i) {\r
1085         /*すべて黒色を示す値  (All value indicate a black color)*/\r
1086         s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);\r
1087         expect(s.rgbColor.red.getFloatValue(1)).toEqual(0);\r
1088         expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);\r
1089         expect(s.rgbColor.blue.getFloatValue(1)).toEqual(0);\r
1090         expect(s.colorType).toEqual(1);\r
1091       }\r
1092       for (var i=5;i<10;++i) {\r
1093         /*すべて白色を示す値  (All value indicate a white color)*/\r
1094         s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);\r
1095         expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);\r
1096         expect(s.rgbColor.green.getFloatValue(1)).toEqual(255);\r
1097         expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);\r
1098         expect(s.colorType).toEqual(1);\r
1099       }\r
1100       s.setColor(/*SVG_COLORTYPE_CURRENTCOLOR*/ 3, null, null);\r
1101       expect(s.colorType).toEqual(3);\r
1102     });\r
1103     /*setColorメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion, when it calls a setColor method)*/\r
1104     it("should be this for the value, when it calls a setColor method (the valid partion)", function() {\r
1105       var cls = ["gainsboro", "rgb(220, 220, 220)", "#dcdcdc", "magenta", "rgb(255, 0, 255)", "#ff00ff", "#f0f", "rgb(100%, 0%, 100%)"];\r
1106       for (var i=0;i<3;++i) {\r
1107         /*すべてgainsboro色を示す値  (All value indicate a gainsboro color)*/\r
1108         s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);\r
1109         expect(s.rgbColor.red.getFloatValue(1)).toEqual(220);\r
1110         expect(s.rgbColor.green.getFloatValue(1)).toEqual(220);\r
1111         expect(s.rgbColor.blue.getFloatValue(1)).toEqual(220);\r
1112         expect(s.colorType).toEqual(1);\r
1113       }\r
1114       for (var i=3;i<8;++i) {\r
1115         /*すべてgainsboro色を示す値  (All value indicate a gainsboro color)*/\r
1116         s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, cls[i], null);\r
1117         expect(s.rgbColor.red.getFloatValue(1)).toEqual(255);\r
1118         expect(s.rgbColor.green.getFloatValue(1)).toEqual(0);\r
1119         expect(s.rgbColor.blue.getFloatValue(1)).toEqual(255);\r
1120         expect(s.colorType).toEqual(1);\r
1121       }\r
1122       s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, "rgb(20%, 40%, 99%)", null);\r
1123       expect(s.rgbColor.red.getFloatValue(1)).toEqual(51);\r
1124       expect(s.rgbColor.green.getFloatValue(1)).toEqual(102);\r
1125       expect(s.rgbColor.blue.getFloatValue(1)).toEqual(252);\r
1126       expect(s.colorType).toEqual(1);\r
1127     });\r
1128     /*setColorメソッドの同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/\r
1129     it("should throw a DOMException 'SVG_INVALID_VALUE_ERR', when it calls a setColor method (the invalid partion)", function() {\r
1130       var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1];\r
1131       var cls = ["gainsboro", "rgb(220, 220, 220)", "#dcdcdc", "magenta", "rgb(255, 0, 255)", "#ff00ff", "#f0f", "rgb(100%, 0%, 100%)"];\r
1132       for (var i=0,tli=t.length;i<tli;++i) {\r
1133         var ti = t[i], sn = function() {\r
1134           s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, ti, null);\r
1135         };\r
1136         expect(sn).toThrow();\r
1137         ti = sn = null;\r
1138       }\r
1139       for (var i=0,tli=cls.length;i<tli;++i) {\r
1140         var ci = cls[i], sn = function() {\r
1141           s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, ci, ci);\r
1142         };\r
1143         expect(sn).toThrow();\r
1144         ci = sn = null;\r
1145       }\r
1146       for (var i=0,tli=cls.length;i<tli;++i) {\r
1147         var ci = cls[i], sn = function() {\r
1148           s.setColor(/*SVG_COLORTYPE_RGBCOLOR*/ 1, null, ci);\r
1149         };\r
1150         expect(sn).toThrow();\r
1151         ci = sn = null;\r
1152       }\r
1153       for (var i=0,tli=t.length,ci=cls[0];i<tli;++i) {\r
1154         var ti = t[i], sn = function() {\r
1155           s.setColor(/*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2, null, ti);\r
1156           s.setColor(/*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2, ci, ti);\r
1157         };\r
1158         expect(sn).toThrow();\r
1159         ti = sn = null;\r
1160       }\r
1161       for (var i=0,tli=cls.length;i<tli;++i) {\r
1162         var ci = cls[i], sn = function() {\r
1163           s.setColor(/*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0, ci, null);\r
1164           s.setColor(/*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0, ci, ci);\r
1165         };\r
1166         expect(sn).toThrow();\r
1167         ci = sn = null;\r
1168       }\r
1169       t = cls = null;\r
1170     });\r
1171   });\r
1172   describe("SVG Unit :: SVG Point", function() {\r
1173     /*http://www.w3.org/TR/SVG/coords.html#InterfaceSVGPoint\r
1174      * 7.15.1 Interface SVGPoint\r
1175      *  An SVGPoint is an (x, y) coordinate pair.\r
1176      */\r
1177     var s;\r
1178     beforeEach(function() {\r
1179       s = svg.createSVGPoint();\r
1180     });\r
1181     it("for the default value on the property of SVGPoint", function() {\r
1182       /*http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement\r
1183        * SVGPoint createSVGPoint()\r
1184        * 'The object is initialized to the point (0,0) in the user coordinate system.'\r
1185        */\r
1186       expect(s.x).toEqual(0);\r
1187       expect(s.y).toEqual(0);\r
1188     });\r
1189     /*境界条件を調べておく (limit value analysis, when it calls a matrixTransform method)*/\r
1190     it("should be this for the value, when it calls a matrixTransform method (limit value analysis)", function() {\r
1191       var matrix = svg.createSVGMatrix(), t = [0,\r
1192                                                -1,\r
1193                                                1,\r
1194                                                Number.MAX_VALUE,\r
1195                                                Number.MIN_VALUE,\r
1196                                                -Number.MIN_VALUE],\r
1197           n;\r
1198       for (var i=0;i<t.length;++i) {\r
1199         matrix.a = t[i];\r
1200         matrix.c = t[i];\r
1201         n = s.matrixTransform(matrix);\r
1202         expect(n.x).toEqual(0);\r
1203         expect(n.y).toEqual(0);\r
1204       }\r
1205       for (var i=0;i<t.length;++i) {\r
1206         matrix.e = t[i];\r
1207         matrix.f = t[i];\r
1208         n = s.matrixTransform(matrix);\r
1209         expect(n.x).toEqual(t[i]);\r
1210         expect(n.y).toEqual(t[i]);\r
1211       }\r
1212     });\r
1213     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1214     it("should be this for the value, when it calls a matrixTransform method (the valid partion)", function() {\r
1215       var matrix = svg.createSVGMatrix(),\r
1216           t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく\r
1217       for (var i=1;i<num;++i) {\r
1218         t[t.length] = Math.pow(10, i);\r
1219         t[t.length] = Math.pow(10, -i);\r
1220         t[t.length] = Math.pow(10, i);\r
1221         t[t.length] = Math.pow(10, -i);\r
1222       }\r
1223       for (var i=0,tli=t.length;i<tli;++i) {\r
1224         matrix.a = t[i];\r
1225         matrix.c = t[i];\r
1226         n = s.matrixTransform(matrix);\r
1227         expect(n.x).toEqual(0);\r
1228         expect(n.y).toEqual(0);\r
1229       }\r
1230       for (var i=0;i<t.length;++i) {\r
1231         matrix.e = t[i];\r
1232         matrix.f = t[i];\r
1233         n = s.matrixTransform(matrix);\r
1234         expect(n.x).toEqual(t[i]);\r
1235         expect(n.y).toEqual(t[i]);\r
1236       }\r
1237     });\r
1238     /*同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1239     it("should throw a Error, when it calls a matrixTransform method (the invalid partion)", function() {\r
1240       var matrix = svg.createSVGMatrix(),\r
1241           t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}];\r
1242       for (var i=0,tli=t.length;i<tli;++i) {\r
1243         var ti = t[i],\r
1244             sn = function() {\r
1245               s.matrixTransform(ti);\r
1246             },\r
1247             stn = function() {\r
1248               s.matrixTransform();\r
1249             },\r
1250             an = function() {\r
1251               matrix.a = ti;\r
1252               s.matrixTransform(matrix);\r
1253             },\r
1254             bn = function() {\r
1255               matrix.a = 0;\r
1256               matrix.b = ti;\r
1257               s.matrixTransform(matrix);\r
1258             },\r
1259             cn = function() {\r
1260               matrix.b = 0;\r
1261               matrix.c = ti;\r
1262               s.matrixTransform(matrix);\r
1263             },\r
1264             dn = function() {\r
1265               matrix.c = 0;\r
1266               matrix.d = ti;\r
1267               s.matrixTransform(matrix);\r
1268             },\r
1269             en = function() {\r
1270               matrix.d = 0;\r
1271               matrix.e = ti;\r
1272               s.matrixTransform(matrix);\r
1273             },\r
1274             fn = function() {\r
1275               matrix.e = 0;\r
1276               matrix.f = ti;\r
1277               s.matrixTransform(matrix);\r
1278             };\r
1279         expect(sn).toThrow();\r
1280         expect(stn).toThrow();\r
1281         expect(an).toThrow();\r
1282         expect(bn).toThrow();\r
1283         expect(cn).toThrow();\r
1284         expect(dn).toThrow();\r
1285         expect(en).toThrow();\r
1286         expect(fn).toThrow();\r
1287         ti = sn = an = bn = cn = dn = en = fn = null;\r
1288       }\r
1289     });\r
1290   });\r
1291   describe("SVG Element :: SVG TextContent Element", function() {\r
1292     var s;\r
1293     beforeEach(function() {\r
1294       s = doc.createElementNS("http://www.w3.org/2000/svg", "text");\r
1295     });\r
1296     /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a SVGTextContentElement interface.)*/\r
1297     it("for the default value on the property of SVGTextContentElement", function() {\r
1298       expect(s.getAttributeNS(null, "textLength")).toBeNull();\r
1299       expect(s.getNumberOfChars()).toEqual(0);\r
1300     });\r
1301     /*境界条件を調べておく (limit value analysis)*/\r
1302     it("should be this for the value(limit value analysis)", function() {\r
1303       var t = [0,\r
1304                1,\r
1305                100],\r
1306           str = "";\r
1307       for (var i=0;i<t.length;++i) {\r
1308         /*文字列の生成 (created a string for the test)*/\r
1309         for (var j=0, ti=t[i];j<ti;++j) {\r
1310           str += "nん曖昧模糊@";\r
1311         }\r
1312         s.appendChild(s.ownerDocument.createTextNode(str));\r
1313         expect(s.getNumberOfChars()).toEqual(s.firstChild.length);\r
1314         s.removeChild(s.firstChild);\r
1315         s.appendChild(s.ownerDocument.createElementNS("http://sie.sourceforge.jp", "hoge"))\r
1316          .appendChild(s.ownerDocument.createTextNode(str));\r
1317         expect(s.getNumberOfChars()).toEqual(s.firstChild.firstChild.length);\r
1318         s.removeChild(s.firstChild);\r
1319         s.appendChild(s.ownerDocument.createElementNS("http://www.w3.org/svg/2000", "a"))\r
1320          .appendChild(s.ownerDocument.createElementNS("http://www.w3.org/svg/2000", "tspan"))\r
1321          .appendChild(s.ownerDocument.createTextNode(str));\r
1322         expect(s.getNumberOfChars()).toEqual(str.length);\r
1323         s.firstChild.appendChild(s.ownerDocument.createTextNode(str));\r
1324         expect(s.getNumberOfChars()).toEqual(str.length*2);\r
1325         s.removeChild(s.firstChild);\r
1326         str = "";\r
1327       }\r
1328     });\r
1329     it("a getStartPositionOfChar method", function() {\r
1330       expect(function(){\r
1331         s.getStartPositionOfChar(1);\r
1332       }).toThrow();\r
1333       var str = "hoge",\r
1334           doc = s.ownerDocument;\r
1335       doc.documentElement.appendChild(s);\r
1336       s.setAttributeNS(null, "font-size", "20");\r
1337       s.appendChild(doc.createTextNode(str));\r
1338       expect(s.getStartPositionOfChar(0).x).toEqual(0);\r
1339       expect(s.getStartPositionOfChar(1).x).toEqual(11);\r
1340 \r
1341       s.insertBefore(doc.createElementNS("http://www.w3.org/2000/svg", "a"), s.firstChild);\r
1342       s.firstChild.appendChild(doc.createTextNode(str));\r
1343       expect(s.getStartPositionOfChar(1).x).toEqual(11);\r
1344 \r
1345       /*a要素の前にテキストノードがない場合*/\r
1346       s.insertBefore(doc.createElementNS("http://www.w3.org/2000/svg", "a"), s.firstChild);\r
1347       var a = s.firstChild;\r
1348       a.appendChild(doc.createElementNS("http://www.w3.org/2000/svg", "tspan"));\r
1349       a.firstChild.appendChild(doc.createTextNode(str+str));\r
1350       expect(s.getStartPositionOfChar(1).x).toEqual(11);\r
1351       expect(s.getStartPositionOfChar(5).x).toEqual(55);\r
1352 \r
1353       /*a要素の前にテキストノードがある場合*/\r
1354       s.insertBefore(doc.createElementNS("http://www.w3.org/2000/svg", "a"), s.firstChild);\r
1355       var a = s.firstChild;\r
1356       a.appendChild(doc.createTextNode(str));\r
1357       a.appendChild(doc.createElementNS("http://www.w3.org/2000/svg", "tspan"));\r
1358       a.lastChild.appendChild(doc.createTextNode(str));\r
1359       expect(s.getStartPositionOfChar(1).x).toEqual(11);\r
1360       expect(s.getStartPositionOfChar(5).x).toEqual(55);\r
1361     });\r
1362   });\r
1363   describe("DOM level 2 Core :: Node", function() {\r
1364     var s, t;\r
1365     beforeEach(function() {\r
1366       s = doc.createElementNS("http://www.w3.org/2000/svg", "text");\r
1367       t = doc.createElementNS("http://sie.sourceforge.jp/", "hoge");\r
1368     });\r
1369     /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a Node interface.)*/\r
1370     it("for the default value on the property of Node", function() {\r
1371       expect(s.firstChild).toBeNull();\r
1372       expect(s.lastChild).toBeNull();\r
1373       expect(s.nextSibling).toBeNull();\r
1374       expect(s.previousSibling).toBeNull();\r
1375       expect(s.parentNode).toBeNull();\r
1376     });\r
1377     /*insertBeforeメソッドの境界条件を調べておく (limit value analysis, when it calls a insertBefore method)*/\r
1378     it("should be this for the value, when it calls a insertBefore method (limit value analysis)", function() {\r
1379       s.insertBefore(t, null);\r
1380       expect(s.firstChild).toEqual(t);\r
1381       expect(s.lastChild).toEqual(t);\r
1382       expect(s.childNodes.item(0)).toEqual(t);\r
1383       expect(s.nextSibling).toBeNull();\r
1384       expect(s.previousSibling).toBeNull();\r
1385       expect(s.parentNode).toBeNull();\r
1386       expect(t.parentNode).toEqual(s);\r
1387       expect(t.nextSibling).toBeNull();\r
1388       expect(t.previousSibling).toBeNull();\r
1389       expect(t.firstChild).toBeNull();\r
1390       expect(t.lastChild).toBeNull();\r
1391 \r
1392       var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
1393       s.insertBefore(u, null);\r
1394       s.insertBefore(t, u);\r
1395       expect(s.firstChild).toEqual(t);\r
1396       expect(s.lastChild).toEqual(u);\r
1397       expect(s.childNodes.item(0)).toEqual(t);\r
1398       expect(s.childNodes.item(1)).toEqual(u);\r
1399       expect(s.nextSibling).toBeNull();\r
1400       expect(s.previousSibling).toBeNull();\r
1401       expect(s.parentNode).toBeNull();\r
1402       expect(t.parentNode).toEqual(s);\r
1403       expect(t.nextSibling).toEqual(u);\r
1404       expect(t.previousSibling).toBeNull();\r
1405       expect(t.firstChild).toBeNull();\r
1406       expect(t.lastChild).toBeNull();\r
1407 \r
1408       u.insertBefore(t, null);\r
1409       expect(s.firstChild).toEqual(u);\r
1410       expect(s.lastChild).toEqual(u);\r
1411       expect(s.childNodes.item(0)).toEqual(u);\r
1412       expect(s.nextSibling).toBeNull();\r
1413       expect(s.previousSibling).toBeNull();\r
1414       expect(s.parentNode).toBeNull();\r
1415       expect(u.firstChild).toEqual(t);\r
1416       expect(u.lastChild).toEqual(t);\r
1417       expect(u.childNodes.item(0)).toEqual(t);\r
1418       expect(u.nextSibling).toBeNull();\r
1419       expect(u.previousSibling).toBeNull();\r
1420       expect(u.parentNode).toEqual(s);\r
1421       expect(t.parentNode).toEqual(u);\r
1422       expect(t.nextSibling).toBeNull();\r
1423       expect(t.previousSibling).toBeNull();\r
1424       expect(t.firstChild).toBeNull();\r
1425       expect(t.lastChild).toBeNull();\r
1426       u = void 0;\r
1427     });\r
1428     /*appendChildメソッドの境界条件を調べておく (limit value analysis, when it calls a appendChild method)*/\r
1429     it("should be this for the value, when it calls a appendChild method (limit value analysis)", function() {\r
1430       s.appendChild(t);\r
1431       expect(s.firstChild).toEqual(t);\r
1432       expect(s.lastChild).toEqual(t);\r
1433       expect(s.childNodes.item(0)).toEqual(t);\r
1434       expect(s.nextSibling).toBeNull();\r
1435       expect(s.previousSibling).toBeNull();\r
1436       expect(s.parentNode).toBeNull();\r
1437       expect(t.parentNode).toEqual(s);\r
1438       expect(t.nextSibling).toBeNull();\r
1439       expect(t.previousSibling).toBeNull();\r
1440       expect(t.firstChild).toBeNull();\r
1441       expect(t.lastChild).toBeNull();\r
1442     });\r
1443     /*removeChildメソッドの境界条件を調べておく (limit value analysis, when it calls a removeChild method)*/\r
1444     it("should be this for the value, when it calls a removeChild method (limit value analysis)", function() {\r
1445       s.insertBefore(t, null);\r
1446       s.removeChild(t);\r
1447       expect(s.firstChild).toBeNull();\r
1448       expect(s.lastChild).toBeNull();\r
1449       expect(s.childNodes.item(0)).toBeNull();\r
1450       expect(s.nextSibling).toBeNull();\r
1451       expect(s.previousSibling).toBeNull();\r
1452       expect(s.parentNode).toBeNull();\r
1453       expect(t.parentNode).toBeNull();\r
1454       expect(t.nextSibling).toBeNull();\r
1455       expect(t.previousSibling).toBeNull();\r
1456       expect(t.firstChild).toBeNull();\r
1457       expect(t.lastChild).toBeNull();\r
1458     });\r
1459     /*replaceChildメソッドの境界条件を調べておく (limit value analysis, when it calls a replaceChild method)*/\r
1460     it("should be this for the value, when it calls a replaceChild method (limit value analysis)", function() {\r
1461       var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
1462       s.insertBefore(t, null);\r
1463       s.replaceChild(u, t);\r
1464       expect(s.firstChild).toEqual(u);\r
1465       expect(s.lastChild).toEqual(u);\r
1466       expect(s.childNodes.item(0)).toEqual(u);\r
1467       expect(s.nextSibling).toBeNull();\r
1468       expect(s.previousSibling).toBeNull();\r
1469       expect(s.parentNode).toBeNull();\r
1470       expect(u.parentNode).toEqual(s);\r
1471       expect(u.nextSibling).toBeNull();\r
1472       expect(u.previousSibling).toBeNull();\r
1473       expect(u.firstChild).toBeNull();\r
1474       expect(u.lastChild).toBeNull();\r
1475       expect(t.parentNode).toBeNull();\r
1476       expect(t.nextSibling).toBeNull();\r
1477       expect(t.previousSibling).toBeNull();\r
1478       expect(t.firstChild).toBeNull();\r
1479       expect(t.lastChild).toBeNull();\r
1480     });\r
1481     /*hasChildNodesメソッドの境界条件を調べておく (limit value analysis, when it calls a hasChildNodes method)*/\r
1482     it("should be this for the value, when it calls a hasChildNodes method (limit value analysis)", function() {\r
1483       expect(s.hasChildNodes()).toEqual(false);\r
1484       s.appendChild(t);\r
1485       expect(s.hasChildNodes()).toEqual(true);\r
1486       s.removeChild(t);\r
1487       expect(s.hasChildNodes()).toEqual(false);\r
1488     });\r
1489     /*cloneNodeメソッドの境界条件を調べておく (limit value analysis, when it calls a cloneNode method)*/\r
1490     it("should be this for the value, when it calls a cloneNode method (limit value analysis)", function() {\r
1491       s.appendChild(t);\r
1492       var u = s.cloneNode(false),\r
1493           v = s.cloneNode(true);\r
1494       expect(u).toNotBe(s);\r
1495       expect(u.firstChild).toBeNull();\r
1496       expect(u.lastChild).toBeNull();\r
1497       expect(u.childNodes.item(0)).toBeNull();\r
1498       expect(u.nextSibling).toBeNull();\r
1499       expect(u.previousSibling).toBeNull();\r
1500       expect(u.parentNode).toBeNull();\r
1501       expect(v).toNotBe(s);\r
1502       expect(v.hasChildNodes()).toEqual(true);\r
1503       expect(v.firstChild.parentNode).toEqual(v);\r
1504       expect(v.lastChild.parentNode).toEqual(v);\r
1505       expect(v.childNodes.item(0).parentNode).toEqual(v);\r
1506       expect(v.nextSibling).toBeNull();\r
1507       expect(v.previousSibling).toBeNull();\r
1508       expect(v.parentNode).toBeNull();\r
1509     });\r
1510     /*normalizeメソッドの境界条件を調べておく (limit value analysis, when it calls a normalize method)*/\r
1511     it("should be this for the value, when it calls a normalize method (limit value analysis)", function() {\r
1512       var text, ttext,\r
1513           tle = [doc.createTextNode(""), doc.createTextNode("0"), doc.createTextNode("a")];\r
1514       s.normalize();\r
1515       expect(s.firstChild).toBeNull();\r
1516       expect(s.lastChild).toBeNull();\r
1517       s.appendChild(tle[0]);\r
1518       s.normalize();\r
1519       expect(s.firstChild).toNotBe(null);\r
1520       expect(s.lastChild).toNotBe(null);\r
1521       expect(s.firstChild.nodeValue).toEqual("");\r
1522       for (var i=0; i<tle.legnth-1; ++i) {\r
1523         text = tle[i],\r
1524         ttext = tle[i+1];\r
1525         s.appendChild(text);\r
1526         s.appendChild(ttext);\r
1527         expect(s.firstChild).toEqual(text);\r
1528         expect(s.lastChild).toEqual(ttext);\r
1529         s.norbalize();\r
1530         expect(s.firstChild.nodeValue).toEqual(text.nodeValue+ttext.nodeValue);\r
1531         expect(s.firstChild).toNotBe(text);\r
1532         expect(s.lastChild).toNotBe(ttext);\r
1533       }\r
1534     });\r
1535     /*hasAttributesメソッドの境界条件を調べておく (limit value analysis, when it calls a hasAttributes method)*/\r
1536     it("should be this for the value, when it calls a hasAttributes method (limit value analysis)", function() {\r
1537       expect(s.hasAttributes()).toEqual(false);\r
1538       s.setAttributeNS(null, "a", "b");\r
1539       expect(s.hasAttributes()).toEqual(true);\r
1540       expect(t.hasAttributes()).toEqual(false);\r
1541       t.setAttributeNS(null, "c", "d");\r
1542       expect(t.hasAttributes()).toEqual(true);\r
1543     });\r
1544 \r
1545     /*insertBeforeメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1546     it("should be this for the value, when it calls a insertBefore method (the valid partion)", function() {\r
1547       var ti = [10, 500, 1000];\r
1548       for (var i=0;i<ti.length;++i) {\r
1549         for (var j=0,tili=ti[i];j<tili;++j) {\r
1550           s.insertBefore(t, null);\r
1551         }\r
1552       }\r
1553       expect(s.firstChild).toEqual(t);\r
1554       expect(s.lastChild).toEqual(t);\r
1555       expect(s.childNodes.item(0)).toEqual(t);\r
1556       expect(s.nextSibling).toBeNull();\r
1557       expect(s.previousSibling).toBeNull();\r
1558       expect(s.parentNode).toBeNull();\r
1559       expect(t.parentNode).toEqual(s);\r
1560       expect(t.nextSibling).toBeNull();\r
1561       expect(t.previousSibling).toBeNull();\r
1562       expect(t.firstChild).toBeNull();\r
1563       expect(t.lastChild).toBeNull();\r
1564 \r
1565       var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
1566       s.insertBefore(u, null);\r
1567       for (var i=0;i<ti.length;++i) {\r
1568         for (var j=0,tili=ti[i];j<tili;++j) {\r
1569           s.insertBefore(t, u);\r
1570         }\r
1571       }\r
1572       expect(s.firstChild).toEqual(t);\r
1573       expect(s.lastChild).toEqual(u);\r
1574       expect(s.childNodes.item(0)).toEqual(t);\r
1575       expect(s.childNodes.item(1)).toEqual(u);\r
1576       expect(s.nextSibling).toBeNull();\r
1577       expect(s.previousSibling).toBeNull();\r
1578       expect(s.parentNode).toBeNull();\r
1579       expect(t.parentNode).toEqual(s);\r
1580       expect(t.nextSibling).toEqual(u);\r
1581       expect(t.previousSibling).toBeNull();\r
1582       expect(t.firstChild).toBeNull();\r
1583       expect(t.lastChild).toBeNull();\r
1584 \r
1585       for (var i=0;i<ti.length;++i) {\r
1586         for (var j=0,tili=ti[i];j<tili;++j) {\r
1587           u.insertBefore(t, null);\r
1588         }\r
1589       }\r
1590       expect(s.firstChild).toEqual(u);\r
1591       expect(s.lastChild).toEqual(u);\r
1592       expect(s.childNodes.item(0)).toEqual(u);\r
1593       expect(s.nextSibling).toBeNull();\r
1594       expect(s.previousSibling).toBeNull();\r
1595       expect(s.parentNode).toBeNull();\r
1596       expect(u.firstChild).toEqual(t);\r
1597       expect(u.lastChild).toEqual(t);\r
1598       expect(u.childNodes.item(0)).toEqual(t);\r
1599       expect(u.nextSibling).toBeNull();\r
1600       expect(u.previousSibling).toBeNull();\r
1601       expect(u.parentNode).toEqual(s);\r
1602       expect(t.parentNode).toEqual(u);\r
1603       expect(t.nextSibling).toBeNull();\r
1604       expect(t.previousSibling).toBeNull();\r
1605       expect(t.firstChild).toBeNull();\r
1606       expect(t.lastChild).toBeNull();\r
1607       u = void 0;\r
1608     });\r
1609     /*appendChildメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1610     it("should be this for the value, when it calls a appendChild method (the valid partion)", function() {\r
1611       var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
1612       s.appendChild(t);\r
1613       s.appendChild(u);\r
1614       expect(s.firstChild).toEqual(t);\r
1615       expect(s.lastChild).toEqual(u);\r
1616       expect(s.childNodes.item(0)).toEqual(t);\r
1617       expect(s.childNodes.item(1)).toEqual(u);\r
1618       expect(s.nextSibling).toBeNull();\r
1619       expect(s.previousSibling).toBeNull();\r
1620       expect(s.parentNode).toBeNull();\r
1621       expect(t.parentNode).toEqual(s);\r
1622       expect(t.nextSibling).toEqual(u);\r
1623       expect(t.previousSibling).toBeNull();\r
1624       expect(t.firstChild).toBeNull();\r
1625       expect(t.lastChild).toBeNull();\r
1626       expect(u.parentNode).toEqual(s);\r
1627       expect(u.nextSibling).toBeNull();\r
1628       expect(u.previousSibling).toEqual(t);\r
1629       expect(u.firstChild).toBeNull();\r
1630       expect(u.lastChild).toBeNull();\r
1631       u = void 0;\r
1632     });\r
1633     /*removeChildメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1634     it("should be this for the value, when it calls a removeChild method (the valid partion)", function() {\r
1635       s.insertBefore(t, null);\r
1636       s.removeChild(t);\r
1637       var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
1638       s.appendChild(u);\r
1639       s.removeChild(u);\r
1640       expect(s.firstChild).toBeNull();\r
1641       expect(s.lastChild).toBeNull();\r
1642       expect(s.childNodes.item(0)).toBeNull();\r
1643       expect(s.nextSibling).toBeNull();\r
1644       expect(s.previousSibling).toBeNull();\r
1645       expect(s.parentNode).toBeNull();\r
1646       expect(t.parentNode).toBeNull();\r
1647       expect(t.nextSibling).toBeNull();\r
1648       expect(t.previousSibling).toBeNull();\r
1649       expect(t.firstChild).toBeNull();\r
1650       expect(t.lastChild).toBeNull();\r
1651       for (var i=0;i<50;++i) {\r
1652         s.appendChild(u);\r
1653         s.removeChild(u);\r
1654       }\r
1655       expect(s.firstChild).toBeNull();\r
1656       expect(s.lastChild).toBeNull();\r
1657       expect(s.childNodes.item(0)).toBeNull();\r
1658       expect(s.nextSibling).toBeNull();\r
1659       expect(s.previousSibling).toBeNull();\r
1660       expect(s.parentNode).toBeNull();\r
1661       expect(t.parentNode).toBeNull();\r
1662       expect(t.nextSibling).toBeNull();\r
1663       expect(t.previousSibling).toBeNull();\r
1664       expect(t.firstChild).toBeNull();\r
1665       expect(t.lastChild).toBeNull();\r
1666       u = void 0;\r
1667     });\r
1668     /*replaceChildメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1669     it("should be this for the value, when it calls a replaceChild method (the valid partion)", function() {\r
1670       var u = doc.createElementNS("http://sie.sourceforge.jp/", "ho");\r
1671       s.insertBefore(t, null);\r
1672       s.replaceChild(u, t);\r
1673       s.replaceChild(t, u);\r
1674       s.replaceChild(u, t);\r
1675       expect(s.firstChild).toEqual(u);\r
1676       expect(s.lastChild).toEqual(u);\r
1677       expect(s.childNodes.item(0)).toEqual(u);\r
1678       expect(s.nextSibling).toBeNull();\r
1679       expect(s.previousSibling).toBeNull();\r
1680       expect(s.parentNode).toBeNull();\r
1681       expect(u.parentNode).toEqual(s);\r
1682       expect(u.nextSibling).toBeNull();\r
1683       expect(u.previousSibling).toBeNull();\r
1684       expect(u.firstChild).toBeNull();\r
1685       expect(u.lastChild).toBeNull();\r
1686       expect(t.parentNode).toBeNull();\r
1687       expect(t.nextSibling).toBeNull();\r
1688       expect(t.previousSibling).toBeNull();\r
1689       expect(t.firstChild).toBeNull();\r
1690       expect(t.lastChild).toBeNull();\r
1691     });\r
1692     /*hasChildNodesメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1693     it("should be this for the value, when it calls a hasChildNodes method (the valid partion)", function() {\r
1694       for (var i=0;i<10;++i) {\r
1695         s.appendChild(t);\r
1696         expect(s.hasChildNodes()).toEqual(true);\r
1697         s.appendChild(t);\r
1698         expect(s.hasChildNodes()).toEqual(true);\r
1699         s.removeChild(t);\r
1700         expect(s.hasChildNodes()).toEqual(false);\r
1701       }\r
1702     });\r
1703     /*cloneNodeメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1704     it("should be this for the value, when it calls a cloneNode method (the valid partion)", function() {\r
1705       s.appendChild(t);\r
1706       var u = s.cloneNode(false),\r
1707           v = s.cloneNode(true);\r
1708       for (var i=0;i<10;++i) {\r
1709         u = u.cloneNode(false);\r
1710         v = v.cloneNode(true);\r
1711       }\r
1712       expect(u).toNotBe(s);\r
1713       expect(u.firstChild).toBeNull();\r
1714       expect(u.lastChild).toBeNull();\r
1715       expect(u.childNodes.item(0)).toBeNull();\r
1716       expect(u.nextSibling).toBeNull();\r
1717       expect(u.previousSibling).toBeNull();\r
1718       expect(u.parentNode).toBeNull();\r
1719       expect(v).toNotBe(s);\r
1720       expect(v.hasChildNodes()).toEqual(true);\r
1721       expect(v.firstChild.parentNode).toEqual(v);\r
1722       expect(v.lastChild.parentNode).toEqual(v);\r
1723       expect(v.childNodes.item(0).parentNode).toEqual(v);\r
1724       expect(v.nextSibling).toBeNull();\r
1725       expect(v.previousSibling).toBeNull();\r
1726       expect(v.parentNode).toBeNull();\r
1727     });\r
1728     /*hasAttributesメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1729     it("should be this for the value, when it calls a hasAttributes method (the valid partion)", function() {\r
1730       s.setAttributeNS(null, "a", "b");\r
1731       s.setAttributeNS(null, "c", "b");\r
1732       expect(s.hasAttributes()).toEqual(true);\r
1733     });\r
1734 \r
1735     /*insertBeforeメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1736     it("should be this for the value, when it calls a insertBefore method (the invalid partion)", function() {\r
1737       var sn = function() {\r
1738           s.insertBefore(t, null);\r
1739           /*HIERARCHY_REQUEST_ERR DOMException */\r
1740           t.insertBefore(s, null);\r
1741         },\r
1742         tn = function() {\r
1743           /*WRONG_DOCUMENT_ERR DOMException*/\r
1744           s.insertBefore(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"), null);\r
1745         },\r
1746         un = function() {\r
1747           /*NOT_FOUND_ERR DOMException*/\r
1748           s.insertBefore(t, t.cloneNode(false));\r
1749         };\r
1750       expect(sn).toThrow();\r
1751       expect(tn).toThrow();\r
1752       expect(un).toThrow();\r
1753     });\r
1754     /*appendChildメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1755     it("should be this for the value, when it calls a appendChild method (the invalid partion)", function() {\r
1756       var sn = function() {\r
1757         s.appendChild(t);\r
1758         /*HIERARCHY_REQUEST_ERR DOMException */\r
1759         t.appendChild(s);\r
1760       },\r
1761       tn = function() {\r
1762         /*WRONG_DOCUMENT_ERR DOMException*/\r
1763         s.appendChild(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"));\r
1764       };\r
1765       expect(sn).toThrow();\r
1766       expect(tn).toThrow();\r
1767     });\r
1768     /*removeChildメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1769     it("should be this for the value, when it calls a removeChild method (the invalid partion)", function() {\r
1770       var sn = function() {\r
1771         s.removeChild(s.cloneNode(false));\r
1772       },\r
1773       tn = function() {\r
1774         /*NOT_FOUND_ERR DOMException*/\r
1775         s.removeChild(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"));\r
1776       };\r
1777       expect(sn).toThrow();\r
1778       expect(tn).toThrow();\r
1779     });\r
1780     /*replaceChildメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1781     it("should be this for the value, when it calls a replaceChild method (the invalid partion)", function() {\r
1782       s.appendChild(t);\r
1783       t.appendChild(t.cloneNode(false));\r
1784       var sn = function() {\r
1785         /*HIERARCHY_REQUEST_ERR DOMException */\r
1786         t.replaceChild(s, t.firstChild);\r
1787       },\r
1788       tn = function() {\r
1789         /*WRONG_DOCUMENT_ERR DOMException*/\r
1790         s.replaceChild(DOMImplementation.createDocument("svg", "svg").createElementNS("o","n"), s.firstChild);\r
1791       },\r
1792       un = function() {\r
1793         /*NOT_FOUND_ERR DOMException*/\r
1794         s.replaceChild(t, t.cloneNode(false));\r
1795       };\r
1796       expect(sn).toThrow();\r
1797       expect(tn).toThrow();\r
1798       expect(un).toThrow();\r
1799     });\r
1800   });\r
1801   describe("DOM level 2 Core :: Document", function() {\r
1802     /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a Document interface.)*/\r
1803     it("for the default value on the property of Document", function() {\r
1804       expect(doc.doctype).toBeNull();\r
1805       expect(doc.nodeName).toEqual("#document");\r
1806       expect(doc.nodeValue).toBeNull();\r
1807       expect(doc.attributes).toBeNull();\r
1808       expect(svg.ownerDocument).toEqual(doc);\r
1809       expect(svg.nodeName).toEqual("svg");\r
1810       expect(svg.namespaceURI).toEqual("http://www.w3.org/2000/svg");\r
1811     });\r
1812     /*getElementByIdメソッドの境界条件を調べておく (limit value analysis, when it calls a getElementById method)*/\r
1813     it("should be this for the value, when it calls a getElementById method (limit value analysis)", function() {\r
1814       expect(doc.getElementById("a")).toBeNull();\r
1815       svg.setAttributeNS(null, "id", "a");\r
1816       expect(doc.getElementById("a")).toEqual(svg);\r
1817       svg.setAttributeNS(null, "id", "x");\r
1818       expect(doc.getElementById("x")).toEqual(svg);\r
1819       expect(doc.getElementById("a")).toBeNull();\r
1820       expect(doc.getElementById("")).toBeNull();\r
1821     });\r
1822     /*getElementsByTagNameメソッドの境界条件を調べておく (limit value analysis, when it calls a getElementsByTagName method)*/\r
1823     it("should be this for the value, when it calls a getElementsByTagName method (limit value analysis)", function() {\r
1824       expect(doc.getElementsByTagName("a")).toBeNull();\r
1825     });\r
1826     /*getElementsByTagNameNSメソッドの境界条件を調べておく (limit value analysis, when it calls a getElementsByTagNameNS method)*/\r
1827     it("should be this for the value, when it calls a getElementsByTagNameNS method (limit value analysis)", function() {\r
1828       var svgns = "http://www.w3.org/2000/svg",\r
1829           ele = doc.createElementNS(svgns, "a");\r
1830       expect(doc.getElementsByTagNameNS(svgns, "a")).toBeNull();\r
1831       expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "a")).toBeNull();\r
1832       expect(doc.getElementsByTagNameNS("*", "a")).toBeNull();\r
1833       expect(doc.getElementsByTagNameNS("*", "*").item(0)).toEqual(svg);\r
1834       expect(doc.getElementsByTagNameNS(svgns, "svg").item(0)).toEqual(svg);\r
1835       expect(doc.getElementsByTagNameNS(svgns, "b")).toBeNull();\r
1836       expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "b")).toBeNull();\r
1837       expect(doc.getElementsByTagNameNS("*", "b")).toBeNull();\r
1838       expect(doc.getElementsByTagNameNS("*", "b")).toBeNull();\r
1839       svg.appendChild(ele);\r
1840       expect(doc.getElementsByTagNameNS(svgns, "a").item(0)).toEqual(ele);\r
1841       expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "a")).toBeNull();\r
1842       expect(doc.getElementsByTagNameNS("*", "a").item(0)).toEqual(ele);\r
1843       expect(doc.getElementsByTagNameNS(svgns, "b")).toBeNull();\r
1844       expect(doc.getElementsByTagNameNS("http://www.d.hatena.jp/dhrname", "b")).toBeNull();\r
1845       expect(doc.getElementsByTagNameNS("*", "b")).toBeNull();\r
1846       expect(doc.getElementsByTagNameNS("*", "b")).toBeNull();\r
1847 \r
1848       expect(doc.getElementsByTagNameNS("", "a")).toBeNull();\r
1849       expect(doc.getElementsByTagNameNS(svgns, "")).toBeNull();\r
1850       svgns = ele = void 0;\r
1851     });\r
1852     /*importNodeメソッドの境界条件を調べておく (limit value analysis, when it calls a importNode method)*/\r
1853     it("should be this for the value, when it calls a importNode method (limit value analysis)", function() {      var ele = doc.createElementNS("http://www.w3.org/2000/svg", "a");\r
1854       var ele = doc.createElementNS("http://www.w3.org/2000/svg", "a"),\r
1855           cdoc = doc.implementation.createDocument("http://", "a"),\r
1856           cele = cdoc.importNode(doc.documentElement);\r
1857       expect(cele.nodeName).toEqual("svg");\r
1858       expect(cele.namespaceURI).toEqual("http://www.w3.org/2000/svg");\r
1859       expect(cele.ownerDocument).toEqual(cdoc);\r
1860       expect(cele.firstChild).toBeNull();\r
1861       doc.documentElement.appendChild(ele);\r
1862       expect(cele.firstChild).toBeNull();\r
1863 \r
1864       ele = cdoc.importNode(doc.documentElement.firstChild);\r
1865       expect(ele.nodeName).toEqual("a");\r
1866       expect(ele.namespaceURI).toEqual("http://www.w3.org/2000/svg");\r
1867       expect(ele.ownerDocument).toEqual(cdoc);\r
1868       cdoc.documentElement.appendChild(ele);\r
1869       expect(cdoc.documentElement.firstChild).toEqual(ele);\r
1870    });\r
1871     /*getElementByIdメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1872     it("should be this for the value, when it calls a getElementById method (the valid partion)", function() {\r
1873       expect(doc.getElementById("ax")).toBeNull();\r
1874       expect(doc.getElementById("hoge-hoge")).toBeNull();\r
1875       expect(doc.getElementById("a102930")).toBeNull();\r
1876       svg.setAttributeNS(null, "id", "ax");\r
1877       expect(doc.getElementById("ax")).toEqual(svg);\r
1878       svg.setAttributeNS(null, "id", "hoge-hoge");\r
1879       expect(doc.getElementById("hoge-hoge")).toEqual(svg);\r
1880       svg.setAttributeNS(null, "id", "a102930");\r
1881       expect(doc.getElementById("a102930")).toEqual(svg);\r
1882     });\r
1883     /*getElementsByTagNameNSメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1884     it("should be this for the value, when it calls a getElementsByTagNameNS method (the valid partion)", function() {\r
1885       var svgns = "http://www.w3.org/2000/svg",\r
1886           ele = doc.createElementNS(svgns, "a"),\r
1887           a;\r
1888       for (var i=0;i<10;++i) {\r
1889         doc.documentElement.appendChild(ele.cloneNode(true));\r
1890       }\r
1891       a = doc.getElementsByTagNameNS(svgns, "a");\r
1892       expect(a.length).toEqual(10);\r
1893       for (var i=0;i<10;++i) {\r
1894         expect(a.item(i).nodeName).toBe("a");\r
1895         expect(a.item(i).namespaceURI).toBe(svgns);\r
1896       }\r
1897       /*深い階層の要素を作っておく*/\r
1898       a = a[0];\r
1899       for (var i=0;i<10;++i) {\r
1900         a.appendChild(ele.cloneNode(true));\r
1901         a = a.firstChild;\r
1902       }\r
1903       a = doc.getElementsByTagNameNS(svgns, "a");\r
1904       expect(a.length).toEqual(20);\r
1905       for (var i=0;i<20;++i) {\r
1906         expect(a.item(i).nodeName).toBe("a");\r
1907         expect(a.item(i).namespaceURI).toBe(svgns);\r
1908       }\r
1909       ele = doc.createElementNS("http:://www", "st");\r
1910       ele.appendChild(doc.documentElement.lastChild);\r
1911       doc.documentElement.appendChild(ele);\r
1912       a = doc.getElementsByTagNameNS(svgns, "a");\r
1913       expect(a.length).toEqual(20);\r
1914       for (var i=0;i<20;++i) {\r
1915         expect(a.item(i).nodeName).toBe("a");\r
1916         expect(a.item(i).namespaceURI).toBe(svgns);\r
1917       }\r
1918     });\r
1919     /*importNodeメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
1920     it("should be this for the value, when it calls a importNode method (the valid partion)", function() {\r
1921       var ele = doc.createElementNS("http://www.w3.org/2000/svg", "a"),\r
1922           cdoc = doc.implementation.createDocument("http://", "a"),\r
1923           c = cdoc.importNode(ele);\r
1924       ele.appendChild(doc.createTextNode("abc"));\r
1925       ele.appendChild(doc.createElementNS("http://", "x:ab"));\r
1926       expect(c.firstChild).toBeNull();\r
1927       expect(c.lastChild).toBeNull();\r
1928 \r
1929       c = cdoc.importNode(ele, true);\r
1930       expect(c.firstChild.data).toBe("abc");\r
1931       expect(c.lastChild.namespaceURI).toBe("http://");\r
1932       expect(c.lastChild.localName).toBe("ab");\r
1933       expect(c.firstChild).not.toBe(ele.firstChild);\r
1934       expect(c.lastChild).not.toBe(ele.lastChild);\r
1935 \r
1936       c = cdoc.importNode(ele, false);\r
1937       expect(c.firstChild).toBeNull();\r
1938       expect(c.lastChild).toBeNull();\r
1939 \r
1940       ele.appendChild(doc.createTextNode("abc"));\r
1941       expect(c.firstChild).toBeNull();\r
1942       expect(c.lastChild).toBeNull();\r
1943 \r
1944       var ds = doc.createElementNS("http://oo", "t:abc");\r
1945       ds.appendChild(doc.createTextNode("def"));\r
1946       ele.appendChild(ds);\r
1947       c = cdoc.importNode(ele, true);\r
1948       expect(c.lastChild.firstChild.data).toBe("def");\r
1949       expect(c.lastChild.namespaceURI).toBe("http://oo");\r
1950       expect(c.lastChild.localName).toBe("abc");\r
1951       expect(c.firstChild).not.toBe(ele.firstChild);\r
1952       expect(c.lastChild).not.toBe(ele.lastChild);\r
1953     });\r
1954     /*getElementByIdメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1955     it("should be this for the value, when it calls a getElementById method (the invalid partion)", function() {\r
1956       var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], undefined, null, 0, -1, 11, 1.1, 10.1];\r
1957       for (var i=0;i<t.length;++i) {\r
1958         var ti = t[i];\r
1959         expect(doc.getElementById(ti)).toBeNull();\r
1960       }\r
1961     });\r
1962     /*getElementsByTagNameNSメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1963     it("should be this for the value, when it calls a getElementsByTagNameNS method (the invalid partion)", function() {\r
1964       var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], undefined, null, 0, -1, 11, 1.1, 10.1];\r
1965       for (var i=0;i<t.length;++i) {\r
1966         var ti = t[i];\r
1967         expect(function(){\r
1968           doc.getElementsByTagNameNS(ti, ti);\r
1969         }).toThrow();\r
1970       }\r
1971     });\r
1972     /*importNodeメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
1973     it("should be this for the value, when it calls a importNode method (the invalid partion)", function() {\r
1974     });\r
1975   });\r
1976   describe("DOM level 2 Core :: Element", function() {\r
1977     var s, t;\r
1978     beforeEach(function() {\r
1979       s = doc.createElementNS("http://www.w3.org/2000/svg", "text");\r
1980       t = doc.createElementNS("http://sie.sourceforge.jp/", "hoge");\r
1981     });\r
1982     /*まずは、あるべきデフォルト値かどうかをチェックしていく(Checking the default value of a Node interface.)*/\r
1983     it("for the default value on the property of Element", function() {\r
1984       expect(s.nodeType).toEqual( /*Node.ELEMENT_NODE*/ 1);\r
1985       expect(s.nodeValue).toBeNull();\r
1986       expect(t.nodeType).toEqual( /*Node.ELEMENT_NODE*/ 1);\r
1987       expect(t.nodeValue).toBeNull();\r
1988       expect(s.attributes.length).toEqual(0);\r
1989     });\r
1990 \r
1991     /*setAttributeNodeNSメソッドの境界条件を調べておく (limit value analysis, when it calls a setAttributeNodeNS method)*/\r
1992     it("should be this for the value, when it calls a setAttributeNodeNS method (limit value analysis)", function() {\r
1993       expect(function() {\r
1994         s.setAttributeNodeNS();\r
1995       }).toThrow();\r
1996       var attr = s.ownerDocument.createAttributeNS(null, "h"),\r
1997           sat = s.attributes;\r
1998       s.setAttributeNodeNS(attr);\r
1999       expect(sat.length).toEqual(1);\r
2000       expect(sat.getNamedItemNS(null, "h")).toBe(attr);\r
2001       /*同じことを繰り返して試行処理*/\r
2002       s.setAttributeNodeNS(attr);\r
2003       expect(sat.length).toEqual(1);\r
2004       expect(sat.getNamedItemNS(null, "h")).toBe(attr);\r
2005       attr = s.ownerDocument.createAttributeNS("urn:wo", "h");\r
2006       s.setAttributeNodeNS(attr);\r
2007       expect(sat.length).toEqual(2);\r
2008       expect(sat.getNamedItemNS("urn:", "h")).toBeNull();\r
2009     });\r
2010     /*setAttributeNodeNSメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2011     it("should be this for the value, when it calls a setAttributeNodeNS method (the valid partion)", function() {\r
2012       for (var i=0;i<10;++i) {\r
2013         var attr = s.ownerDocument.createAttributeNS(null, "h"),\r
2014             sat = s.attributes;\r
2015         s.setAttributeNodeNS(attr);\r
2016       }\r
2017       expect(sat.length).toEqual(1);\r
2018       expect(sat.getNamedItemNS(null, "h")).toBe(attr);\r
2019       for (var i=0;i<10;++i) {\r
2020         attr = s.ownerDocument.createAttributeNS("urn:" +i+ "o", "h");\r
2021         s.setAttributeNodeNS(attr);\r
2022       }\r
2023       expect(sat.length).toEqual(11);\r
2024       expect(sat.getNamedItemNS("urn:9o", "h")).toBe(attr);\r
2025 \r
2026       attr = s.ownerDocument.createAttributeNS("urn:wo", "0");\r
2027       s.setAttributeNodeNS(attr);\r
2028       expect(sat.getNamedItemNS("urn:wo", "0")).toBe(attr);\r
2029     });\r
2030     /*setAttributeNodeNSメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2031     it("should be this for the value, when it calls a setAttributeNodeNS method (the invalid partion)", function() {\r
2032       var attr = s.ownerDocument.createAttributeNS(null, "h"),\r
2033           sat = s.attributes;\r
2034       s.setAttributeNodeNS(attr);\r
2035       expect(function() {\r
2036         /*すでに使われている属性ノードを別の要素に移した場合はエラー*/\r
2037         t.setAttrributeNodeNS(attr);\r
2038       }).toThrow();\r
2039 \r
2040       attr = s.ownerDocument.implementation\r
2041               .createDocument("http://www.w3.org/svg/2000", "svg")\r
2042               .createAttributeNS("urn:", "h");\r
2043       expect(function() {\r
2044         /*別の文書ノードに属する属性ノードを設定した場合はエラー*/\r
2045         t.setAttrributeNodeNS(attr);\r
2046       }).toThrow();\r
2047     });\r
2048   });\r
2049 });\r
2050 describe("SMIL Animation Spec", function() {\r
2051   describe("$frame object", function() {\r
2052     var frame = base("$frame");\r
2053       beforeEach( function() {\r
2054         frame.timelines = [];\r
2055     } );\r
2056     /*境界条件を調べておく (limit value analysis)*/\r
2057     it("should be this for the value  (limit value analysis)", function() {\r
2058       expect(typeof frame.setFrame).toBe("function");\r
2059       expect(frame.timelines.length).toBe(0);\r
2060       expect(frame.startTime).toBeGreaterThan(-1);\r
2061       expect(frame.rank).toBe(0);\r
2062       frame.setFrame();\r
2063       frame.setFrame(0);\r
2064       /*負の値も許される*/\r
2065       frame.setFrame(-1);\r
2066       \r
2067       expect(frame.addLine()).toBe(false);\r
2068       expect(frame.addLine({})).toBe(false);\r
2069       expect(frame.addLine({\r
2070         begin: 0\r
2071       })).toBe(false);\r
2072       expect(frame.addLine({\r
2073         activeTime: 1\r
2074       })).toBe(false);\r
2075       \r
2076       expect(frame.removeLine()).toBeUndefined();\r
2077       expect(frame.removeLine({})).toBeUndefined();\r
2078       \r
2079       frame.setFrame(0);\r
2080       expect(frame.currentFrame).toEqual(0);\r
2081       frame.setFrame(1);\r
2082       expect(frame.currentFrame).toEqual(1);\r
2083     });\r
2084     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2085     it("should be this for the value (the valid partion)", function() {\r
2086       frame.setFrame(0);\r
2087       expect(frame.currentFrame).toBe(0);\r
2088       frame.startTime = Date.now();\r
2089       for (var i=0;i<100000;i++) {\r
2090         /*負荷をかけて、時間を進める*/\r
2091         1;\r
2092       }\r
2093       expect(frame.begin).toEqual(0);\r
2094       expect(frame.activeTime).toEqual(Number.MAX_VALUE);\r
2095       frame.begin = 10;\r
2096       frame.setFrame(0);\r
2097       frame.begin = -10;\r
2098       frame.setFrame(0);\r
2099 \r
2100       expect(frame.addLine( {\r
2101         begin: 0,\r
2102         activeTime: 0\r
2103       })).toBe(true);\r
2104       expect(frame.addLine( {\r
2105         begin: null,\r
2106         activeTime: null\r
2107       })).toBe(false);\r
2108       expect(frame.addLine( {\r
2109         begin: 0,\r
2110         activeTime: null\r
2111       })).toBe(false);\r
2112       expect(frame.addLine( {\r
2113         begin: null,\r
2114         activeTime: 0\r
2115       })).toBe(false);\r
2116       \r
2117       expect(frame.timelines.length).toEqual(1);\r
2118       var timeline = frame.timelines[0];\r
2119       expect(timeline.begin).toBe(0);\r
2120       expect(timeline.activeTime).toBe(0);\r
2121       /*timelineの再追加*/\r
2122       expect(frame.timelines[0]).toBe(timeline);\r
2123       frame.addLine({begin:1, activeTime:1});\r
2124       expect(frame.timelines[1]).not.toBe(timeline);\r
2125       frame.addLine(timeline);\r
2126       expect(frame.timelines[0]).not.toBe(timeline);\r
2127       expect(frame.timelines[1]).toBe(timeline);\r
2128 \r
2129       timeline = frame.timelines[0];\r
2130       frame.removeLine({});\r
2131       expect(frame.timelines[0]).toBe(timeline);\r
2132       frame.removeLine(timeline);\r
2133       expect(frame.timelines[0]).not.toBe(timeline);\r
2134       \r
2135       frame.addLine(frame.up().mix( {\r
2136         timelines: [] \r
2137         } ));\r
2138       expect(frame.timelines).not.toBe(frame.$1.timelines);\r
2139       \r
2140       frame.timelines.length = 0;\r
2141       frame.addLine( {\r
2142         begin: 1,\r
2143         activeTime: 1,\r
2144         rank:2\r
2145       } );\r
2146       frame.addLine( {\r
2147         begin: 1,\r
2148         activeTime: 1,\r
2149         rank:1\r
2150       } );\r
2151       expect(frame.timelines[0].rank).toBe(1);\r
2152       expect(frame.timelines[1].rank).toBe(2);\r
2153     });\r
2154     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2155     it("should be this for the value (the invalid partion)", function() {\r
2156       expect(frame.addLine(12)).toBe(false);\r
2157     });\r
2158   } );\r
2159   \r
2160   describe("$begin object", function() {\r
2161     var begin = base("$frame").$begin;\r
2162     /*境界条件を調べておく (limit value analysis)*/\r
2163     it("should be this for the value  (limit value analysis)", function() {\r
2164       expect(begin.string).toBe("");\r
2165       expect(begin.isResolved).toBeFalsy();\r
2166       expect(begin.eventTarget).toBe(document.documentElement);\r
2167       expect(typeof begin.listener).toBe("function");\r
2168       expect(begin.eventOffset).toBe(0);\r
2169     } );\r
2170     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2171     it("should be this for the value (the valid partion)", function() {\r
2172       begin.string = " hoge ";\r
2173       expect(begin.string).toBe(" hoge ");\r
2174     } );\r
2175     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2176     it("should be this for the value (the invalid partion)", function() {\r
2177     } );\r
2178     \r
2179     describe("A trim method in $begin object", function() {\r
2180       /*境界条件を調べておく (limit value analysis)*/\r
2181       beforeEach( function() {\r
2182         begin.string = "";\r
2183       } );\r
2184       it("should be this for the value  (limit value analysis)", function() {\r
2185         delete begin.string;\r
2186         expect(begin.trim(" ")).toBe("");\r
2187         expect( function() {\r
2188           begin.trim();\r
2189         } ).toThrow();\r
2190       } );\r
2191       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2192       it("should be this for the value (the valid partion)", function() {\r
2193         expect(begin.trim(" hoge ")).toBe("hoge");\r
2194         expect(begin.trim(" h o g e ")).toBe("hoge");\r
2195         expect(begin.trim(" h  o  g     e ")).toBe("hoge");\r
2196         expect(begin.trim("   h  o  g    12 +  e   ")).toBe("hog12+e");\r
2197       } );\r
2198       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2199       it("should be this for the value (the invalid partion)", function() {\r
2200         expect( function() {\r
2201           begin.trim(1);\r
2202         } ).toThrow();\r
2203         expect( function() {\r
2204           begin.trim({});\r
2205         } ).toThrow();\r
2206       } );\r
2207     } );\r
2208 \r
2209     describe("An offset method in $begin object", function() {\r
2210       beforeEach( function() {\r
2211         begin.string = "";\r
2212       } );\r
2213       /*境界条件を調べておく (limit value analysis)*/\r
2214       it("should be this for the value  (limit value analysis)", function() {\r
2215         expect(begin.offset(begin.trim(" "))).toEqual(0);\r
2216         expect(begin.offset(begin.trim(" 0 "))).toEqual(0);\r
2217         expect(begin.offset(begin.trim("+0ms"))).toEqual(0);\r
2218         expect(begin.offset(begin.trim("-0ms"))).toEqual(0);\r
2219         expect(begin.offset(begin.trim("1ms"))).toEqual(1);\r
2220         expect(begin.offset(begin.trim("-1ms"))).toEqual(-1);\r
2221 \r
2222         expect(begin.offset("+0s")).toEqual(0);\r
2223         expect(begin.offset("-0s")).toEqual(0);\r
2224         expect(begin.offset("1s")).toEqual(1000);\r
2225         expect(begin.offset("-1s")).toEqual(-1000);\r
2226 \r
2227         expect(begin.offset("+0min")).toEqual(0);\r
2228         expect(begin.offset("-0min")).toEqual(0);\r
2229         expect(begin.offset("1min")).toEqual(60000);\r
2230         expect(begin.offset("-1min")).toEqual(-60000);\r
2231 \r
2232         expect(begin.offset("+0h")).toEqual(0);\r
2233         expect(begin.offset("-0h")).toEqual(0);\r
2234         expect(begin.offset("1h")).toEqual(60*60*1000);\r
2235         expect(begin.offset("-1h")).toEqual(-3600000);\r
2236 \r
2237         expect(begin.offset("00:0")).toEqual(0);\r
2238         expect(begin.offset("00:00:0.0")).toEqual(0);\r
2239         expect(begin.offset("-00:0")).toEqual(0);\r
2240         expect(begin.offset("-00:00:0.0")).toEqual(0);\r
2241         expect(begin.offset("00:1")).toEqual(1000);\r
2242         expect(begin.offset("-00:1")).toEqual(-1000);\r
2243         expect(begin.offset("00:00:1")).toEqual(1000);\r
2244         expect(begin.offset("-00:00:1")).toEqual(-1000);\r
2245 \r
2246         expect(begin.offset()).toEqual(0);\r
2247       } );\r
2248       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2249       it("should be this for the value (the valid partion)", function() {\r
2250         expect(begin.offset(begin.trim(" + 0 ms"))).toEqual(0);\r
2251         expect(begin.offset(begin.trim(" -1m s "))).toEqual(-1);\r
2252         expect(begin.offset(begin.trim("1000ms"))).toEqual(1000);\r
2253         expect(begin.offset(begin.trim(" -1212ms"))).toEqual(-1212);\r
2254 \r
2255         expect(begin.offset("+100s")).toEqual(100 * 1000);\r
2256         expect(begin.offset("-121s")).toEqual(-121 * 1000);\r
2257         expect(begin.offset("1.25s")).toEqual(1.25 * 1000);\r
2258         expect(begin.offset("-0.20s")).toEqual(-0.20 * 1000);\r
2259         expect(begin.offset(".20s")).toEqual(0.20 * 1000);\r
2260 \r
2261         expect(begin.offset("+100min")).toEqual(100 * 60000);\r
2262         expect(begin.offset("-121min")).toEqual(-121 * 60000);\r
2263         expect(begin.offset("1.25min")).toEqual(1.25 * 60000);\r
2264         expect(begin.offset("-0.20min")).toEqual(-0.20 * 60000);\r
2265         expect(begin.offset(".20min")).toEqual(0.20 * 60000);\r
2266 \r
2267         expect(begin.offset("+100h")).toEqual(100 * 3600000);\r
2268         expect(begin.offset("-121h")).toEqual(-121 * 3600000);\r
2269         expect(begin.offset("1.25h")).toEqual(1.25 * 3600000);\r
2270         expect(begin.offset("-0.20h")).toEqual(-0.20 * 3600000);\r
2271         expect(begin.offset(".20h")).toEqual(0.20 * 3600000);\r
2272 \r
2273         expect(begin.offset("01:0")).toEqual(60000);\r
2274         expect(begin.offset("-01:0")).toEqual(-60000);\r
2275         expect(begin.offset("00:00:1")).toEqual(1000);\r
2276         expect(begin.offset("-00:00:1")).toEqual(-1000);\r
2277         expect(begin.offset("00:01:0")).toEqual(60000);\r
2278         expect(begin.offset("-00:01:0")).toEqual(-60000);\r
2279         expect(begin.offset("01:00:0")).toEqual(3600000);\r
2280         expect(begin.offset("-01:00:0")).toEqual(-3600000);\r
2281         expect(begin.offset("00:10")).toEqual(10000);\r
2282         expect(begin.offset("00:0.01")).toEqual(10);\r
2283         expect(begin.offset("01:0.01")).toEqual(60010);\r
2284         expect(begin.offset("10:0")).toEqual(600000);\r
2285         expect(begin.offset("-00:10")).toEqual(-10000);\r
2286         expect(begin.offset("-00:0.01")).toEqual(-10);\r
2287         expect(begin.offset("-01:0.01")).toEqual(-60010);\r
2288         expect(begin.offset("-10:0")).toEqual(-600000);\r
2289         expect(begin.offset("00:00:20")).toEqual(20000);\r
2290         expect(begin.offset("00:11:20")).toEqual(11*60*1000 + 20000);\r
2291         expect(begin.offset("12:11:20")).toEqual(12*60*60*1000 + 11*60*1000 + 20000);\r
2292         expect(begin.offset("-10:0")).toEqual(-600000);\r
2293         expect(begin.offset("-01:01:0.1")).toEqual(-1*60*60*1000 - 60000 - 100);\r
2294       } );\r
2295       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2296       it("should be this for the value (the invalid partion)", function() {\r
2297         expect(begin.offset(begin.trim(" h  o  g     1e "))).toEqual(0);\r
2298         expect(begin.offset("ms")).toEqual(0);\r
2299         expect(begin.offset(".s")).toEqual(0);\r
2300         expect(begin.offset("10:")).toEqual(0);\r
2301         expect(begin.offset("::")).toEqual(0);\r
2302         expect(begin.offset("-:0")).toEqual(0);\r
2303         expect(begin.offset("-::0")).toEqual(0);\r
2304       } );\r
2305     } );\r
2306     describe("An event method in $begin object", function() {\r
2307       /*境界条件を調べておく (limit value analysis)*/\r
2308       it("should be this for the value  (limit value analysis)", function() {\r
2309         var evt = begin.event();\r
2310         expect(evt.id).toBe("");\r
2311         expect(evt.event).toBe("");\r
2312         evt = begin.event("");\r
2313         expect(evt.id).toBe("");\r
2314         expect(evt.event).toBe("");\r
2315         evt = begin.event(".");\r
2316         expect(evt.id).toBe("");\r
2317         expect(evt.event).toBe("");\r
2318 \r
2319         evt = begin.event("a");\r
2320         expect(evt.id).toBe("");\r
2321         expect(evt.event).toBe("a");\r
2322         evt = begin.event("a.b");\r
2323         expect(evt.id).toBe("a");\r
2324         expect(evt.event).toBe("b");\r
2325       } );\r
2326       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2327       it("should be this for the value (the valid partion)", function() {\r
2328         var evt = begin.event("id.event");\r
2329         expect(evt.id).toBe("id");\r
2330         expect(evt.event).toBe("event");\r
2331         evt = begin.event("event");\r
2332         expect(evt.id).toBe("");\r
2333         expect(evt.event).toBe("event");\r
2334         \r
2335         evt = begin.event("event+0s");\r
2336         expect(evt.id).toBe("");\r
2337         expect(evt.event).toBe("event");\r
2338         evt = begin.event("event-0s");\r
2339         expect(evt.id).toBe("");\r
2340         expect(evt.event).toBe("event");\r
2341       } );\r
2342       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2343       it("should be this for the value (the invalid partion)", function() {\r
2344         evt = begin.event("...");\r
2345         expect(evt.id).toBe("");\r
2346         expect(evt.event).toBe("");\r
2347         evt = begin.event(".event");\r
2348         expect(evt.id).toBe("");\r
2349         expect(evt.event).toBe("");\r
2350         evt = begin.event("id.");\r
2351         expect(evt.id).toBe("");\r
2352         expect(evt.event).toBe("");\r
2353       } );\r
2354     } );\r
2355     \r
2356     describe("An parse method in $begin object", function() {\r
2357        beforeEach( function() {\r
2358         begin.string = "";\r
2359       } );\r
2360       /*境界条件を調べておく (limit value analysis)*/\r
2361       it("should be this for the value  (limit value analysis)", function() {\r
2362         expect(begin.parse().begin).toEqual(0);\r
2363         begin.string="+0";\r
2364         expect(begin.parse().begin).toEqual(0);\r
2365         begin.string = "+1";\r
2366         expect(begin.parse().begin).toEqual(1000*begin.fpms);\r
2367         begin.string = " ";\r
2368         expect(begin.parse().begin).toEqual(0);\r
2369         begin.string = "1";\r
2370         expect(begin.parse().begin).toEqual(1000*begin.fpms);\r
2371         begin.string = "+0ms";\r
2372         expect(begin.parse().begin).toEqual(0);\r
2373         begin.string = "-0ms";\r
2374         expect(begin.parse().begin).toEqual(0);\r
2375         \r
2376         expect(begin.eventOffset).toBe(0);\r
2377         begin.string = "click";\r
2378         expect(begin.parse().begin).toBe(0);\r
2379         expect(begin.eventOffset).toBe(0);\r
2380         begin.string = "id.click";\r
2381         expect(begin.parse().begin).toBe(0);\r
2382         expect(begin.eventOffset).toBe(0);\r
2383       } );\r
2384       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2385       it("should be this for the value (the valid partion)", function() {\r
2386         begin.string = " 1 0 0 m s";\r
2387         expect(begin.parse().begin).toEqual(Math.floor(100*begin.fpms));\r
2388 \r
2389         begin.string = "1ms";\r
2390         begin.isResolved = false;\r
2391         expect(begin.parse().begin).toEqual(Math.floor(1*begin.fpms));\r
2392         expect(begin.isResolved).toBeTruthy();\r
2393         expect(begin.eventOffset).toBe(0);\r
2394 \r
2395         begin.string="click+0";\r
2396         expect(begin.parse().begin).toBe(0);\r
2397         expect(begin.eventOffset).toBe(0);\r
2398         begin.string = "click+1";\r
2399         expect(begin.parse().begin).toBe(1000*begin.fpms);\r
2400         expect(begin.eventOffset).toBe(1000*begin.fpms);\r
2401         begin.string = " click ";\r
2402         expect(begin.parse().begin).toEqual(0);\r
2403         expect(begin.eventOffset).toBe(0);\r
2404         begin.string = "click+0ms";\r
2405         expect(begin.parse().begin).toEqual(0);\r
2406         expect(begin.eventOffset).toBe(0);\r
2407         begin.string = "click-0ms";\r
2408         expect(begin.parse().begin).toEqual(0);\r
2409         expect(begin.eventOffset).toBe(0);\r
2410         begin.string = "click+100ms";\r
2411         expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));\r
2412         expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));\r
2413         begin.string = "click-100ms";\r
2414         expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));\r
2415         expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));\r
2416 \r
2417         begin.string="id.click+0";\r
2418         expect(begin.parse().begin).toEqual(0);\r
2419         expect(begin.eventOffset).toBe(0);\r
2420         begin.string = "id.click+1";\r
2421         expect(begin.parse().begin).toEqual(1000*begin.fpms);\r
2422         expect(begin.eventOffset).toBe(1000*begin.fpms);\r
2423         begin.string = " id . click ";\r
2424         expect(begin.parse().begin).toEqual(0);\r
2425         expect(begin.eventOffset).toBe(0);\r
2426         begin.string = "id.click+0ms";\r
2427         expect(begin.parse().begin).toEqual(0);\r
2428         expect(begin.eventOffset).toBe(0);\r
2429         begin.string = "id.click-0ms";\r
2430         expect(begin.parse().begin).toEqual(0);\r
2431         expect(begin.eventOffset).toBe(0);\r
2432         begin.string = "id.click+100ms";\r
2433         expect(begin.parse().begin).toBe(Math.floor(100*begin.fpms));\r
2434         expect(begin.eventOffset).toBe(Math.floor(100*begin.fpms));\r
2435         begin.string = "id.click-100ms";\r
2436         expect(begin.parse().begin).toBe(Math.floor(-100*begin.fpms));\r
2437         expect(begin.eventOffset).toBe(Math.floor(-100*begin.fpms));\r
2438       } );\r
2439       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2440       it("should be this for the value (the invalid partion)", function() {\r
2441         begin.string = "ms";\r
2442         begin.isResolved = false;\r
2443         expect(begin.parse().begin).toEqual(0);\r
2444         expect(begin.isResolved).toBeFalsy();\r
2445       } );\r
2446     } );\r
2447     \r
2448     describe("A listener method in $begin object", function() {\r
2449       var obj = begin.up();\r
2450        beforeEach( function() {\r
2451         begin.string = "";\r
2452         /*配列は初期化しておく*/\r
2453         begin.timelines.length = 0;\r
2454         obj.$activate = begin.$activate.up();\r
2455         obj.startTime = Date.now();\r
2456         obj.setFrame(0);\r
2457       } );\r
2458       /*境界条件を調べておく (limit value analysis)*/\r
2459       it("should be this for the value  (limit value analysis)", function() {\r
2460         obj.isResolved = true;\r
2461         obj.listener();\r
2462         expect(obj.begin).toBe(0);\r
2463         \r
2464         obj.listener( {\r
2465             timeStamp: Date.now()\r
2466         } );\r
2467         expect(obj.begin).toBe(0);\r
2468         expect(obj.activeTime).toBeGreaterThan(0);\r
2469         expect(obj.timelines.length).toBe(1);\r
2470 \r
2471         obj.isResolved = false;\r
2472         obj.listener( {\r
2473             timeStamp: Date.now()\r
2474         } );\r
2475         expect(obj.begin).toBe(0);\r
2476         expect(obj.activeTime).toBeGreaterThan(0);\r
2477         expect(obj.timelines.length).toBe(1);\r
2478         /*配列を初期化*/\r
2479         obj.timelines.length = 0;\r
2480 \r
2481         obj.up().mix( {\r
2482                 begin: 1,\r
2483                 eventOffset: 1,\r
2484                 $activate: begin.$activate.up().mix( {\r
2485                     dur: "12"\r
2486                   } )\r
2487               })\r
2488               .listener( {\r
2489                 timeStamp: Date.now()\r
2490               } );\r
2491         expect(obj.$1.begin).toBe(1);\r
2492         expect(obj.$1.activeTime).toEqual(Math.floor(12000*obj.fpms));\r
2493         expect(obj.$1.$activate.begin).toBe(obj.$1.begin);\r
2494         expect(obj.timelines[0]).toBe(obj.$1);\r
2495       } );\r
2496       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2497       it("should be this for the value (the valid partion)", function() {\r
2498         obj.up().mix( {\r
2499                 begin: 1,\r
2500                 eventOffset: 1,\r
2501                 $activate: begin.$activate.up().mix( {\r
2502                     end: begin.$activate.end.up().mix( {\r
2503                        string: "1s"\r
2504                       } )\r
2505                   } )\r
2506               })\r
2507               .listener( {\r
2508                 timeStamp: Date.now()\r
2509               } );\r
2510         expect(obj.$1.begin).toBe(1);\r
2511         expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);\r
2512         expect(obj.$1.$activate.begin).toBe(obj.$1.begin);\r
2513         expect(obj.timelines[0]).toBe(obj.$1);\r
2514 \r
2515         obj.up().mix( {\r
2516                 begin: 1,\r
2517                 eventOffset: 1,\r
2518                 $activate: begin.$activate.up().mix( {\r
2519                     end: begin.$activate.end.up().mix( {\r
2520                        string: "1s"\r
2521                       } )\r
2522                   } )\r
2523               })\r
2524               .listener( {\r
2525                 timeStamp: Date.now()\r
2526               } );\r
2527         expect(obj.$1.begin).toBe(1);\r
2528         expect(obj.$1.activeTime).toBe(Math.floor(1000*obj.fpms) - 1);\r
2529         expect(obj.$1.$activate.begin).toBe(obj.$1.begin);\r
2530         expect(obj.timelines[1]).toBe(obj.$1);\r
2531         obj.$1.listener( {\r
2532           timeStamp: (Date.now() + 500)\r
2533         } );\r
2534         expect(obj.$1.begin).toBe(Math.floor(500*obj.fpms) + 1);\r
2535         expect(obj.$1.activeTime).toEqual(Math.floor(1000*obj.fpms) - Math.floor(500*obj.fpms) - 1);\r
2536         expect(obj.$1.$activate.begin).toBe(obj.$1.begin);\r
2537         expect(obj.timelines[1]).toBe(obj.$1);\r
2538       } );\r
2539       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2540       it("should be this for the value (the invalid partion)", function() {\r
2541         expect( function() {\r
2542           obj.listener({});\r
2543         } ).toThrow();\r
2544       } );\r
2545     } );\r
2546   } );\r
2547   describe("A $end object", function() {\r
2548     var end = base("$frame").$begin.$end.up();\r
2549     end.startTime = 0;\r
2550     beforeEach( function() {\r
2551       end.string = "";\r
2552       end.startTime = Date.now();\r
2553       end.setFrame(0);\r
2554     } );\r
2555     /*境界条件を調べておく (limit value analysis)*/\r
2556     it("should be this for the value  (limit value analysis)", function() {\r
2557       expect(end.up().call()).toBeNull();\r
2558       end.string = "0";\r
2559       expect(end.up().call()).toBe(0);\r
2560       end.string = "hoge";\r
2561       expect(end.up().call()).toBe("indefinite");\r
2562       \r
2563     } );\r
2564     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2565     it("should be this for the value (the valid partion)", function() {\r
2566       end.string = "hoge+0";\r
2567       expect(end.up().call()).toBe("indefinite");\r
2568       end.string = "12ms";\r
2569       expect(end.up().call()).toBe(Math.floor(12*end.fpms));\r
2570       end.string = "hoge+12ms";\r
2571       expect(end.up().call()).toBe("indefinite");\r
2572 \r
2573     } );\r
2574     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2575     it("should be this for the value (the invalid partion)", function() {\r
2576       end.string = null;\r
2577       expect(end.up().call()).toBeNull();\r
2578     } );\r
2579 \r
2580     describe("A listener method in $end object", function() {\r
2581       var obj,\r
2582           begin = base("$frame").$begin;\r
2583        beforeEach( function() {\r
2584         end.string = "";\r
2585         /*配列は初期化しておく*/\r
2586         end.timelines.length = 0;\r
2587         obj = end.up();\r
2588         obj.$begin = begin.up().mix( {\r
2589           begin: 12,\r
2590           activeTime: 120\r
2591         } );\r
2592         obj.$begin.$activate = begin.$activate.up();\r
2593         obj.addLine(obj.$begin);\r
2594       } );\r
2595       /*境界条件を調べておく (limit value analysis)*/\r
2596       it("should be this for the value  (limit value analysis)", function() {\r
2597         expect(obj.timelines[0]).toBe(obj.$begin);\r
2598         expect(obj.timelines[0]).not.toBe(obj);\r
2599         obj.listener();\r
2600         expect(obj.timelines[0]).not.toBe(obj.$begin);\r
2601 \r
2602         obj.addLine(obj.$begin.mix( {\r
2603           begin: 12,\r
2604           activeTime: 120\r
2605         } ) );\r
2606         obj.listener({\r
2607           timeStamp: (Date.now() + 12)\r
2608         } );\r
2609         expect(obj.timelines[0]).not.toBe(obj.$begin);\r
2610       } );\r
2611       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2612       it("should be this for the value (the valid partion)", function() {\r
2613         obj.$begin.$activate.begin = 0;\r
2614         obj.mix( {\r
2615           string: "event"\r
2616         } ).parse();\r
2617         obj.listener({\r
2618           timeStamp: (Date.now() + 120)\r
2619         } );\r
2620         expect(obj.timelines[0]).not.toBe(obj.$begin);\r
2621         expect(obj.begin).toBe(Math.ceil(120*obj.fpms));\r
2622         expect(obj.$begin.activeTime).toBe(Math.ceil(120*obj.fpms));\r
2623 \r
2624         obj.addLine(obj.$begin.mix( {\r
2625           begin: 12,\r
2626           activeTime: 120\r
2627         } ) );\r
2628         obj.$begin.$activate.begin = 0;\r
2629         obj.mix( {\r
2630           string: "event+1000ms"\r
2631         } ).parse();\r
2632         obj.listener({\r
2633           timeStamp: (Date.now() + 12)\r
2634         } );\r
2635         expect(obj.timelines[0]).toBe(obj.$begin);\r
2636         expect(obj.begin).toBe(Math.ceil(1012*obj.fpms));\r
2637         expect(obj.$begin.activeTime).toBe(Math.ceil(1012*obj.fpms));\r
2638       } );\r
2639       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2640       it("should be this for the value (the invalid partion)", function() {\r
2641         expect(function() {\r
2642           obj.listener({});\r
2643         } ).toThrow();\r
2644       } );\r
2645     } )\r
2646   } );\r
2647   describe("A $activate object", function() {\r
2648     var act = base("$frame").$begin.$activate.up();\r
2649      beforeEach( function() {\r
2650       act.dur = "indefinite";\r
2651       act.begin = 0;\r
2652       act.repeatCount = null;\r
2653       act.repeatDur = null;\r
2654       act.end = act.$begin.$end;\r
2655       act.simpleDur = base("$frame").$begin.$activate.simpleDur;\r
2656     } );\r
2657     /*境界条件を調べておく (limit value analysis)*/\r
2658     it("should be this for the value  (limit value analysis)", function() {\r
2659       expect(act.dur).toBe("indefinite");\r
2660       expect(typeof act.resolvedTime).toBe("function");\r
2661       expect(act.end).toBe(act.$begin.$end);\r
2662       expect(act.repeatCount).toBeNull();\r
2663       expect(act.repeatDur).toBeNull();\r
2664       expect(act.simpleDur()).toBeNull();\r
2665       expect(act.min).toBe("0");\r
2666       expect(act.max).toBe("indefinite");\r
2667 \r
2668       act.up("$a");\r
2669       expect(act.$a.call()).toBeNull();\r
2670       expect(act.$a.end).toBeNull();\r
2671     } );\r
2672     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2673     it("should be this for the value (the valid partion)", function() {\r
2674       expect(act.resolvedTime()).toEqual((+new Date()));\r
2675 \r
2676       /*Activate Duration = dur*/\r
2677       act.up("$b");\r
2678       act.$b.dur = "132ms";\r
2679       var abc = act.$b.call();\r
2680       expect(abc).toEqual(Math.floor(132*act.fpms));\r
2681       expect(abc).toEqual(act.$b.simpleDur);\r
2682       act.dur = null;\r
2683       expect(act.up().call()).toBeNull();\r
2684       \r
2685       /*AD = end -begin*/\r
2686       act.begin = 1;\r
2687       act.up("$eb").end = act.end.up().mix( {string: "120ms" } );\r
2688       expect( act.$eb.mix( {\r
2689         dur: "indefinite",\r
2690         simpleDur: act.simpleDur,\r
2691         repeatCount: 12,\r
2692         repeatDur: null,\r
2693       } ).call() ).toEqual(Math.floor(120*act.fpms) - 1);\r
2694       expect( act.$eb.mix( {\r
2695         dur: "12",\r
2696         repeatCount: "indefinite",\r
2697         repeatDur: null,\r
2698       } ).call() ).toEqual(Math.floor(120*act.fpms) - 1);\r
2699       expect( act.$eb.mix( {\r
2700         dur: "12",\r
2701         simpleDur: act.simpleDur,
2702         repeatCount: null,\r
2703         repeatDur: "indefinite",\r
2704       } ).call() ).toEqual(Math.floor(120*act.fpms) - 1);\r
2705       act.$eb.end *= 3;\r
2706       expect( act.$eb.mix( {\r
2707         dur: "12",\r
2708         simpleDur: act.simpleDur,
2709         repeatCount: "indefinite",\r
2710         repeatDur: "indefinite",\r
2711       } ).call() ).toEqual(Math.floor(120*act.fpms)*3 - 1);\r
2712 \r
2713       /*AD = Min(dur, end - begin)*/\r
2714       act.up("$c").end = act.end.up().mix( { string: "12" } );\r
2715       act.$c.mix( {\r
2716         dur: "10",\r
2717         simpleDur: act.simpleDur,
2718         repeatCount: null,\r
2719         repeatDur: null\r
2720       } );\r
2721       expect(act.$c.call()).toEqual(Math.floor(10000*act.fpms));\r
2722       expect(act.$c.call()).toEqual(act.$c.simpleDur);\r
2723       act.$c.mix( {\r
2724         dur: "15",\r
2725         simpleDur: act.simpleDur,
2726         repeatCount: null,\r
2727         repeatDur: null\r
2728       } );\r
2729       expect(act.$c.call()).toEqual(Math.floor(12000*act.fpms) - 1);\r
2730       expect(act.$c.simpleDur).toEqual(Math.floor(15000*act.fpms));\r
2731 \r
2732       /*AD = Min(repeatCount*dur, end - begin)*/\r
2733       expect(act.$c.end).toEqual(Math.floor(12000*act.fpms));\r
2734       act.$c.mix( {\r
2735         dur: "10",\r
2736         simpleDur: act.simpleDur,
2737         repeatCount: 2,\r
2738         repeatDur: null\r
2739       } );\r
2740       expect(act.$c.call()).toEqual(Math.floor(12000*act.fpms) - 1);\r
2741       expect(act.$c.simpleDur).toEqual(Math.floor(10000*act.fpms));\r
2742       act.$c.mix( {\r
2743         dur: "10",\r
2744         simpleDur: act.simpleDur,
2745         repeatCount: 1,\r
2746         repeatDur: null\r
2747       } );\r
2748       expect(act.$c.call()).toEqual(Math.floor(10000*act.fpms));\r
2749       expect(act.$c.simpleDur).toEqual(Math.floor(10000*act.fpms));\r
2750 \r
2751       /*AD = Min(repeatDur, end - begin)*/\r
2752       act.$c.mix( {\r
2753         dur: "indefinite",\r
2754         simpleDur: act.simpleDur,
2755         repeatCount: 2,\r
2756         repeatDur: "15"\r
2757       } );\r
2758       expect(act.$c.call()).toEqual(Math.floor(12000*act.fpms) - 1);\r
2759       expect(act.$c.simpleDur).toBeNull();\r
2760       act.$c.mix( {\r
2761         dur: "indefinite",\r
2762         simpleDur: act.simpleDur,
2763         repeatCount: 2,\r
2764         repeatDur: "10"\r
2765       } );\r
2766       expect(act.$c.call()).toEqual(Math.floor(10000*act.fpms));\r
2767       expect(act.$c.simpleDur).toBeNull();\r
2768       act.$c.mix( {\r
2769         dur: "10",\r
2770         simpleDur: act.simpleDur,
2771         repeatCount: null,\r
2772         repeatDur: "15"\r
2773       } );\r
2774       expect(act.$c.call()).toEqual(Math.floor(12000*act.fpms) - 1);\r
2775       expect(act.$c.simpleDur).toEqual(Math.floor(10000*act.fpms));\r
2776       act.$c.mix( {\r
2777         dur: "10",\r
2778         simpleDur: act.simpleDur,
2779         repeatCount: null,\r
2780         repeatDur: "11"\r
2781       } );\r
2782       expect(act.$c.call()).toEqual(Math.floor(11000*act.fpms));\r
2783       expect(act.$c.simpleDur).toEqual(Math.floor(10000*act.fpms));\r
2784       \r
2785       /*AD = Min(repeatCount*d, repeatDur, end - begin)*/\r
2786       act.$c.mix( {\r
2787         dur: "10",\r
2788         simpleDur: act.simpleDur,
2789         repeatCount: 2,\r
2790         repeatDur: "15"\r
2791       } );\r
2792       expect(act.$c.call()).toEqual(Math.floor(12000*act.fpms) - 1);\r
2793       expect(act.$c.simpleDur).toEqual(Math.floor(10000*act.fpms));\r
2794       act.$c.mix( {\r
2795         dur: "10",\r
2796         simpleDur: act.simpleDur,
2797         repeatCount: 1,\r
2798         repeatDur: "15"\r
2799       } );\r
2800       expect(act.$c.call()).toEqual(Math.floor(10000*act.fpms));\r
2801       expect(act.$c.simpleDur).toEqual(Math.floor(10000*act.fpms));\r
2802       act.$c.mix( {\r
2803         dur: "11",\r
2804         simpleDur: act.simpleDur,
2805         repeatCount: 1,\r
2806         repeatDur: "9"\r
2807       } );\r
2808       expect(act.$c.call()).toEqual(Math.floor(9000*act.fpms));\r
2809       expect(act.$c.simpleDur).toEqual(Math.floor(11000*act.fpms));\r
2810 \r
2811       /*AD = repeatDur,*/\r
2812       act.$c.mix( {\r
2813         end: null,\r
2814         dur: "10",\r
2815         simpleDur: act.simpleDur,
2816         repeatCount: null,\r
2817         repeatDur: "15"\r
2818       } );\r
2819       expect(act.$c.call()).toEqual(Math.floor(15000*act.fpms));\r
2820       expect(act.$c.simpleDur).toEqual(Math.floor(10000*act.fpms));\r
2821       act.$c.mix( {\r
2822         dur: "indefinite",\r
2823         simpleDur: act.simpleDur,
2824         repeatCount: 2,\r
2825         repeatDur: "10"\r
2826       } );\r
2827       expect(act.$c.call()).toEqual(Math.floor(10000*act.fpms));\r
2828       expect(act.$c.simpleDur).toBeNull();\r
2829 \r
2830       act.end.string = null;\r
2831       act.up("$cd").mix( {\r
2832         dur: "10",\r
2833         end: act.end,\r
2834         repeatCount: 2\r
2835       } );\r
2836       expect(act.$cd.call()).toEqual(Math.floor(10000*act.fpms) * 2);\r
2837       \r
2838       act.$cd.end = act.end;\r
2839       act.$cd.repeatCount = null;\r
2840       act.$cd.repeatDur = "12";\r
2841       expect(act.$cd.call()).toEqual(Math.floor(12000*act.fpms));\r
2842       \r
2843       act.up("$d").mix( {\r
2844         min: "2",\r
2845         max: "3",\r
2846         dur: "1",\r
2847         simpleDur: act.simpleDur\r
2848       } );\r
2849       expect(act.$d.call()).toEqual(Math.floor(2000*act.fpms));\r
2850       act.up("$d").mix( {\r
2851         min: "1",\r
2852         max: "2",\r
2853         dur: "12",\r
2854         simpleDur: act.simpleDur\r
2855       } );\r
2856       expect(act.$d.call()).toEqual(Math.floor(2000*act.fpms));\r
2857       \r
2858       /*endで0が指定されている場合*/\r
2859       act.begin = 0;\r
2860       act.end = 0;\r
2861       act.repeatDur = null;\r
2862       act.repeatCount = "indefinite";\r
2863       act.dur = "1";\r
2864       expect(act.call()).toEqual(0);\r
2865       act.repeatCount = null;\r
2866       act.repeatDur = "indefinite";\r
2867       act.dur = "1";\r
2868       expect(act.call()).toEqual(0);\r
2869       act.repeatDur = "indefinite";\r
2870       act.repeatCount = "indefinite";\r
2871       act.dur = "1";\r
2872       expect(act.call()).toEqual(0);\r
2873     } );\r
2874     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
2875     it("should be this for the value (the invalid partion)", function() {\r
2876       /*min > max*/\r
2877       act.up("$d").mix( {\r
2878         min: "3",\r
2879         max: "2",\r
2880         dur: "1",\r
2881         simpleDur: act.simpleDur\r
2882       } );\r
2883       expect(act.$d.call()).toEqual(Math.floor(1000*act.fpms));\r
2884       \r
2885       act.repeatDur = null;\r
2886       act.repeatCount = "indefinite";\r
2887       act.dur = "1";\r
2888       expect(act.call()).toBeNull();\r
2889       act.repeatCount = null;\r
2890       act.repeatDur = "indefinite";\r
2891       act.dur = "1";\r
2892       expect(act.call()).toBeNull();\r
2893       act.repeatDur = "indefinite";\r
2894       act.repeatCount = "indefinite";\r
2895       act.dur = "1";\r
2896       expect(act.call()).toBeNull();\r
2897     } );\r
2898   } );\r
2899   describe("A $from object", function() {\r
2900     var from = base("$from");\r
2901      beforeEach( function() {\r
2902        from = base("$from").up();\r
2903        from.from = from.from.up();\r
2904        from.string = "";\r
2905      } );\r
2906     /*境界条件を調べておく (limit value analysis)*/\r
2907     it("should be this for the value  (limit value analysis)", function() {\r
2908       expect(from.string).toBe("");\r
2909       expect(from.numList()).toEqual([]);\r
2910       expect(from.strList()).toBeNull();\r
2911 \r
2912       from.string = "0";\r
2913       expect(from.numList()[0]).toEqual(0);\r
2914       expect(from.strList()).toBeNull();\r
2915       \r
2916       from.string = " 0 ";\r
2917       expect(from.numList()[0]).toEqual(0);\r
2918       expect(from.strList().join("")).toBe("  ");\r
2919 \r
2920       from.string = "a";\r
2921       expect(from.numList()).toEqual([]);\r
2922       expect(from.strList()[0]).toBe("a");\r
2923       \r
2924       from.string = null;\r
2925       expect( function() {\r
2926         from.numList();\r
2927       } ).toThrow();\r
2928       expect( function() {\r
2929         from.strList();\r
2930       } ).toThrow();\r
2931       \r
2932       expect(from.underlying.additive[0]).toEqual(0);\r
2933       expect(from.underlying.accumlate[0]).toEqual(0);\r
2934     } );\r
2935     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
2936     it("should be this for the value (the valid partion)", function() {\r
2937       from.string = "0a";\r
2938       expect(from.numList()[0]).toEqual(0);\r
2939       expect(from.strList()[0]).toBe("a");\r
2940 \r
2941       from.string = "a0";\r
2942       expect(from.numList()[0]).toEqual(0);\r
2943       expect(from.strList()[0]).toBe("a");\r
2944 \r
2945       from.string = "0.1";\r
2946       expect(from.numList()[0]).toEqual(0.1);\r
2947       expect(from.strList()).toBeNull();\r
2948 \r
2949       from.string = "+0.1";\r
2950       expect(from.numList()[0]).toEqual(0.1);\r
2951       expect(from.strList()).toBeNull();\r
2952 \r
2953       from.string = "-0.1";\r
2954       expect(from.numList()[0]).toEqual(-0.1);\r
2955       expect(from.strList()).toBeNull();\r
2956 \r
2957       from.string = "1e-1";\r
2958       expect(from.numList()[0]).toEqual(1e-1);\r
2959       expect(from.strList()).toBeNull();\r
2960 \r
2961       from.string = "1E-1";\r
2962       expect(from.numList()[0]).toEqual(1E-1);\r
2963       expect(from.strList()).toBeNull();\r
2964 \r
2965       from.string = "0,0";\r
2966       expect(from.numList().toString()).toBe("0,0");\r
2967       expect(from.strList().join("")).toBe(",");\r
2968 \r
2969       from.string = "a00a";\r
2970       expect(from.numList()[0]).toBe(0);\r
2971       expect(from.strList().join("")).toBe("aa");\r
2972 \r
2973       from.string = "a0b0a";\r
2974       expect(from.numList().toString()).toBe("0,0");\r
2975       expect(from.strList().join("")).toBe("aba");\r
2976 \r
2977       from.string = "0b0a";\r
2978       expect(from.numList().toString()).toBe("0,0");\r
2979       expect(from.strList().join("")).toBe("ba");\r
2980 \r
2981       from.string = "0b-1.0a";\r
2982       expect(from.numList()[1]).toBe(-1);\r
2983       expect(from.strList().join("")).toBe("ba");\r
2984 \r
2985       expect(from.up().call()).toBe(from.$1.numList);\r
2986       expect(from.$1.numList[1]).toBe(-1);\r
2987       expect(from.$1.strList.join("")).toBe("ba");\r
2988 \r
2989       from.string = "あ 0b-1.0a12";\r
2990       expect(from.numList()[1]).toBe(-1);\r
2991       expect(from.strList().join("")).toBe("あ ba12");\r
2992 \r
2993       from.string = "0b-1.0a0";\r
2994       expect(from.numList().join(",")).toBe("0,-1,0");\r
2995       expect(from.strList().join("")).toBe("ba");\r
2996 \r
2997       from.string = "0b .1a";\r
2998       expect(from.numList()[1]).toBe(0.1);\r
2999       expect(from.strList().join("")).toBe("b a");\r
3000     } );\r
3001     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3002     it("should be this for the value (the invalid partion)", function() {\r
3003       from.string = NaN;\r
3004       expect(function(){\r
3005         from.numList();\r
3006       } ).toThrow();\r
3007       expect(function(){\r
3008         from.strList();\r
3009       } ).toThrow();      \r
3010       \r
3011       from.string = "currentColor";\r
3012       expect(from.numList()).toEqual([]);\r
3013       expect(from.strList()[0]).toBe("currentColor");\r
3014 \r
3015       from.string = "eE";\r
3016       expect(from.numList()).toEqual([]);\r
3017       expect(from.strList()[0]).toBe("eE");\r
3018       expect(from.strList()[0]).toBe("eE");\r
3019     } )\r
3020   } );\r
3021   describe("A $to object", function() {\r
3022     var from = base("$from");\r
3023      beforeEach( function() {\r
3024        from = base("$from").up();\r
3025        from.up("$to");\r
3026        from.string = "";\r
3027      } );\r
3028     /*境界条件を調べておく (limit value analysis)*/\r
3029     it("should be this for the value  (limit value analysis)", function() {\r
3030       expect(from.$to instanceof from.constructor).toBeTruthy();\r
3031       expect(from.up().call()).toBe(from.$1.numList);\r
3032       expect(from.$to.up().call()).toBe(from.$to.$1.numList);\r
3033     } );\r
3034     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3035     it("should be this for the value (the valid partion)", function() {\r
3036       from.up("$to");\r
3037       from.$to.from = from;\r
3038       from.$to.string = "12cm-7";\r
3039       expect(from.$to.numList().join(",")).toBe("12,-7");\r
3040       expect(from.$to.strList().toString()).toBe("cm");\r
3041       \r
3042       from.string = "7cm+8";\r
3043       from.$to.call();\r
3044       expect(from.call()).toBe(from.numList);\r
3045       expect(from.$to.numList.join(",")).toBe("12,-7");\r
3046       expect(from.$to.strList.join("")).toBe("cm");\r
3047       expect(from.numList.join(",")).toBe("7,8");\r
3048       expect(from.strList.join("")).toBe("cm");\r
3049       expect(from.$to.from).toBe(from.numList);\r
3050 \r
3051     } );\r
3052     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3053     it("should be this for the value (the invalid partion)", function() {\r
3054       from.call();\r
3055       from.up("$to").mix( function() {\r
3056         this.string = "12cm";\r
3057         this.call();\r
3058         expect(this.numList).toEqual([]);\r
3059         expect(this.strList).toBeNull();\r
3060       } );\r
3061     } );\r
3062     \r
3063     describe("An advance method", function() {\r
3064       var from = base("$from");\r
3065        beforeEach( function() {\r
3066          from = base("$from").up();\r
3067          from.string = "";\r
3068          from.up("$to");\r
3069          from.$to.from = from;\r
3070        } );\r
3071       /*境界条件を調べておく (limit value analysis)*/\r
3072       it("should be this for the value  (limit value analysis)", function() {\r
3073         expect(from.advance()).toBe("");\r
3074         expect(from.$to.advance()).toBe("");\r
3075         expect(from.$to.advance(0)).toBe("");\r
3076         expect(from.$to.advance(1)).toBe("");\r
3077         expect(function(){\r
3078           from.$to.advance(1.01);\r
3079         }).toThrow("An Invalid Number Error");\r
3080         expect(function(){\r
3081           from.$to.advance(-0.01);\r
3082         }).toThrow("An Invalid Number Error");\r
3083         \r
3084         from.string = "0";\r
3085         from.$to.string = "1";\r
3086         expect(from.$to.call()).toBe(from.$to.numList);\r
3087         expect(from.$to.numList[0]).toEqual(1);\r
3088         expect(from.$to.strList).toBeNull();\r
3089         expect(from.numList[0]).toEqual(0);\r
3090         expect(from.strList).toBeNull();\r
3091         expect(from.advance(0)).toBe("");\r
3092         expect(from.$to.from).toBe(from.numList);\r
3093         expect(from.$to.advance(0)).toBe("0");       \r
3094         expect(from.call()).toBe(from.numList);\r
3095       } );\r
3096       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3097       it("should be this for the value (the valid partion)", function() {\r
3098         var deg = 3;\r
3099         \r
3100         from.string = "0s";\r
3101         from.$to.string = "1s";\r
3102         expect(from.$to.call()).toBe(from.$to.numList);\r
3103         expect(from.$to.numList[0]).toEqual(1);\r
3104         expect(from.$to.strList[0]).toEqual("");\r
3105         expect(from.numList[0]).toEqual(0);\r
3106         expect(from.strList[0]).toEqual("");\r
3107         expect(from.advance(0)).toBe("");\r
3108         expect(from.$to.from).toBe(from.numList);\r
3109         expect(from.$to.advance(0)).toBe("0s");\r
3110         from.$to.degit = deg;\r
3111         for (var i=0;i<1;i+=0.01) {\r
3112           expect(from.$to.advance(i)).toBe(i.toFixed(deg)+"s");\r
3113         }\r
3114         expect(from.call()).toBe(from.numList);\r
3115         \r
3116         from = base("$from").up();\r
3117         from.up("$to");\r
3118         from.string = "a0S";\r
3119         from.$to.string = "a1S";\r
3120         from.$to.from = from;\r
3121         expect(from.$to.call()).toBe(from.$to.numList);\r
3122         expect(from.$to.numList[0]).toEqual(1);\r
3123         expect(from.$to.strList[0]).toEqual("a");\r
3124         expect(from.numList[0]).toEqual(0);\r
3125         expect(from.strList[0]).toEqual("a");\r
3126         expect(from.advance(0)).toBe("");\r
3127         expect(from.$to.from).toBe(from.numList);\r
3128         expect(from.$to.advance(0)).toBe("a0S");\r
3129 \r
3130         from.$to.degit = deg;\r
3131         for (var i=0;i<1;i+=0.01) {\r
3132           expect(from.$to.advance(i)).toBe("a" +i.toFixed(deg)+ "S");\r
3133         }\r
3134         expect(from.call()).toBe(from.numList);\r
3135         \r
3136         from = base("$from").up();\r
3137         from.up("$to");\r
3138         from.string = "a-10s1.5";\r
3139         from.$to.string = "a10s-3";\r
3140         from.$to.from = from;\r
3141         from.$to.call();\r
3142         from.$to.degit = 1;\r
3143         expect(from.$to.advance(0)).toEqual("a-10.0s1.5");\r
3144         expect(from.$to.advance(0.4)).toEqual("a-2.0s-0.3");\r
3145         expect(from.$to.advance(1)).toEqual("a10.0s-3.0");\r
3146         \r
3147         from.$to.underlying.additive[0] = 1;\r
3148         from.$to.underlying.accumlate[1] = 2;\r
3149         expect(from.$to.advance(0.4)).toEqual("a-1.0s1.7");\r
3150         from.$to.underlying.additive[0] = 0.5;\r
3151         from.$to.underlying.accumlate[1] = 0.8;\r
3152         expect(from.$to.advance(1)).toEqual("a10.5s-2.2");\r
3153       } );\r
3154       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3155       it("should be this for the value (the invalid partion)", function() {\r
3156         expect(function(){\r
3157           from.$to.advance(10);\r
3158         }).toThrow("An Invalid Number Error");\r
3159         expect(function(){\r
3160           from.$to.advance(-10);\r
3161         }).toThrow("An Invalid Number Error");\r
3162       } );\r
3163     } )\r
3164   } );\r
3165    describe("A distance method", function() {\r
3166       var from = base("$from");\r
3167        beforeEach( function() {\r
3168          from = base("$from").up();\r
3169          from.string = "";\r
3170          from.up("$to");\r
3171        } );\r
3172       /*境界条件を調べておく (limit value analysis)*/\r
3173       it("should be this for the value  (limit value analysis)", function() {\r
3174         expect(from.distance()).toEqual(0)\r
3175         expect(from.$to.distance()).toEqual(0);\r
3176         \r
3177         from.string = "0";\r
3178         from.$to.string = "1";\r
3179         expect(from.distance()).toEqual(0);\r
3180         expect(from.$to.distance(from)).toEqual(1);\r
3181       } );\r
3182       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3183       it("should be this for the value (the valid partion)", function() {\r
3184         from.string = "s 0 s 12";\r
3185         from.$to.string = "s 0 s 0";\r
3186         expect(from.distance()).toEqual(0);\r
3187         expect(from.$to.distance(from)).toEqual(12);\r
3188         expect(from.$to.distance(from)).toEqual(12);\r
3189         expect(from.$to.distance(from.call())).toEqual(12);\r
3190 \r
3191         from = base("$from").up();\r
3192         from.up("$to");\r
3193         from.string = "rgb(1, 0, 0)";\r
3194         from.$to.string = "rgb(0, 0, 1)";\r
3195         expect(from.distance()).toEqual(0);\r
3196         expect(from.$to.distance(from)).toEqual(Math.sqrt(2));\r
3197       } );\r
3198       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3199       it("should be this for the value (the invalid partion)", function() {\r
3200         from.string = "s";\r
3201         from.$to.string = "s";\r
3202         expect(from.$to.distance(from)).toEqual(0);\r
3203       } );\r
3204    } );\r
3205   describe("A $calcMode object", function() {\r
3206     var calc = base("$calcMode"),\r
3207         to = calc.to,\r
3208         from;\r
3209      beforeEach( function() {\r
3210        calc = base("$calcMode").up();\r
3211        calc.to = base("$from").up().mix( {string: "1"} );\r
3212        from = calc.to.from = base("$from").up().mix( {string: "0"} );\r
3213      } );\r
3214     /*境界条件を調べておく (limit value analysis)*/\r
3215     it("should be this for the value  (limit value analysis)", function() {\r
3216       expect(calc.mode).toBe("linear");\r
3217       expect(calc.keyTime).toEqual(1);\r
3218       expect(calc.keySplines).toBeNull();\r
3219       expect(calc.string).toBe("");\r
3220 \r
3221       expect(calc.call()(0)).toBe("0");\r
3222       expect(calc.keyTime).toBe(1);\r
3223       expect(calc.call()(1)).toBe("1");\r
3224       \r
3225       calc.keyTime = 0;\r
3226       expect(calc.call()(1)).toBe("0");\r
3227       \r
3228       /*paced mode*/\r
3229       calc.mode = "paced";\r
3230       expect(calc.norm).toEqual(1);\r
3231       calc.to.from = from;\r
3232       expect(calc.call()(0)).toBe("0");\r
3233       expect(calc.keyTime).toBe(1);\r
3234       calc.to.from = from;\r
3235       expect(calc.call()(1)).toBe("1");\r
3236       \r
3237       calc.keyTime = 0;\r
3238       calc.to.from = from;\r
3239       expect(calc.call()(1)).toBe("1");\r
3240       \r
3241       /*discrete mode*/\r
3242       calc.mode = "discrete";\r
3243       calc.to.from = from;\r
3244       calc.keyTime = 1;\r
3245       expect(calc.call()(0)).toBe("0");\r
3246       expect(calc.call()(1)).toBe("0");\r
3247     } );\r
3248     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3249     it("should be this for the value (the valid partion)", function() {\r
3250       calc.mode = "linear";\r
3251       calc.keyTime = 0.5;\r
3252       calc.to.degit = 1;\r
3253       expect(calc.call()(0.2)).toBe("0.4");\r
3254       expect(calc.call()(0.3)).toBe("0.6");\r
3255       /*もう一度確かめる*/\r
3256       expect(calc.call()(0.2)).toBe("0.4");\r
3257       \r
3258       calc = base("$calcMode").up();\r
3259       calc.keyTime = 0.2;\r
3260       calc.to = base("$from").up();\r
3261       calc.to.from = base("$from").up();    \r
3262       calc.to.from.string = "0s";\r
3263       calc.to.string = "1s";\r
3264       calc.to.degit = 1;\r
3265       expect(calc.call()(0.1)).toBe("0.5s");\r
3266 \r
3267       calc = base("$calcMode").up();\r
3268       calc.keyTime = 0.5;\r
3269       calc.to = base("$from").up();\r
3270       calc.to.from = base("$from").up();    \r
3271       calc.to.from.string = "rgb(100, 20, 32)";\r
3272       calc.to.string = "rgb(0, 10, 50)";\r
3273       expect(calc.call()(0.25)).toBe("rgb(50, 15, 41)");\r
3274       \r
3275       /*paced mode*/\r
3276       calc.to = base("$from").up();\r
3277       calc.to.from = base("$from").up();    \r
3278       calc.mode = "paced";\r
3279       calc.norm = 100;\r
3280       calc.to.from.string = "0s";\r
3281       calc.to.string = "20s";\r
3282       calc.to.degit = 1;\r
3283       expect(calc.call()(0.1)).toEqual("10.0s");\r
3284       expect(calc.keyTime).toEqual(0.2);\r
3285 \r
3286       calc.to = base("$from").up();\r
3287       calc.to.from = base("$from").up();    \r
3288       calc.mode = "paced";\r
3289       calc.norm = 100;\r
3290       calc.to.from.string = "rgb(0, 0, 20)";\r
3291       calc.to.string = "rgb(0, 0, 0)";\r
3292       expect(calc.call()(0.1)).toEqual("rgb(0, 0, 10)");\r
3293       expect(calc.keyTime).toEqual(0.2);\r
3294       \r
3295       /*discrete mode*/\r
3296       calc.to = base("$from").up();\r
3297       calc.to.from = base("$from").up();    \r
3298       calc.mode = "discrete";\r
3299       calc.keyTime = 0.5;\r
3300       calc.to.degit = 1;\r
3301       calc.to.from.string = "0.5";\r
3302       expect(calc.call()(0.2)).toBe("0.5");\r
3303       expect(calc.call()(0.3)).toBe("0.5");\r
3304       /*もう一度確かめる*/\r
3305       expect(calc.call()(0.2)).toBe("0.5");\r
3306     } );\r
3307     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3308     it("should be this for the value (the invalid partion)", function() {\r
3309       calc.keyTime = null;\r
3310       expect(calc.call()(1)).toEqual(calc.string);\r
3311       \r
3312       calc.keyTime = 1/0;\r
3313       expect(calc.call()(1)).toEqual(calc.string);\r
3314 \r
3315       expect(calc.call()()).toEqual(calc.string);\r
3316 \r
3317       calc = base("$calcMode").up();\r
3318       calc.mode = "paced";\r
3319       calc.to.from = from;\r
3320       expect(calc.call()()).toEqual(calc.string);\r
3321       \r
3322       calc = base("$calcMode").up();\r
3323       calc.mode = "discrete";\r
3324       expect(calc.call()()).toEqual(calc.string);\r
3325     } );\r
3326     \r
3327     /*splineモードの境界条件を調べておく (limit value analysis)*/\r
3328     it("should be this for the value  (spline mode limit value analysis)", function() {\r
3329       /*3次ベジェ曲線の数式はこのページを参考にした http://opentype.jp/fontguide_doc3.htm*/\r
3330       var x = 0,\r
3331           y = 0,\r
3332           bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {\r
3333             return function (t) {\r
3334               x = (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;\r
3335               y = (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;\r
3336               return y;\r
3337             };\r
3338           };\r
3339       expect(calc.keySplines).toBeNull();\r
3340       calc.mode = "spline";\r
3341       expect( calc.call()("undef")).toBe(Math.PI);\r
3342       calc.keySplines = [0, 0, 1, 1];\r
3343       calc.to.degit = 1;\r
3344       calc.to.from = from;\r
3345       expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");\r
3346       calc.to.from = from;\r
3347       expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");\r
3348       calc.to.from = from;\r
3349       expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");\r
3350       \r
3351       df(0,0, 0,0, 1,1, 1,1, 0.1);\r
3352       df(0,0, 0,0, 1,1, 1,1, 0.5);\r
3353       df(0,0, 0,0, 1,1, 1,1, 0.8);\r
3354       df(0,0, 0,0, 1,1, 1,1, 0.9);\r
3355       df(0,0, 0.75,0, 0,0.75, 1,1, 0.1);\r
3356       df(0,0, 0.75,0, 0,0.75, 1,1, 0.5);\r
3357       df(0,0, 0.75,0, 0,0.75, 1,1, 0.8);\r
3358       df(0,0, 0.75,0, 0,0.75, 1,1, 0.9);\r
3359       function df (x1, y1, x2, y2, x3, y3, x4, y4, t) {\r
3360       /*自作のニュートン法*/\r
3361         var a = y4-3*(y3-y2)-y1,\r
3362             b = 3*(y3-2*y2+y1),\r
3363             c = 3*(y2-y1),\r
3364             d = y1 - bezier.apply(null, arguments)(t);\r
3365         expect(Math.abs(Math.qubicnewton(a, b, c, d, t) - t)).toBeLessThan(1e-5);\r
3366       };\r
3367     } );\r
3368     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3369     it("should be this for the value (the valid partion on a spline mode )", function() {\r
3370       var x = 0,\r
3371           y = 0,\r
3372           bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {\r
3373             return function (t) {\r
3374               return {\r
3375                   x: (x4-3*(x3-x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1,\r
3376                   y: (y4-3*(y3-y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1\r
3377                 };\r
3378             };\r
3379           };\r
3380       calc.mode = "spline";\r
3381       calc.keySplines = [0, 0.5, 0.5, 1];\r
3382       calc.to.degit = 1;\r
3383       var b = bezier(0,0, 0,0.5, 0.5,1, 1,1);\r
3384       expect(calc.call()(0)).toBe(b(0).y+".0");\r
3385       calc.to.from = from;\r
3386       expect(calc.call()(1)).toBe(b(1).y+".0");\r
3387       calc.to.from = from;\r
3388       expect(calc.call()( b(0.5).x )).toBe(b(0.5).y.toFixed(1));\r
3389       \r
3390       var ff = function(k) {\r
3391         calc.keySplines = k;\r
3392         calc.to.degit = 10;\r
3393         var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1),\r
3394             epsilon = 1e-5; //誤差\r
3395         expect(calc.call()(0)).toBe(b(0).y.toFixed(10));\r
3396         calc.to.from = from;\r
3397         expect(calc.call()(1)).toBe(b(1).y.toFixed(10));\r
3398         calc.to.from = from;\r
3399         b = b(Math.random());\r
3400         expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon);\r
3401       };\r
3402       for (var i=0;i<10000;++i) {\r
3403         var rand = [Math.random(), Math.random(), Math.random(), Math.random()].sort(function(a,b){return a-b;});\r
3404         ff(rand);\r
3405       }\r
3406     } );\r
3407     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3408     it("should be this for the value (the invalid partion on a spline mode )", function() {\r
3409       calc.mode = "spline";\r
3410       calc.keySplines = [0, NaN, 1, 1];\r
3411       calc.to.degit = 1;\r
3412       calc.to.from = from;\r
3413       expect( calc.up().call()("undef")).toBe(Math.PI);\r
3414 \r
3415       \r
3416       calc.keySplines = [0, 0, 1, 2];\r
3417       calc.to.degit = 1;\r
3418       calc.to.from = from;\r
3419       expect( calc.up().call()("undef")).toBe(Math.PI);\r
3420       \r
3421       calc.keySplines = null;\r
3422       calc.to.degit = 1;\r
3423       calc.to.from = from;\r
3424       expect( calc.up().call()("undef")).toBe(Math.PI);\r
3425     } );\r
3426   } );\r
3427   describe("A $attribute object", function() {\r
3428     describe("A push method", function() {\r
3429       var attr, s;\r
3430       beforeEach( function() {\r
3431         attr = base("$calcMode").$attribute.up("width");\r
3432         base("$frame").timelines.length = 0;\r
3433         s = document.createElementNS("http:///www.w3.org/2000/svg", "animate");\r
3434       } );\r
3435       /*境界条件を調べておく (limit value analysis)*/\r
3436       it("should be this for the value  (limit value analysis)", function() {\r
3437         expect(attr.element).toBeNull();\r
3438         expect(attr.push()).toBeNull();\r
3439         expect(attr.element).toBeNull();\r
3440         expect(base("$frame").timelines.length).toEqual(0);\r
3441         \r
3442         expect(attr.push(s)).toBeNull();\r
3443         expect(attr.element).toBeNull();\r
3444         expect(base("$frame").timelines.length).toEqual(0);\r
3445         \r
3446         var p = document.createElement("g");\r
3447         p.appendChild(s);\r
3448         expect(attr.push(s)).toBeNull();\r
3449         expect(attr.element).toBe(p);\r
3450         expect(base("$frame").timelines.length).toEqual(0);\r
3451         \r
3452         s.setAttribute("end", "0");\r
3453         check("from", 1);\r
3454         check("to", 2);\r
3455         check("by", 3);\r
3456         check("values", 4);\r
3457         function check(attrName, num) {\r
3458           s.setAttribute(attrName, "1");\r
3459           expect(s.hasAttributeNS(null, attrName)).toBeTruthy();\r
3460           var l = attr.push(s);\r
3461           expect(attr.element).toBe(p);\r
3462           var timelines = base("$frame").timelines;\r
3463           expect(timelines.length).toEqual(num);\r
3464           var line = timelines[num-1];\r
3465           expect(line.string).toBe("0");\r
3466           expect(line).toBe(l); //タイムラインのオブジェクトを返す\r
3467           var act = line.$activate;\r
3468           expect(act.dur).toBeNull();\r
3469           expect(act.end).toBe(0);\r
3470           expect(act.repeatCount).toBeNull();\r
3471           expect(act.repeatDur).toBeNull();\r
3472           expect(act.min).toBe("0");\r
3473           expect(act.max).toBe("indefinite");\r
3474           expect(act.simpleDur).toBeNull();\r
3475           \r
3476           s.removeAttribute(attrName);\r
3477           expect(s.hasAttributeNS(null, attrName)).toBeFalsy();\r
3478           attr.push(s);\r
3479           expect(attr.element).toBe(p);\r
3480           expect(timelines.length).toEqual(num);\r
3481         };\r
3482           \r
3483         /*targetElement属性のサポート*/\r
3484         var p2 = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
3485         document.documentElement.appendChild(p2);\r
3486         p2.setAttributeNS(null, "id", "p23");\r
3487         s.setAttributeNS(null, "targetElement", "p23");\r
3488         attr.push(s);\r
3489         expect(attr.element).toBe(p2);\r
3490         \r
3491         /*ハイパーリンクのサポート*/\r
3492         var p3 = document.createElementNS("http://www.w3.org/2000/svg", "a");\r
3493         document.documentElement.appendChild(p3);\r
3494         p3.setAttributeNS(null, "id", "p34");\r
3495         s.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#p34");\r
3496         attr.push(s);\r
3497         expect(attr.element).toBe(p3);\r
3498       } );\r
3499       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3500       it("should be this for the value (the valid partion on a spline mode )", function() {\r
3501         s.setAttribute("from", "1");\r
3502         var p = document.createElement("g");\r
3503         p.appendChild(s);\r
3504         var values = [ "0",\r
3505                       "0", null, null, null, \r
3506                       "0", "indefinite", null\r
3507                     ];\r
3508         values[7] = 0;\r
3509         check2("dur", "0");\r
3510         check2("begin", "0");\r
3511         values[0] = "1";\r
3512         check2("begin", "1");\r
3513         values[2] = 0;\r
3514         check2("end", "0");\r
3515         values[3] = "0";\r
3516         check2("repeatCount", "0");\r
3517         values[4] = "0";\r
3518         check2("repeatDur", "0");\r
3519         values[5] = "0";\r
3520         check2("min", "0");\r
3521         values[6] = "0";\r
3522         check2("max", "0");\r
3523         values[0] = "12";\r
3524         check2("begin", "12");\r
3525         values[7] = 1000 * base("$frame").fpms;\r
3526         values[1] = "1";\r
3527         check2("dur", "1");\r
3528         function check2(attrName, value) {\r
3529           s.setAttribute(attrName, value);\r
3530           expect(s.hasAttributeNS(null, attrName)).toBeTruthy();\r
3531           attr.push(s);\r
3532           expect(attr.element).toBe(p);\r
3533           var timelines = base("$frame").timelines;\r
3534           var line = timelines[timelines.length-1];\r
3535           expect(line.string).toBe(values[0]);\r
3536           var act = line.$activate;\r
3537           expect(act.dur).toBe(values[1]);\r
3538           expect(act.end).toBe(values[2]);\r
3539           expect(act.repeatCount).toBe(values[3]);\r
3540           expect(act.repeatDur).toBe(values[4]);\r
3541           expect(act.min).toBe(values[5]);\r
3542           expect(act.max).toBe(values[6]);\r
3543           expect(act.simpleDur).toBe(values[7]);\r
3544         };\r
3545       } );\r
3546       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3547       it("should be this for the value (the invalid partion )", function() {\r
3548         var p = document.createElement("g");\r
3549         p.appendChild(s);\r
3550         \r
3551         s.setAttributeNS(null, "begin", "1");\r
3552         attr.push(s);\r
3553         var timelines = base("$frame").timelines;\r
3554         expect(timelines.length).toBe(0);\r
3555         s.setAttributeNS(null, "from", "1");\r
3556         attr.push(s);\r
3557         expect(timelines.length).toBe(1);\r
3558         expect(attr.push(12)).toBeNull();\r
3559       } );\r
3560     } );\r
3561     describe("A setValues method", function() {\r
3562       var attr, s;\r
3563       beforeEach( function() {\r
3564         attr = base("$calcMode").$attribute.up("width");\r
3565         base("$frame").timelines.length = 0;\r
3566         s = document.createElement("animate");\r
3567       } );\r
3568       /*境界条件を調べておく (limit value analysis)*/\r
3569       it("should be this for the value  (limit value analysis)", function() {\r
3570         expect(attr.$from).not.toBeUndefined();\r
3571         expect(attr.setValues()).toBeNull();\r
3572         expect(attr.setValues("")).toBeNull();\r
3573 \r
3574         expect(attr.setValues("0;1")[0].to.string).toBe("1");\r
3575         expect(attr.setValues("0;1")[0].to.from.string).toBe("0");\r
3576         expect(attr.setValues("0;1", "0", "1", "1")[0].to.from.string).toBe("0");\r
3577         expect(attr.setValues("0;1", null, "1", "0")[0].to.from.string).toBe("0"); \r
3578                \r
3579         /*from-to アニメーション*/\r
3580         expect(attr.setValues(null, "0", "1")[0].to.string).toBe("1");\r
3581         expect(attr.setValues(null, "0", "1")[0].to.from.string).toBe("0");\r
3582         \r
3583         /*from-by アニメーション*/\r
3584         expect(attr.setValues(null, "1", null, "1")[0].to.string).toBe("1");\r
3585         expect(attr.setValues(null, "1", null, "1")[0].to.from[0]).toEqual(1);\r
3586         expect(attr.setValues(null, "1", null, "1")[0].to.numList[0]).toEqual(2);\r
3587         \r
3588         /*fromなしto アニメーション*/\r
3589         expect(attr.setValues(null, null, "1")[0].to.string).toBe("1");\r
3590         expect(attr.setValues(null, null, "1")[0].to.from.string).toBe("0");\r
3591         var aset = attr.setValues(null, null, "1")[0].to;\r
3592         aset.call();\r
3593         expect(aset.from[0]).toEqual(0);\r
3594         \r
3595         /*fromなしby アニメーション*/\r
3596         expect(attr.setValues(null, null, null, "1")[0].to.string).toBe("1");\r
3597         expect(attr.setValues(null, null, null, "1")[0].to.from[0]).toEqual(0);\r
3598         var aset = attr.setValues(null, null, null, "1")[0].to;\r
3599         aset.call();\r
3600         expect(aset.from[0]).toEqual(0);\r
3601       } );\r
3602       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3603       it("should be this for the value (the valid partion on a spline mode )", function() {\r
3604         attr.$from.degit = 1;\r
3605         var setv = attr.setValues("0;1")[0].call();\r
3606         expect(setv(0.5)).toBe("0.5");\r
3607         expect(setv(1)).toBe("1.0");\r
3608         \r
3609         setv = attr.setValues(" 0;1; 2 ")[0].call();\r
3610         expect(setv(0.5)).toBe("0.5");\r
3611         expect(setv(1)).toBe("1.0");\r
3612         setv = attr.setValues("0;1;2")[1].call();\r
3613         expect(setv(0.4)).toBe("1.4");\r
3614         expect(setv(1)).toBe("2.0");\r
3615         \r
3616         attr.$from.degit = 2;\r
3617         setv = attr.setValues("1;1;1;1 ;1;15.1")[4].call();\r
3618         expect(setv(0.5)).toBe("8.05");\r
3619         expect(setv(1)).toBe("15.10");\r
3620         \r
3621         var v = attr.setValues("1;1;2;1;1;15.1");\r
3622         setv = v[4].mix( {\r
3623          keyTime: 0.1\r
3624         } ).call();\r
3625         expect(setv(0.05)).toBe("8.05");\r
3626         expect(setv(0.1)).toBe("15.10");\r
3627         setv = v[3].mix( {\r
3628          keyTime: 0.1\r
3629         } ).call();\r
3630         expect(setv(0.01)).toBe("1.00");\r
3631         expect(setv(0.1)).toBe("1.00");\r
3632         setv = v[2].mix( {\r
3633          keyTime: 0.5\r
3634         } ).call();\r
3635         expect(setv(0.25)).toBe("1.50");\r
3636         expect(setv(0.5)).toBe("1.00");\r
3637       } );\r
3638       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3639       it("should be this for the value (the invalid partion on a spline mode )", function() {\r
3640         attr.$from.degit = 1;\r
3641         expect(attr.setValues("")).toBeNull();\r
3642         expect(attr.setValues(null, null, null, null)).toBeNull();\r
3643       } );\r
3644     } );\r
3645     describe("A setKey method", function() {\r
3646       var attr, s;\r
3647       beforeEach( function() {\r
3648         attr = base("$calcMode").$attribute.up("width");\r
3649         base("$frame").timelines.length = 0;\r
3650         s = document.createElement("animate");\r
3651         document.createElement("g").appendChild(s);\r
3652       } );\r
3653       /*境界条件を調べておく (limit value analysis)*/\r
3654       it("should be this for the value  (limit value analysis)", function() {\r
3655         expect(attr.setKey(s)).toBeNull();\r
3656         \r
3657         s.setAttributeNS(null, "from", "0");\r
3658         attr.setKey(s);\r
3659         s.setAttributeNS(null, "to", "0");\r
3660         expect(attr.setKey(s)[0].to.from.string).toBe("0");\r
3661         expect(attr.setKey(s)[0].to.string).toBe("0");\r
3662         s.setAttributeNS(null, "by", "0");\r
3663         attr.setKey(s);\r
3664         s.setAttributeNS(null, "values", "0;2");\r
3665         expect(attr.setKey(s)[0].to.from.string).toBe("0");\r
3666         expect(attr.setKey(s)[0].to.string).toBe("2");\r
3667         \r
3668         s.setAttributeNS(null, "keyTimes", "0;0.1");\r
3669         expect(attr.setKey(s)[0].keyTime).toEqual(0.1);\r
3670         \r
3671         s.setAttributeNS(null, "keySplines", "0,0.1,0.3,0.4");\r
3672         expect(attr.setKey(s)[0].keySplines[0]).toEqual(0);\r
3673         expect(attr.setKey(s)[0].keySplines[1]).toEqual(0.1);\r
3674         expect(attr.setKey(s)[0].keySplines[2]).toEqual(0.3);\r
3675         expect(attr.setKey(s)[0].keySplines[3]).toEqual(0.4);\r
3676       } );\r
3677       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3678       it("should be this for the value (the valid partion on a spline mode )", function() {\r
3679         s.setAttributeNS(null, "values", "0;2;12;30");\r
3680         expect(attr.setKey(s)[0].keyTime.toFixed(3)).toEqual("0.333");\r
3681         s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");\r
3682         expect(attr.setKey(s)[0].keyTime).toEqual(0.1);\r
3683         expect(attr.setKey(s)[1].keyTime).toEqual(0.1);\r
3684         expect(attr.setKey(s)[2].keyTime).toEqual(0.8);\r
3685         s.setAttributeNS(null, "values", " 0; 2;12 ;30 ");\r
3686         s.setAttributeNS(null, "keyTimes", " 0; 0.1; 0.2 ; 1 ");\r
3687         expect(attr.setKey(s)[0].keyTime).toEqual(0.1);\r
3688         expect(attr.setKey(s)[1].keyTime).toEqual(0.1);\r
3689         expect(attr.setKey(s)[2].keyTime).toEqual(0.8);\r
3690         \r
3691         s.setAttributeNS(null, "keySplines", " 0,0.1,0.3,1; 0.1,0.4,0.5,0.7; 0.2,0.2,0.1  , 1 ;");\r
3692         f(0, 0,0.1,0.3,1);\r
3693         f(1, 0.1,0.4,0.5,0.7);\r
3694         f(2, 0.2,0.2,0.1,1);\r
3695         function f (i, a, b, c, d) {\r
3696           var splines = attr.setKey(s)[i].keySplines;\r
3697           expect(splines[0]).toEqual(a);\r
3698           expect(splines[1]).toEqual(b);\r
3699           expect(splines[2]).toEqual(c);\r
3700           expect(splines[3]).toEqual(d);\r
3701         };\r
3702       } );\r
3703       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3704       it("should be this for the value (the invalid partion on a spline mode )", function() {\r
3705         s.setAttributeNS(null, "keyTimes", "0;0.1;0.2;1");\r
3706         expect(attr.setKey(s)).toBeNull();\r
3707         s.setAttributeNS(null, "values", "0;2;12");\r
3708         expect(attr.setKey(s)).toBeNull();\r
3709         s.setAttributeNS(null, "values", "0;2;12;20");\r
3710         s.setAttributeNS(null, "keyTimes", "0;0.1;0.2");\r
3711         expect(attr.setKey(s)).toBeNull();\r
3712       } );\r
3713     } );\r
3714   } );\r
3715   describe("A $setElemenet object", function() {\r
3716     describe("An init method", function() {\r
3717       var $set, ele, frame;\r
3718       beforeEach( function() {\r
3719         $set = base("$calcMode").$attribute.$setElement.up();\r
3720         var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
3721         ele = document.createElementNS("http://www.w3.org/2000/svg", "set");\r
3722         p.appendChild(ele);\r
3723         frame = base("$frame");\r
3724       } );\r
3725       /*境界条件を調べておく (limit value analysis)*/\r
3726       it("should be this for the value  (limit value analysis)", function() {\r
3727         expect($set.to).toBe("");\r
3728         expect($set.attrName).toBe("");\r
3729         expect($set.defaultValue).toBe("");\r
3730         expect($set.isDefault).toBeFalsy();\r
3731         expect($set.attrNameSpace).toBeNull();\r
3732         $set.init();\r
3733         $set.init(ele);\r
3734         expect($set.to).toBe("");\r
3735         expect($set.attrName).toBe("");\r
3736         expect($set.isDefault).toBeFalsy();\r
3737         expect($set.attrNameSpace).toBeNull();\r
3738       } );\r
3739       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3740       it("should be this for the value (the valid partion on a spline mode )", function() {\r
3741         ele.setAttributeNS(null, "to", "t1");\r
3742         $set.init(ele);\r
3743         expect($set.to).toBe("t1");\r
3744         expect($set.attrName).toBe("");\r
3745         expect($set.defaultValue).toBe("");\r
3746 \r
3747         ele.setAttributeNS(null, "attributeName", "tt1");\r
3748         $set.init(ele);\r
3749         expect($set.to).toBe("t1");\r
3750         expect($set.attrName).toBe("tt1");\r
3751         expect($set.defaultValue).toBe("");\r
3752 \r
3753         ele.parentNode.setAttributeNS(null, "tt1", "undef");\r
3754         $set.init(ele);\r
3755         expect($set.defaultValue).toBe("undef");\r
3756         expect($set.isDefault).toBeTruthy();\r
3757 \r
3758         ele.setAttributeNS(null, "attributeName", "font-size");\r
3759         ele.parentNode.style.setProperty("font-size", "12px");\r
3760         $set.init(ele);\r
3761         expect($set.defaultValue).toBe("12px");\r
3762         expect($set.isDefault).toBeFalsy();\r
3763         \r
3764         ele.setAttributeNS(null, "attributeName", "xlink:href");\r
3765         $set.init(ele);\r
3766         expect($set.to).toBe("t1");\r
3767         expect($set.attrName).toBe("xlink:href");\r
3768         expect($set.defaultValue).toBe("");\r
3769         ele.parentNode.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "undef");\r
3770         $set.init(ele);\r
3771         expect($set.attrNameSpace).toBe("http://www.w3.org/1999/xlink");\r
3772       } );\r
3773       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3774       it("should be this for the value (the invalid partion on a spline mode )", function() {\r
3775         $set.init(null);\r
3776         expect($set.to).toBe("");\r
3777         expect($set.attrName).toBe("");\r
3778         expect($set.defaultValue).toBe("");\r
3779 \r
3780         $set.init(12);\r
3781         expect($set.to).toBe("");\r
3782         expect($set.attrName).toBe("");\r
3783         expect($set.defaultValue).toBe("");\r
3784       } );\r
3785     } );\r
3786     describe("Frame Set", function() {\r
3787       var $set, ele, frame;\r
3788       beforeEach( function() {\r
3789         $set = base("$calcMode").$attribute.$setElement.up();\r
3790         var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
3791         ele = document.createElementNS("http://www.w3.org/2000/svg", "set");\r
3792         p.appendChild(ele);\r
3793         frame = base("$frame");\r
3794         frame.timelines.length = 0; //配列の初期化\r
3795         frame.startTime = Date.now();\r
3796         frame.setFrame(0);\r
3797       } );\r
3798       /*境界条件を調べておく (limit value analysis)*/\r
3799       it("should be this for the value  (limit value analysis)", function() {\r
3800         expect($set.isEnd).toBeFalsy();\r
3801         ele.setAttributeNS(null, "dur", "1s");\r
3802         ele.setAttributeNS(null, "attributeName", "fill");\r
3803         ele.setAttributeNS(null, "to", "red");\r
3804         $set.init(ele);\r
3805         frame.setFrame(0);\r
3806         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
3807       } );\r
3808       /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3809       it("should be this for the value (the valid partion)", function() {\r
3810         ele.setAttributeNS(null, "begin", "1s");\r
3811         ele.setAttributeNS(null, "dur", "1s");\r
3812         ele.setAttributeNS(null, "attributeName", "fill");\r
3813         ele.setAttributeNS(null, "to", "red");\r
3814         $set.init(ele);\r
3815         var f = function(num) {\r
3816           frame.setFrame(num);\r
3817           expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBeNull();\r
3818         }\r
3819         f(0);\r
3820         f(1);\r
3821         f(23);\r
3822         frame.setFrame(24);\r
3823         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
3824         frame.setFrame(25);\r
3825         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
3826         f(48);\r
3827         f(49);\r
3828         \r
3829         ele.setAttributeNS(null, "fill", "freeze");\r
3830         $set.init(ele);\r
3831         f(0);\r
3832         f(1);\r
3833         f(23);\r
3834         frame.setFrame(24);\r
3835         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
3836         frame.setFrame(25);\r
3837         expect(ele.parentNode.getAttributeNS(null, "fill")).toBe("red");\r
3838         frame.setFrame(48);\r
3839         expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
3840         frame.setFrame(49);\r
3841         expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
3842         ele.setAttributeNS(null, "begin", "1s");\r
3843         ele.setAttributeNS(null, "attributeName", "fill");\r
3844         ele.setAttributeNS(null, "to", "red");\r
3845         /*eleにはdur属性やendなどが設定されていなくとも、アニメーションが有効*/\r
3846         $set.init(ele);\r
3847         var f = function(num) {\r
3848           frame.setFrame(num);\r
3849           expect(ele.parentNode.getAttributeNS(null, "fill") || null).toBe("red");\r
3850         }\r
3851         f(0);\r
3852         f(1);\r
3853         f(23);\r
3854         f(24);\r
3855         f(25);\r
3856         f(48);      } );\r
3857       /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
3858       it("should be this for the value (the invalid partion)", function() {\r
3859 \r
3860       } );\r
3861     } );\r
3862   } );\r
3863     describe("A $animateElemenet object", function() {\r
3864       describe("An init method", function() {\r
3865         var $animate, ele, frame;\r
3866         beforeEach( function() {\r
3867           $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();\r
3868           var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
3869           ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
3870           p.appendChild(ele);\r
3871           frame = base("$frame");\r
3872           frame.timelines.length = 0;\r
3873           frame.startTime = Date.now();\r
3874           frame.setFrame(0);\r
3875         } );\r
3876         /*境界条件を調べておく (limit value analysis)*/\r
3877         it("should be this for the value  (limit value analysis)", function() {\r
3878           $animate.init();\r
3879           \r
3880           ele.setAttributeNS(null, "begin", "1s");\r
3881           ele.setAttributeNS(null, "dur", "1s");\r
3882           ele.setAttributeNS(null, "attributeName", "d");\r
3883           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
3884           ele.setAttributeNS(null, "to", "M20 20 L10 30");\r
3885           $animate.init(ele);\r
3886           \r
3887           frame.setFrame(0);\r
3888           var p = ele.parentNode;\r
3889           /*getAttributeNSメソッドは、IE11では空文字列を返す(DOM 2に準拠)のに対して、\r
3890            * 他のブラウザではnullを返すため、その対策をする*/\r
3891           expect(p.getAttributeNS(null, "d") || null).toBeNull();\r
3892           \r
3893           function f(fr, result) {\r
3894             frame.setFrame(fr);\r
3895             expect(p.getAttributeNS(null, "d") || "").toBe(result);\r
3896           };\r
3897           \r
3898           f(24, "M20.0 0.0 L20.0 30.0");\r
3899           f(36, "M20.0 10.0 L15.0 30.0");\r
3900           f(48, "");\r
3901                     \r
3902           ele.setAttributeNS(null, "fill", "freeze");\r
3903           $animate.init(ele);\r
3904           f(24, "M20.0 0.0 L20.0 30.0");\r
3905           f(36, "M20.0 10.0 L15.0 30.0");\r
3906           f(48, "M20.0 20.0 L10.0 30.0");\r
3907           \r
3908           frame.timelines.length = 0;\r
3909           ele.setAttributeNS(null, "calcMode", "discrete");\r
3910           $animate.init(ele);\r
3911           expect($animate.mode).toBe("discrete");\r
3912           f(24, "M20 0 L20 30");\r
3913           f(25, "M20 0 L20 30");\r
3914           f(37, "M20 20 L10 30");\r
3915           f(48, "M20 20 L10 30");\r
3916         } );\r
3917         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
3918         it("should be this for the value (the valid partion )", function() {\r
3919           /*24FPSが前提*/\r
3920           ele.setAttributeNS(null, "begin", "0s");\r
3921           ele.setAttributeNS(null, "dur", "100s");\r
3922           ele.setAttributeNS(null, "attributeName", "d");\r
3923           ele.setAttributeNS(null, "fill", "freeze");\r
3924           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
3925           ele.setAttributeNS(null, "to", "M20 2400 L20 30");\r
3926           $animate.init(ele);\r
3927           \r
3928           var p = ele.parentNode;\r
3929           expect(p.getAttributeNS(null, "d") || null).toBeNull();\r
3930           \r
3931           function f(fr, result) {\r
3932             frame.setFrame(fr);\r
3933             expect(p.getAttributeNS(null, "d")).toBe(result);\r
3934           };\r
3935           \r
3936           for (var i=0;i<2400;++i) {\r
3937             f(i, "M20.0 " +i+ ".0 L20.0 30.0");\r
3938           }\r
3939           f(2401, "M20.0 2400.0 L20.0 30.0");\r
3940           \r
3941           \r
3942           frame.timelines.length = 0;\r
3943           ele.setAttributeNS(null, "begin", "0s");\r
3944           ele.setAttributeNS(null, "dur", "1s");\r
3945           ele.setAttributeNS(null, "repeatDur", "2s");\r
3946           ele.setAttributeNS(null, "attributeName", "d");\r
3947           ele.setAttributeNS(null, "fill", "freeze");\r
3948           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
3949           ele.setAttributeNS(null, "to", "M20 24 L20 30");\r
3950           $animate.init(ele);\r
3951           f(23, "M20.0 23.0 L20.0 30.0");\r
3952           f(24, "M20.0 0.0 L20.0 30.0");\r
3953           f(25, "M20.0 1.0 L20.0 30.0");\r
3954           f(48, "M20.0 24.0 L20.0 30.0");\r
3955 \r
3956           frame.timelines.length = 0;\r
3957           ele.setAttributeNS(null, "begin", "0s");\r
3958           ele.setAttributeNS(null, "dur", "2s");\r
3959           ele.setAttributeNS(null, "attributeName", "d");\r
3960           ele.setAttributeNS(null, "fill", "freeze");\r
3961           ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");\r
3962           $animate.init(ele);\r
3963           f(0, "M20.0 0.0 L20.0 30.0");\r
3964           f(1, "M20.0 1.0 L20.0 30.0");\r
3965           f(24, "M20.0 24.0 L20.0 30.0");\r
3966           f(25, "M20.0 24.1 L20.0 30.0");\r
3967           f(47, "M20.0 26.3 L20.0 30.0");\r
3968           f(48, "M20.0 26.4 L20.0 30.0");\r
3969           f(49, "M20.0 26.4 L20.0 30.0");\r
3970           f(50, "M20.0 26.4 L20.0 30.0");\r
3971           \r
3972           frame.timelines.length = 0;\r
3973           ele.setAttributeNS(null, "begin", "0s");\r
3974           ele.setAttributeNS(null, "end", "2s");\r
3975           ele.removeAttributeNS(null, "dur"); //単純継続時間が設定されていない場合\r
3976           ele.removeAttributeNS(null, "repeatDur");\r
3977           ele.setAttributeNS(null, "attributeName", "d");\r
3978           ele.setAttributeNS(null, "fill", "freeze");\r
3979           ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");\r
3980           $animate.init(ele);\r
3981           f(0, "M20.0 0.0 L20.0 30.0");\r
3982           f(1, "M20.0 0.0 L20.0 30.0");\r
3983           f(24, "M20.0 0.0 L20.0 30.0");\r
3984           f(25, "M20.0 0.0 L20.0 30.0");\r
3985           f(47, "M20.0 0.0 L20.0 30.0");\r
3986           f(48, "M20.0 0.0 L20.0 30.0");\r
3987           f(49, "M20.0 0.0 L20.0 30.0");\r
3988           f(50, "M20.0 0.0 L20.0 30.0");\r
3989           \r
3990           frame.timelines.length = 0;\r
3991           ele.setAttributeNS(null, "dur", "2s");\r
3992           ele.setAttributeNS(null, "fill", "remove");\r
3993           var attrValue = p.getAttributeNS(null, "d");\r
3994           $animate.init(ele);\r
3995           f(48, attrValue);\r
3996           \r
3997           frame.timelines.length = 0;\r
3998           p.removeAttributeNS(null, "d");\r
3999           ele.setAttributeNS(null, "fill", "freeze");\r
4000           ele.setAttributeNS(null, "keyTimes", "0;0.1;1");\r
4001           $animate.init(ele);\r
4002           f(1, "M20.0 5.0 L20.0 30.0");\r
4003           f(48, "M20.0 26.4 L20.0 30.0");\r
4004           \r
4005           frame.timelines.length = 0;\r
4006           ele.setAttributeNS(null, "fill", "freeze");\r
4007           ele.setAttributeNS(null, "calcMode", "discrete");\r
4008           ele.setAttributeNS(null, "keyTimes", "0.1;0.5;0.4");\r
4009           $animate.init(ele);\r
4010           f(1, "M20 0 L20 30");\r
4011           f(4, "M20 0 L20 30");\r
4012           f(5, "M20 24 L20 30");\r
4013           f(25, "M20 24 L20 30");\r
4014           f(29, "M20 26.4 L20 30");\r
4015           f(48, "M20 26.4 L20 30");\r
4016           \r
4017           frame.timelines.length = 0;\r
4018           ele.setAttributeNS(null, "calcMode", "spline");\r
4019           ele.removeAttributeNS(null, "keyTimes");\r
4020           ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;.75,0,0,.75");\r
4021           ele.removeAttributeNS(null, "end");\r
4022           ele.setAttributeNS(null, "dur", "9s");\r
4023           ele.setAttributeNS(null, "values", "210;177;121;10");\r
4024           $animate.init(ele);\r
4025           f(0, "210.0");\r
4026           f(72, "177.0");\r
4027           f(144, "121.0");\r
4028           f(216, "10.0");\r
4029           f(300, "10.0");\r
4030           \r
4031           frame.timelines.length = 0;\r
4032           ele.setAttributeNS(null, "calcMode", "spline");\r
4033           ele.setAttributeNS(null, "keyTimes", "0;.25;.5;1");\r
4034           ele.setAttributeNS(null, "keySplines", "0,0,1,1;0,0,1,1;1,0,0,1");\r
4035           ele.setAttributeNS(null, "dur", "8s");\r
4036           ele.setAttributeNS(null, "values", "300;255;180;30");\r
4037           $animate.init(ele);\r
4038           f(0, "300.0");\r
4039           f(48, "255.0");\r
4040           f(96, "180.0");\r
4041           f(192, "30.0");\r
4042           f(300, "30.0");\r
4043           \r
4044         } );\r
4045         /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
4046         it("should be this for the value (the invalid partion )", function() {\r
4047           ele.setAttributeNS(null, "begin", "0s");\r
4048           ele.setAttributeNS(null, "dur", "100s");\r
4049           ele.setAttributeNS(null, "attributeName", "d");\r
4050           ele.setAttributeNS(null, "fill", "freeze");\r
4051           ele.setAttributeNS(null, "from", "M20 0 L20 30");\r
4052           ele.setAttributeNS(null, "to", "M20 2400 L20 30");\r
4053           ele.setAttributeNS(null, "keyTimes", "0;0.1;1");\r
4054           $animate.init(ele);\r
4055           \r
4056           var p = ele.parentNode;\r
4057           expect(p.getAttributeNS(null, "d") || null).toBeNull();\r
4058           \r
4059           function f(fr, result) {\r
4060             frame.setFrame(fr);\r
4061             expect(p.getAttributeNS(null, "d") || null).toBe(result);\r
4062           };\r
4063           f(0, null);\r
4064           f(1, null);\r
4065           \r
4066            frame.timelines.length = 0;\r
4067           /*keyTimes属性のリストの個数がvaluesリストと合致しない*/\r
4068           ele.setAttributeNS(null, "keyTimes", "0;0.1;0.5;1");\r
4069           ele.setAttributeNS(null, "values", "M20 0 L20 30;M20 24 L20 30;M20 26.4 L20 30");\r
4070           $animate.init(ele);\r
4071           f(0, null);\r
4072           f(1, null);\r
4073           \r
4074           frame.timelines.length = 0;\r
4075           ele.setAttributeNS(null, "calcMode", "spline");\r
4076           $animate.init(ele);\r
4077           expect($animate.mode).toBe("spline");\r
4078           f(0, null);\r
4079           f(0.2, null);\r
4080           f(1, null); \r
4081         } );\r
4082       } );\r
4083       describe("RGB Color", function() {\r
4084         var $animate, ele, frame, f;\r
4085         beforeEach( function() {\r
4086           $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();\r
4087           var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
4088           ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
4089           p.appendChild(ele);\r
4090           frame = base("$frame");\r
4091           frame.timelines.length = 0;\r
4092           \r
4093           f = function (fr, result, attr) {\r
4094             frame.setFrame(fr);\r
4095             expect(p.getAttributeNS(null, attr)).toBe(result);\r
4096           };\r
4097         } );\r
4098         /*境界条件を調べておく (limit value analysis)*/\r
4099         it("should be this for the value  (limit value analysis)", function() {\r
4100           ele.setAttributeNS(null, "begin", "0s");\r
4101           ele.setAttributeNS(null, "dur", "1s");\r
4102           ele.setAttributeNS(null, "attributeName", "fill");\r
4103           ele.setAttributeNS(null, "fill", "remove");\r
4104           ele.setAttributeNS(null, "from", "rgb(0, 0, 0)");\r
4105           ele.setAttributeNS(null, "to", "rgb(10, 10, 1)");\r
4106           $animate.init(ele);\r
4107           \r
4108           f(0, "rgb(0, 0, 0)", "fill");\r
4109           f(23, "rgb(10, 10, 1)", "fill");\r
4110           \r
4111           frame.timelines.length = 0;\r
4112           ele.setAttributeNS(null, "attributeName", "stroke");\r
4113           $animate.init(ele);\r
4114           f(0, "rgb(0, 0, 0)", "stroke");\r
4115           f(23, "rgb(10, 10, 1)", "stroke");\r
4116 \r
4117           frame.timelines.length = 0;\r
4118           ele.setAttributeNS(null, "attributeName", "stop-color");\r
4119           $animate.init(ele);\r
4120           f(0, "rgb(0,0,0)", "stop-color");\r
4121           f(23, "rgb(10,10,1)", "stop-color");\r
4122 \r
4123           frame.timelines.length = 0;\r
4124           ele.setAttributeNS(null, "attributeName", "color");\r
4125           $animate.init(ele);\r
4126           f(0, "rgb(0,0,0)", "color");\r
4127           f(23, "rgb(10,10,1)", "color");\r
4128         } );\r
4129         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
4130         it("should be this for the value (the valid partion )", function() {\r
4131           ele.setAttributeNS(null, "begin", "0s");\r
4132           ele.setAttributeNS(null, "dur", "1s");\r
4133           ele.setAttributeNS(null, "attributeName", "fill");\r
4134           ele.setAttributeNS(null, "fill", "remove");\r
4135           ele.setAttributeNS(null, "values", "rgb(0, 0, 0);rgb(24, 2.4, 1)");\r
4136           $animate.init(ele);\r
4137           \r
4138           f(0, "rgb(0, 0, 0)", "fill");\r
4139           f(1, "rgb(1, 0, 0)", "fill");\r
4140           f(23, "rgb(23, 2, 1)", "fill");\r
4141 \r
4142           frame.timelines.length = 0;\r
4143           ele.setAttributeNS(null, "values", "#00083C;#18203C");\r
4144           $animate.init(ele);\r
4145           /*rgb形式に変換*/\r
4146           \r
4147           f(0, "rgb(0, 8, 60)", "fill");\r
4148           f(1, "rgb(1, 9, 60)", "fill");\r
4149           f(23, "rgb(23, 31, 60)", "fill");\r
4150           \r
4151           frame.timelines.length = 0;\r
4152           ele.setAttributeNS(null, "fill", "freeze");\r
4153           ele.setAttributeNS(null, "values", "black;white");\r
4154           $animate.init(ele);\r
4155           /*色キーワードをrgb形式に変換*/\r
4156           \r
4157           f(0, "rgb(0, 0, 0)", "fill");\r
4158           f(12, "rgb(128, 128, 128)", "fill");\r
4159           f(24, "rgb(255, 255, 255)", "fill");\r
4160         } );\r
4161         /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
4162         it("should be this for the value (the invalid partion )", function() {\r
4163           ele.setAttributeNS(null, "begin", "0s");\r
4164           ele.setAttributeNS(null, "dur", "1s");\r
4165           ele.setAttributeNS(null, "attributeName", "fi");\r
4166           ele.setAttributeNS(null, "fill", "remove");\r
4167           ele.setAttributeNS(null, "values", "#00083C;#00107C");\r
4168           $animate.init(ele);\r
4169           /*rgb形式に変換しない*/\r
4170           \r
4171           f(0, "#83.0C", "fi");\r
4172           f(1, "#84.0C", "fi");\r
4173           f(23, "#106.0C", "fi");   \r
4174         } );\r
4175       } );\r
4176     describe("Event", function() {\r
4177       var $animate, ele, frame, p;\r
4178       beforeEach( function() {\r
4179         $animate = base("$calcMode").$attribute.$setElement.$animateElement.up();\r
4180         p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
4181         ele = document.createElementNS("http://www.w3.org/2000/svg", "animate");\r
4182         p.appendChild(ele);\r
4183         frame = base("$frame");\r
4184         frame.timelines.length = 0; //配列の初期化\r
4185         frame.setFrame(0);\r
4186       } );\r
4187       /*境界条件を調べておく (limit value analysis)*/\r
4188       it("should be this for the value  (limit value analysis)", function() {\r
4189         ele.addEventListener("beginEvent", function(evt) {\r
4190           expect(evt.target).toBe(ele);\r
4191         } );\r
4192         var evt = ele.ownerDocument.createEvent("MouseEvents");\r
4193         evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);\r
4194         ele.dispatchEvent(evt);\r
4195         \r
4196         ele.setAttributeNS(null, "begin", "mousedown");\r
4197         ele.setAttributeNS(null, "dur", "1s");\r
4198         ele.setAttributeNS(null, "attributeName", "fill");\r
4199         ele.setAttributeNS(null, "fill", "freeze");\r
4200         ele.setAttributeNS(null, "from", "rgb(0,0,0)");\r
4201         ele.setAttributeNS(null, "to", "rgb(10,10,1)");\r
4202         $animate.init(ele);\r
4203         expect(p.getAttributeNS(null, "fill") || null).toBeNull();\r
4204         evt = ele.ownerDocument.createEvent("MouseEvents");\r
4205         evt.initMouseEvent("beginEvent",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, ele);\r
4206         p.dispatchEvent(evt);\r
4207         expect(p.getAttributeNS(null, "fill") || null).toBeNull();\r
4208         evt = ele.ownerDocument.createEvent("MouseEvents");\r
4209         evt.initMouseEvent("mousedown",true, true, window, 0, 0, 0, 0, 0, false, false, false, false,0, p);\r
4210         p.addEventListener("mousedown", function(evt) {\r
4211           frame.setFrame(frame.currentFrame);\r
4212           expect(evt.target.getAttributeNS(null, "fill") || null).toBe("rgb(0,0,0)");\r
4213         }, false );\r
4214         frame.setFrame(0);\r
4215         p.dispatchEvent(evt);\r
4216       } );\r
4217     } );\r
4218     } );\r
4219 } );\r