svnno****@sourc*****
svnno****@sourc*****
2011年 1月 18日 (火) 23:08:16 JST
Revision: 2309 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2309 Author: dhrname Date: 2011-01-18 23:08:16 +0900 (Tue, 18 Jan 2011) Log Message: ----------- createSVGMatrixメソッドとmultiplyメソッドのチェックを開始 Modified Paths: -------------- trunk/Spec/SvgDomSpec.js Modified: trunk/Spec/SvgDomSpec.js =================================================================== --- trunk/Spec/SvgDomSpec.js 2011-01-17 14:41:02 UTC (rev 2308) +++ trunk/Spec/SvgDomSpec.js 2011-01-18 14:08:16 UTC (rev 2309) @@ -75,6 +75,7 @@ */ describe("SVG Spec in JavaScript", function() { + /*Refer to W3C SVG1.1 (second edition)*/ var doc, svg; beforeEach(function() { /*前もって実行しておく変数(The variable 'doc' is a document node, and the 'svg' is a root element node.)*/ @@ -165,36 +166,81 @@ } t = null; }); - describe("SVG Unit :: SVG Matrix", function() { - var s; - beforeEach(function() { - s = svg.createSVGMatrix(); - }); - it("for the default value on the property of SVGMtrix", function() { - /*See http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement - * The object is initialized to the identity matrix. - */ - expect(s.a).toEqual(1); - expect(s.b).toEqual(0); - expect(s.c).toEqual(0); - expect(s.d).toEqual(1); - expect(s.e).toEqual(0); - expect(s.f).toEqual(0); - }); - /*境界条件を調べておく (limit value analysis)*/ - it("should be this for the value, when it calls a 'multiply' method", function() { - var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, Number.MIN_VALUE/2]; - for (var i=0,tli=t.length;i<tli;++i) { - var n = svg.createSVGMatrix(); - n.a = t[i]; - n.b = t[i]; - n.c = t[i]; - n.d = t[i]; - n.e = t[i]; - s.multiply(n); - } - t = null; - }); + }); + describe("SVG Unit :: SVG Matrix", function() { + var s; + beforeEach(function() { + s = svg.createSVGMatrix(); }); + it("for the default value on the property of SVGMtrix", function() { + /*See http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement + * *The object is initialized to the identity matrix. + *以下では、createSVGElementが単位行列を返しているかどうかをチェック + */ + expect(s.a).toEqual(1); + expect(s.b).toEqual(0); + expect(s.c).toEqual(0); + expect(s.d).toEqual(1); + expect(s.e).toEqual(0); + expect(s.f).toEqual(0); + }); + /*境界条件を調べておく (limit value analysis)*/ + it("should be this for the value, when it calls a 'multiply' method", function() { + var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, Number.MIN_VALUE/2, 0]; + for (var i=0,tli=t.length;i<tli;++i) { + var n = svg.createSVGMatrix(); + n.a = t[i]; + n.b = t[i]; + n.c = t[i]; + n.d = t[i]; + n.e = t[i]; + s.multiply(n); + n = null; + } + t = null; + }); + it("should return the SVGMatrix Object, when it calls a 'multiply' method", function() { + var t = s.multiply(svg.createSVGMatrix()); + expect(t.a).toEqual(1); + expect(t.b).toEqual(0); + expect(t.c).toEqual(0); + expect(t.d).toEqual(1); + expect(t.e).toEqual(0); + expect(t.f).toEqual(0); + /*See http://www.w3.org/TR/SVG/coords.html#InterfaceSVGMatrix + * *..returning the resulting new matrix. + *以下では新しいSVGMatrixオブジェクトを返しているかどうかをチェック + */ + expect(t).toNotBe(s); + }); + /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/ + it("should be this for the value", function() { + var t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく + for (var i=1;i<num;++i) { + t[t.length] = Math.pow(10, i); + t[t.length] = Math.pow(10, -i); + t[t.length] = Math.pow(10, i); + t[t.length] = Math.pow(10, -i); + } + for (var i=0,tli=t.length;i<tli;++i) { + var n = svg.createSVGMatrix(), ti = t[i]; + n.a = ti; + n.b = ti; + n.c = ti; + n.d = ti; + n.e = ti; + n.f = ti; + var d = n.multiply(s); + /*注:sが単位行列であることに注意すること (Note that the variable 's' is a identity matrix)*/ + expect(d.a).toEqual(ti); + expect(d.b).toEqual(ti); + expect(d.c).toEqual(ti); + expect(d.d).toEqual(ti); + expect(d.e).toEqual(ti); + expect(d.f).toEqual(ti); + n = d = null; + } + t = null; + }); }); }); \ No newline at end of file