OSDN Git Service

Add a distance method of the object
authordhrname <dhrname@users.sourceforge.jp>
Thu, 5 Mar 2015 13:27:16 +0000 (22:27 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Thu, 5 Mar 2015 13:27:16 +0000 (22:27 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 767a4f0..b24eaaf 100644 (file)
@@ -520,7 +520,22 @@ base("$from").of( {
       str = (strList ? strList[0] : "") + str;\r
       numList = strList = fromNumList = i = nuli = deg = void 0;\r
       return str;\r
-    }\r
+    },\r
+    \r
+    /*distanceメソッド\r
+     * fromベクトルから自分自身のベクトルへの距離 (ノルム)の数値を返す。callメソッドを使うので注意すること*/\r
+     distance: function(from) {\r
+       if (!from) {\r
+          return 0;\r
+       }\r
+       var toList = this.call(),\r
+           fromList = from.call(),\r
+           s = 0;\r
+       for (var i=0, tli=toList.length; i<tli; ++i) {\r
+         s += toList[i]*toList[i] - fromList[i]*fromList[i];\r
+       }\r
+       return s;\r
+     }\r
   } )\r
   /*fromプロパティの初期化*/\r
  .up("$to").from = null;\r
index a1d1b82..a0b7a17 100644 (file)
@@ -3054,6 +3054,30 @@ describe("SMIL Animation Spec", function() {
       } );\r
     } )\r
   } );\r
+   describe("A distance method", function() {\r
+      var from = base("$from");\r
+       beforeEach( function() {\r
+         from = base("$from").up();\r
+         from.string = "";\r
+         from.up("$to");\r
+       } );\r
+      /*境界条件を調べておく (limit value analysis)*/\r
+      it("should be this for the value  (limit value analysis)", function() {\r
+        expect(from.distance()).toEqual(0)\r
+        expect(from.$to.distance()).toEqual(0);\r
+        \r
+        from.string = "0";\r
+        from.$to.string = "1";\r
+        expect(from.distance()).toEqual(0);\r
+        expect(from.$to.distance(from)).toEqual(1);\r
+      } );\r
+      /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+      it("should be this for the value (the valid partion)", function() {\r
+      } );\r
+      /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+      it("should be this for the value (the invalid partion)", function() {\r
+      } );\r
+   } );\r
   describe("A $calcMode object", function() {\r
     var calc = base("$calcMode"),\r
         from = base("$from");\r