[Sie-announce] SIEコード [2345] SVGMatrixにおいて、さまざまなメソッドのスペックを書いておいた

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 1月 30日 (日) 22:16:50 JST


Revision: 2345
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2345
Author:   dhrname
Date:     2011-01-30 22:16:50 +0900 (Sun, 30 Jan 2011)

Log Message:
-----------
SVGMatrixにおいて、さまざまなメソッドのスペックを書いておいた

Modified Paths:
--------------
    trunk/Spec/spec/SvgDomSpec.js

Modified: trunk/Spec/spec/SvgDomSpec.js
===================================================================
--- trunk/Spec/spec/SvgDomSpec.js	2011-01-30 12:05:05 UTC (rev 2344)
+++ trunk/Spec/spec/SvgDomSpec.js	2011-01-30 13:16:50 UTC (rev 2345)
@@ -352,7 +352,6 @@
         expect(d.d).toEqual(1);
         expect(d.e).toEqual(0);
         expect(d.f).toEqual(0);
-        console.log(d);
         d = null;
       }
       si = t = null;
@@ -372,5 +371,189 @@
       expect(s.inverse).toThrow();
       t = null;
     });
+    /*併進変換に関する境界条件を調べておく (limit value analysis about the 'translate')*/
+    it("should be this for the value, when it calls the 'translate' method", function() {
+      var t = [0, 0,
+               -1, 0,
+               1, -1,
+               Number.MAX_VALUE, Number.MIN_VALUE];
+      for (var i=0;i<t.length;i+=2) {
+        var d = s.translate(t[i], t[i+1]);
+        expect(d.a).toEqual(1);
+        expect(d.b).toEqual(0);
+        expect(d.c).toEqual(0);
+        expect(d.d).toEqual(1);
+        expect(d.e).toEqual(t[i]);
+        expect(d.f).toEqual(t[i+1]);
+        expect(d).toNotBe(s);
+      }      
+    });
+    /*伸縮変換に関する境界条件を調べておく (limit value analysis about the 'scale')*/
+    it("should be this for the value, when it calls the 'scale' method", function() {
+      var t = [0,
+               -1,
+               1,
+               Number.MAX_VALUE,
+               Number.MIN_VALUE];
+      for (var i=0;i<t.length;i+=2) {
+        var d = s.scale(t[i]);
+        expect(d.a).toEqual(t[i]);
+        expect(d.b).toEqual(0);
+        expect(d.c).toEqual(0);
+        expect(d.d).toEqual(t[i]);
+        expect(d.e).toEqual(0);
+        expect(d.f).toEqual(0);
+        expect(d).toNotBe(s);
+      }      
+    });
+    /*比率の違う伸縮変換に関する境界条件を調べておく (limit value analysis about the 'scaleNonUniform')*/
+    it("should be this for the value, when it calls the 'scaleNonUniform' method", function() {
+      var t = [0, 0,
+               -1, 0,
+               1, -1,
+               Number.MAX_VALUE, Number.MIN_VALUE];
+      for (var i=0;i<t.length;i+=2) {
+        var d = s.scaleNonUniform(t[i], t[i+1]);
+        expect(d.a).toEqual(t[i]);
+        expect(d.b).toEqual(0);
+        expect(d.c).toEqual(0);
+        expect(d.d).toEqual(t[i+1]);
+        expect(d.e).toEqual(0);
+        expect(d.f).toEqual(0);
+        expect(d).toNotBe(s);
+      }      
+    });
+    /*回転変換に関する境界条件を調べておく (limit value analysis about the 'rotate')*/
+    it("should be this for the value, when it calls the 'rotate' method", function() {
+      var t = [0,
+               -1,
+               1,
+               Number.MAX_VALUE,
+               Number.MIN_VALUE];
+      for (var i=0;i<t.length;i+=2) {
+        var d = s.rotate(t[i]);
+        expect(d.a).toEqual(Math.cos(t[i] / 180 * Math.PI));
+        expect(d.b).toEqual(Math.sin(t[i] / 180 * Math.PI));
+        expect(d.c).toEqual(-Math.sin(t[i] / 180 * Math.PI));
+        expect(d.d).toEqual(Math.cos(t[i] / 180 * Math.PI));
+        expect(d.e).toEqual(0);
+        expect(d.f).toEqual(0);
+        expect(d).toNotBe(s);
+      }      
+    });
+    /*座標指定による回転変換に関する境界条件を調べておく (limit value analysis about the 'rotateFromVector')*/
+    it("should be this for the value, when it calls the 'rotateFromVector'", function() {
+      /*IE8において、Number.MIN_VALUEを2で割ると0となるバグがある (There's a bug that Number.MIN_VALUE/2 is zero in IE8)*/
+      var t = [1, 1,
+               -1, -1,
+               1, -1,
+               -1, 1,
+               Number.MAX_VALUE, Number.MIN_VALUE];
+      for (var i=0;i<t.length;i+=2) {
+        var d = s.rotateFromVector(t[i], t[i+1]);
+        expect(d.a).toEqual(Math.cos(Math.atan2(t[i+1], t[i])));
+        expect(d.b).toEqual(Math.sin(Math.atan2(t[i+1], t[i])));
+        expect(d.c).toEqual(-Math.sin(Math.atan2(t[i+1], t[i])));
+        expect(d.d).toEqual(Math.cos(Math.atan2(t[i+1], t[i])));
+        expect(d.e).toEqual(0);
+        expect(d.f).toEqual(0);
+        expect(d).toNotBe(s);
+      }      
+    });
+    /*座標指定による回転変換に関して同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/
+    it("should throw an SVG Invalid Value Error, when it calls the 'rotateFromVector' method", function() {
+      var t = [0,
+               Number.NEGATIVE_INFINITY,
+               Number.POSITIVE_INFINITY,
+               Number.NaN,
+               undefined];
+      for (var i=0;i<t.length;++i) {
+        var f = function() {
+          var d = s.rotateFromVector(t[i], 1);
+        }
+        expect(f).toThrow();
+        f = function() {
+          var d = s.rotateFromVector(1, t[i]);
+        }
+        expect(f).toThrow();
+      }
+      t = f = null;
+    });
+    /*x軸によって向き合わせとなる変換に関する境界条件を調べておく (limit value analysis about the 'flipX')*/
+    it("should be this for the value, when it calls the 'flipX' method", function() {
+      var t = [0,
+               -1,
+               1,
+               Number.MAX_VALUE,
+               Number.MIN_VALUE];
+      for (var i=0;i<t.length;++i) {
+        s.a = t[i];
+        s.d = t[i];
+        var d = s.flipX();
+        expect(d.a).toEqual(-t[i]);
+        expect(d.b).toEqual(0);
+        expect(d.c).toEqual(0);
+        expect(d.d).toEqual(t[i]);
+        expect(d.e).toEqual(0);
+        expect(d.f).toEqual(0);
+        expect(d).toNotBe(s);
+      }      
+    });
+    /*y軸によって向き合わせとなる変換に関する境界条件を調べておく (limit value analysis about the 'flipY')*/
+    it("should be this for the value, when it calls the 'flipY' method", function() {
+      var t = [0,
+               -1,
+               1,
+               Number.MAX_VALUE,
+               Number.MIN_VALUE];
+      for (var i=0;i<t.length;++i) {
+        s.a = t[i];
+        s.d = t[i];
+        var d = s.flipY();
+        expect(d.a).toEqual(t[i]);
+        expect(d.b).toEqual(0);
+        expect(d.c).toEqual(0);
+        expect(d.d).toEqual(-t[i]);
+        expect(d.e).toEqual(0);
+        expect(d.f).toEqual(0);
+        expect(d).toNotBe(s);
+      }      
+    });
+    /*横の傾き変換に関する境界条件を調べておく (limit value analysis about the 'skewX')*/
+    it("should be this for the value, when it calls the 'skewX' method", function() {
+      var t = [0,
+               -1,
+               1,
+               Number.MAX_VALUE,
+               Number.MIN_VALUE];
+      for (var i=0;i<t.length;i+=2) {
+        var d = s.skewX(t[i]);
+        expect(d.a).toEqual(1);
+        expect(d.b).toEqual(0);
+        expect(d.c).toEqual(Math.tan(t[i] / 180 * Math.PI));
+        expect(d.d).toEqual(1);
+        expect(d.e).toEqual(0);
+        expect(d.f).toEqual(0);
+        expect(d).toNotBe(s);
+      }      
+    });
+    /*縦の傾き変換に関する境界条件を調べておく (limit value analysis about the 'skewY')*/
+    it("should be this for the value, when it calls the 'skewY' method", function() {
+      var t = [0,
+               -1,
+               1,
+               Number.MAX_VALUE,
+               Number.MIN_VALUE];
+      for (var i=0;i<t.length;i+=2) {
+        var d = s.skewY(t[i]);
+        expect(d.a).toEqual(1);
+        expect(d.b).toEqual(Math.tan(t[i] / 180 * Math.PI));
+        expect(d.c).toEqual(0);
+        expect(d.d).toEqual(1);
+        expect(d.e).toEqual(0);
+        expect(d.f).toEqual(0);
+        expect(d).toNotBe(s);
+      }      
+    });
   });
 });
\ No newline at end of file




Sie-announce メーリングリストの案内
Back to archive index