}\r
\r
} )\r
- .mix( { \r
+ .mix( {\r
+ /*advanceメソッドで使われる有効数字の桁数 (小数点の桁数を決めるときに使う)*/\r
+ degit: 0,\r
+ \r
/*advance メソッド\r
* アニメーションの進行具合を示す進捗率 t (0 <= t <= 1)をもとに、現在の呈示値を算出するためのもの\r
* callメソッドが前もって呼び出されていることが前提となる*/\r
var str = "",\r
numList = this.numList,\r
strList = this.strList,\r
- fromNumList = this.from.numList;\r
+ fromNumList = this.from.numList,\r
+ deg = this.degit;\r
for (var i=0,nuli=numList.length;i<nuli;++i) {\r
/*$fromと$toを、原点Oからの二つのベクトル (n次空間のベクトル)と考える*/\r
- str += ( t * numList[i] + (1 - t) * fromNumList[i] );\r
+ str += ( t * numList[i] + (1 - t) * fromNumList[i] ).toFixed(deg);\r
strList && ( str += strList[i+1] );\r
}\r
/*文字列はcallメソッドにより、a0aのパターンになっているので、aの部分を追加*/\r
str = (strList ? strList[0] : "") + str;\r
- numList = strList = fromNumList = i = nuli = void 0;\r
+ numList = strList = fromNumList = i = nuli = deg = void 0;\r
return str;\r
}\r
} )\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
it("should be this for the value (the valid partion)", function() {\r
+ var deg = 3;\r
+ \r
from.string = "0s";\r
from.$to.string = "1s";\r
expect(from.$to.call()).toBe(from.$to.numList);\r
expect(from.advance(0)).toBe("");\r
expect(from.$to.from).toBe(from);\r
expect(from.$to.advance(0)).toBe("0s");\r
+ from.$to.degit = deg;\r
for (var i=0;i<1;i+=0.01) {\r
- expect(from.$to.advance(i)).toBe(i+"s");\r
+ expect(from.$to.advance(i)).toBe(i.toFixed(deg)+"s");\r
}\r
\r
from = base("$from").up();\r
expect(from.advance(0)).toBe("");\r
expect(from.$to.from).toBe(from);\r
expect(from.$to.advance(0)).toBe("a0s");\r
+\r
+ from.$to.degit = deg;\r
for (var i=0;i<1;i+=0.01) {\r
- expect(from.$to.advance(i)).toBe("a" +i+ "s");\r
+ expect(from.$to.advance(i)).toBe("a" +i.toFixed(deg)+ "s");\r
}\r
+ \r
+ from = base("$from").up();\r
+ from.up("$to");\r
+ from.string = "a-10s1.5";\r
+ from.$to.string = "a10s-3";\r
+ from.$to.call();\r
+ from.call();\r
+ from.$to.degit = 1;\r
+ expect(from.$to.advance(0)).toEqual("a-10.0s1.5");\r
+ expect(from.$to.advance(0.4)).toEqual("a-2.0s-0.3");\r
+ expect(from.$to.advance(1)).toEqual("a10.0s-3.0");\r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion)", function() {\r