numList: function() {\r
var s = this.string.match(/[\-\+]?[\d\.]+(?:[eE][\-\+]?[\d\.]+)?/g);\r
if (s) {\r
+ /*mapメソッドで代用してもよい*/\r
for (var i=0;i<s.length;++i) {\r
s[i] = parseFloat(s[i]);\r
}\r
}\r
\r
} )\r
- .mix( {\r
- advance: function() {\r
- return "";\r
+ .mix( { \r
+ /*advance メソッド\r
+ * アニメーションの進行具合を示す進捗率 t (0 <= t <= 1)をもとに、現在の呈示値を算出するためのもの*/\r
+ advance: function(t) {\r
+ if ( (t < 0) || (1 < t)) {\r
+ throw new Error("An Invalid Number Error");\r
+ }\r
+ if (!this.string || !this.from) {\r
+ return "";\r
+ }\r
+ var str = "";\r
+ for (var i=0,nuli=this.numList.length;i<nuli;++i) {\r
+ /*$fromと$toを、原点Oから伸びる二つのベクトル (n次空間のベクトル)と考え、\r
+ * そのベクトルの端同士を結ぶ線上の点Pをベクトルの計算から求める*/\r
+ str += ( t * this.numList[i] + (1 - t) * this.from.numList[i] );\r
+ this.strList && ( str += this.strList[i] );\r
+ }\r
+ return str;\r
}\r
} )\r
- .up("$to");\r
+ /*fromプロパティの初期化*/\r
+ .up("$to").from = null;\r
//#endif // _SMIL_IDL_\r
it("should be this for the value (limit value analysis)", function() {\r
expect(from.advance()).toBe("");\r
expect(from.$to.advance()).toBe("");\r
+ expect(from.$to.advance(0)).toBe("");\r
+ expect(from.$to.advance(1)).toBe("");\r
+ expect(function(){\r
+ from.$to.advance(1.01);\r
+ }).toThrow("An Invalid Number Error");\r
+ expect(function(){\r
+ from.$to.advance(-0.01);\r
+ }).toThrow("An Invalid Number Error");\r
+ \r
+ from.string = "0";\r
+ from.$to.string = "1";\r
+ expect(from.$to.call()).toBe(from.$to);\r
+ expect(from.$to.numList[0]).toEqual(1);\r
+ expect(from.$to.strList).toBeNull();\r
+ expect(from.call()).toBe(from.$to);\r
+ expect(from.numList[0]).toEqual(0);\r
+ expect(from.strList).toBeNull();\r
+ expect(from.advance(0)).toBe("");\r
+ expect(from.$to.from).toBe(from);\r
+ expect(from.$to.advance(0)).toBe("0"); \r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
it("should be this for the value (the valid partion)", function() {\r
+ from.string = "0s";\r
+ from.$to.string = "1s";\r
+ expect(from.$to.call()).toBe(from.$to);\r
+ expect(from.$to.numList[0]).toEqual(1);\r
+ expect(from.$to.strList[0]).toEqual("s");\r
+ expect(from.call()).toBe(from.$to);\r
+ expect(from.numList[0]).toEqual(0);\r
+ expect(from.strList[0]).toEqual("s");\r
+ expect(from.advance(0)).toBe("");\r
+ expect(from.$to.from).toBe(from);\r
+ expect(from.$to.advance(0)).toBe("0s"); \r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion)", function() {\r
+ expect(function(){\r
+ from.$to.advance(10);\r
+ }).toThrow("An Invalid Number Error");\r
+ expect(function(){\r
+ from.$to.advance(-10);\r
+ }).toThrow("An Invalid Number Error");\r
} );\r
} )\r
} );\r