From ebb1047e514592ba06559e0b2fd4093214dae1ad Mon Sep 17 00:00:00 2001 From: dhrname Date: Fri, 13 Feb 2015 20:33:47 +0900 Subject: [PATCH] Change a trim method of arguments --- org/w3c/dom/smil.js | 6 ++--- tool/Spec/spec/SvgDomSpec.js | 57 +++++++++++++++----------------------------- 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/org/w3c/dom/smil.js b/org/w3c/dom/smil.js index d7189bb..cc8d86e 100644 --- a/org/w3c/dom/smil.js +++ b/org/w3c/dom/smil.js @@ -202,8 +202,8 @@ base("$frame").mix ( { /*trim メソッド * 文字列中の空白を除去*/ - trim: function() { - return this.string.replace(/[\s\n]+/g, ""); + trim: function(str) { + return str.replace(/[\s\n]+/g, ""); }, /*offset メソッド @@ -258,7 +258,7 @@ base("$frame").mix ( { * また、イベントリスナーに登録をしておく*/ parse: function() { this.begin = 0; - var str = this.trim(), + var str = this.trim(this.string), plusminus = str.search(/[\+\-]/), event = null, ele; diff --git a/tool/Spec/spec/SvgDomSpec.js b/tool/Spec/spec/SvgDomSpec.js index 893801b..2e171ef 100644 --- a/tool/Spec/spec/SvgDomSpec.js +++ b/tool/Spec/spec/SvgDomSpec.js @@ -2138,34 +2138,26 @@ describe("SMIL Animation Spec", function() { begin.string = ""; } ); it("should be this for the value (limit value analysis)", function() { - expect(begin.trim()).toBe(""); - begin.string = " "; - expect(begin.trim()).toBe(""); + delete begin.string; + expect(begin.trim(" ")).toBe(""); expect( function() { - delete begin.string; begin.trim(); } ).toThrow(); } ); /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/ it("should be this for the value (the valid partion)", function() { - begin.string = " hoge "; - expect(begin.trim()).toBe("hoge"); - begin.string = " h o g e "; - expect(begin.trim()).toBe("hoge"); - begin.string = " h o g e "; - expect(begin.trim()).toBe("hoge"); - begin.string = " h o g 12 + e "; - expect(begin.trim()).toBe("hog12+e"); + expect(begin.trim(" hoge ")).toBe("hoge"); + expect(begin.trim(" h o g e ")).toBe("hoge"); + expect(begin.trim(" h o g e ")).toBe("hoge"); + expect(begin.trim(" h o g 12 + e ")).toBe("hog12+e"); } ); /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/ it("should be this for the value (the invalid partion)", function() { expect( function() { - begin.string = 1; - begin.trim(); + begin.trim(1); } ).toThrow(); expect( function() { - begin.string = {}; - begin.trim(); + begin.trim({}); } ).toThrow(); } ); } ); @@ -2176,18 +2168,12 @@ describe("SMIL Animation Spec", function() { } ); /*境界条件を調べておく (limit value analysis)*/ it("should be this for the value (limit value analysis)", function() { - begin.string = " "; - expect(begin.offset(begin.trim())).toEqual(0); - begin.string = " 0 "; - expect(begin.offset(begin.trim())).toEqual(0); - begin.string = "+0ms"; - expect(begin.offset(begin.trim())).toEqual(0); - begin.string = "-0ms"; - expect(begin.offset(begin.trim())).toEqual(0); - begin.string = "1ms"; - expect(begin.offset(begin.trim())).toEqual(1); - begin.string = "-1ms"; - expect(begin.offset(begin.trim())).toEqual(-1); + expect(begin.offset(begin.trim(" "))).toEqual(0); + expect(begin.offset(begin.trim(" 0 "))).toEqual(0); + expect(begin.offset(begin.trim("+0ms"))).toEqual(0); + expect(begin.offset(begin.trim("-0ms"))).toEqual(0); + expect(begin.offset(begin.trim("1ms"))).toEqual(1); + expect(begin.offset(begin.trim("-1ms"))).toEqual(-1); expect(begin.offset("+0s")).toEqual(0); expect(begin.offset("-0s")).toEqual(0); @@ -2217,14 +2203,10 @@ describe("SMIL Animation Spec", function() { } ); /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/ it("should be this for the value (the valid partion)", function() { - begin.string = " + 0 ms"; - expect(begin.offset(begin.trim())).toEqual(0); - begin.string = " -1m s "; - expect(begin.offset(begin.trim())).toEqual(-1); - begin.string = "1000ms"; - expect(begin.offset(begin.trim())).toEqual(1000); - begin.string = " -1212ms"; - expect(begin.offset(begin.trim())).toEqual(-1212); + expect(begin.offset(begin.trim(" + 0 ms"))).toEqual(0); + expect(begin.offset(begin.trim(" -1m s "))).toEqual(-1); + expect(begin.offset(begin.trim("1000ms"))).toEqual(1000); + expect(begin.offset(begin.trim(" -1212ms"))).toEqual(-1212); expect(begin.offset("+100s")).toEqual(100 * 1000); expect(begin.offset("-121s")).toEqual(-121 * 1000); @@ -2268,8 +2250,7 @@ describe("SMIL Animation Spec", function() { } ); /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/ it("should be this for the value (the invalid partion)", function() { - begin.string = " h o g 1e "; - expect(begin.offset(begin.trim())).toEqual(0); + expect(begin.offset(begin.trim(" h o g 1e "))).toEqual(0); expect(begin.offset("ms")).toEqual(0); expect(begin.offset(".s")).toEqual(0); expect(begin.offset("10:")).toEqual(0); -- 2.11.0