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
} );\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