OSDN Git Service

New a parse method in the object
authordhrname <dhrname@users.sourceforge.jp>
Mon, 2 Feb 2015 14:28:00 +0000 (23:28 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Mon, 2 Feb 2015 14:28:00 +0000 (23:28 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 79d20e6..77c3b4d 100644 (file)
@@ -195,6 +195,9 @@ base("$frame").mix ( {
     /*開始時刻やタイミングが書かれた文字列*/\r
     string: "",\r
 \r
+    /*イベントやindefinteで未解決かどうか*/\r
+    isResolved: false,\r
+\r
     /*trim メソッド\r
      * 文字列中の空白を除去*/\r
     trim: function() {\r
@@ -215,6 +218,7 @@ base("$frame").mix ( {
       plusminus = _float = sec = min = h = void 0;\r
       return s;\r
       \r
+      /*00:00:0と00:0と、0sなどの文字列をミリ秒へ変換*/\r
       function sec() {\r
         return  ( 1000*( _float(str.match(/[\d.]+s$/) || "0") || _float(str.match(/[\d.]+$/) || "0") ) );\r
       };\r
@@ -245,6 +249,29 @@ base("$frame").mix ( {
           event: str\r
         };\r
       }\r
+    },\r
+    \r
+    /*parse メソッド\r
+     * stringプロパティを解析して、時刻を算出し、結果を$frame::beginプロパティに出力*/\r
+    parse: function() {\r
+      this.begin = 0;\r
+      var str = this.trim(),\r
+          plusminus = str.search(/[\+\-]/),\r
+          event = "";\r
+      if (plusminus > 0) {\r
+        /*Event-Value +/- Clock-Value の場合*/\r
+        this.begin = this.offset( str.slice(plusminus) );\r
+        event = this.event(str);\r
+      } else if ( /[^\+\-\d]/.test(str.charAt(0)) ) {\r
+        /*Event-Valuen のみの場合*/\r
+        event = this.event(str);\r
+      } else {\r
+        /*+/- Clock-Value のみの場合*/\r
+        this.begin = this.offset( str );\r
+        /*イベントもindefiniteもないので、解決済みと考える*/\r
+        this.isResolved = true;\r
+      }\r
+      return this;\r
     }\r
   } );\r
 } );\r
index 28ee4de..856c58c 100644 (file)
@@ -2118,6 +2118,7 @@ describe("SMIL Animation Spec", function() {
     /*境界条件を調べておく (limit value analysis)*/\r
     it("should be this for the value  (limit value analysis)", function() {\r
       expect(begin.string).toBe("");\r
+      expect(begin.isResolved).toBeFalsy();\r
     } );\r
     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
     it("should be this for the value (the valid partion)", function() {\r
@@ -2314,7 +2315,43 @@ describe("SMIL Animation Spec", function() {
         expect(evt.event).toBe("");\r
         evt = begin.event("id.");\r
         expect(evt.id).toBe("");\r
-        expect(evt.event).toBe("");      } );\r
+        expect(evt.event).toBe("");\r
+      } );\r
+    } );\r
+    \r
+    describe("An parse method in $begin object", function() {\r
+       beforeEach( function() {\r
+        begin.string = "";\r
+      } );\r
+      /*境界条件を調べておく (limit value analysis)*/\r
+      it("should be this for the value  (limit value analysis)", function() {\r
+        expect(begin.parse().begin).toEqual(0);\r
+        begin.string="+0";\r
+        expect(begin.parse().begin).toEqual(0);\r
+        begin.string = "+1";\r
+        expect(begin.parse().begin).toEqual(1000);\r
+        begin.string = " ";\r
+        expect(begin.parse().begin).toEqual(0);\r
+        begin.string = "1";\r
+        expect(begin.parse().begin).toEqual(1000);\r
+        begin.string = "+1ms";\r
+        expect(begin.parse().begin).toEqual(1);\r
+        begin.string = "-1ms";\r
+        expect(begin.parse().begin).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
+        begin.string = " 1 0 0 m s";\r
+        expect(begin.parse().begin).toEqual(100);\r
+        begin.string = "ms";\r
+        begin.isResolved = false;\r
+        expect(begin.parse().begin).toEqual(0);\r
+        expect(begin.isResolved).toBeFalsy();\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
     } );\r
   } );\r
 } )\r