[Sie-announce] SIEコード [2341] inverseメソッドについての有効値クラスのテストを追加

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 1月 28日 (金) 23:18:36 JST


Revision: 2341
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2341
Author:   dhrname
Date:     2011-01-28 23:18:36 +0900 (Fri, 28 Jan 2011)

Log Message:
-----------
inverseメソッドについての有効値クラスのテストを追加

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

Modified: trunk/Spec/spec/SvgDomSpec.js
===================================================================
--- trunk/Spec/spec/SvgDomSpec.js	2011-01-27 14:15:48 UTC (rev 2340)
+++ trunk/Spec/spec/SvgDomSpec.js	2011-01-28 14:18:36 UTC (rev 2341)
@@ -313,5 +313,64 @@
       }
       si = t = null;
     });
+    /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/
+    it("should be this for the value, when it calls a 'inverse' method", function() {
+      var si = s.inverse(), t = [];
+      s.a = -1;
+      s.e = 0;
+      s.f = 1;
+      si = s.inverse();
+      t[t.length] = s.multiply(si);
+      t[t.length] = si.multiply(s);
+      s.a = 1;
+      s.d = -1;
+      s.e = 10000;
+      s.f = -10000;
+      si = s.inverse();
+      t[t.length] = s.multiply(si);
+      t[t.length] = si.multiply(s);
+      s.b = -1;
+      s.c = 1;
+      s.d = 1;
+      s.e = 0.0001;
+      s.f = -0.0001;
+      si = s.inverse();
+      t[t.length] = s.multiply(si);
+      t[t.length] = si.multiply(s);
+      s.b = 1;
+      s.c = -1;
+      s.e = 0.1;
+      s.f = 1;
+      si = s.inverse();
+      t[t.length] = s.multiply(si);
+      t[t.length] = si.multiply(s);
+      for (var i=0;i<t.length;++i) {
+        var d = t[i];
+        expect(d.a).toEqual(1);
+        expect(d.b).toEqual(0);
+        expect(d.c).toEqual(0);
+        expect(d.d).toEqual(1);
+        expect(d.e).toEqual(0);
+        expect(d.f).toEqual(0);
+        console.log(d);
+        d = null;
+      }
+      si = t = null;
+    });
+    it("should throw an Error, when it calls a 'inverse' method", function() {
+      /*以下では行列式が0なので、逆行列が成り立たない (it is invalid in these cases because the determint is zero)*/
+      var t = [1, 1, 1, 1,
+               0, 0, 0, 0,
+               2, 4, 2, 4,
+               2.5, -1, 2.5, -1];
+      for (var i=0;i<t.length;i+=4) {
+        s.a = t[i];
+        s.b = t[i+1];
+        s.c = t[i+2];
+        s.d = t[i+3]
+      };
+      expect(s.inverse).toThrow();
+      t = null;
+    });
   });
 });
\ No newline at end of file




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