OSDN Git Service

Support the Spec for object
authordhrname <dhrname@users.sourceforge.jp>
Sat, 31 Jan 2015 11:38:49 +0000 (20:38 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sat, 31 Jan 2015 11:38:49 +0000 (20:38 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 9a80cc0..ba52a7b 100644 (file)
@@ -197,6 +197,7 @@ base("$frame").mix ( {
       return this.string.replace(/[\s\n]+/g, "");\r
     },\r
     offset: function(str) {\r
+      str = str || "0";\r
       var plusminus = str.charAt(0),\r
           s =  ms() + sec() + min() + h();\r
       if (plusminus === "-") {\r
@@ -206,18 +207,18 @@ base("$frame").mix ( {
       return s;\r
       \r
       function ms() {\r
-        var deg = str.match(/\d+ms$/) || "0";\r
+        var deg = str.match(/[\d.]+ms$/) || "0";\r
         return ( parseFloat(deg) );\r
       };\r
       function sec() {\r
-        var deg = str.match(/:\d+$/) || "0",\r
-            de = str.match(/\d+s$/) || "0",\r
-            d = str.match(/\d+$/) || "0";\r
+        var deg = str.match(/:[\d.]+$/) || "0",\r
+            de = str.match(/[\d.]+s$/) || "0",\r
+            d = str.match(/[\d.]+$/) || "0";\r
         return  ( 1000*( parseFloat(deg) || parseFloat(de) || parseFloat(d) ) );\r
       };\r
       function min() {\r
         var deg = str.match(/:\d\d:/) || "0",\r
-            de = str.match(/\d+min$/) || "0",\r
+            de = str.match(/[\d.]+min$/) || "0",\r
             d = str.match(/\d\d:[^:]+$/) || "0";\r
         return ( 60000*( parseFloat(deg) || parseFloat(de) || parseFloat(d) ) );\r
       };\r
index bff0cf8..219e356 100644 (file)
@@ -2117,36 +2117,139 @@ describe("SMIL Animation Spec", function() {
     var begin = base("$frame").$begin;\r
     /*境界条件を調べておく (limit value analysis)*/\r
     it("should be this for the value  (limit value analysis)", function() {\r
-      expect(begin.trim()).toBe("");\r
-      begin.string = " ";\r
-      expect(begin.trim()).toBe("");\r
-      expect(begin.offset(begin.trim())).toEqual(0);\r
-      begin.string = "+0ms";\r
-      expect(begin.offset(begin.trim())).toEqual(0);\r
-      begin.string = "-0ms";\r
-      expect(begin.offset(begin.trim())).toEqual(0);\r
-      begin.string = "1ms";\r
-      expect(begin.offset(begin.trim())).toEqual(1);\r
-      begin.string = "-1ms";\r
-      expect(begin.offset(begin.trim())).toEqual(-1);\r
+      expect(begin.string).toBe("");\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 = " hoge ";\r
-      expect(begin.trim()).toBe("hoge");\r
-      begin.string = " h o g e ";\r
-      expect(begin.trim()).toBe("hoge");\r
-       begin.string = " h  o  g     e ";\r
-      expect(begin.trim()).toBe("hoge");\r
-      \r
-      expect(begin.offset(begin.trim())).toEqual(0);\r
+      expect(begin.string).toBe(" hoge ");\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
-        delete begin.string;\r
+\r
+    } );\r
+    \r
+    describe("A trim method in $begin object", function() {\r
+      /*境界条件を調べておく (limit value analysis)*/\r
+      beforeEach( function() {\r
+        begin.string = "";\r
+      } );\r
+      it("should be this for the value  (limit value analysis)", function() {\r
+        expect(begin.trim()).toBe("");\r
+        begin.string = " ";\r
+        expect(begin.trim()).toBe("");\r
+        expect( function() {\r
+          delete begin.string;\r
+          begin.trim();\r
+        } ).toThrow();\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 = " hoge ";\r
+        expect(begin.trim()).toBe("hoge");\r
+        begin.string = " h o g e ";\r
+        expect(begin.trim()).toBe("hoge");\r
+        begin.string = " h  o  g     e ";\r
         expect(begin.trim()).toBe("hoge");\r
-      } ).toThrow();\r
+        begin.string = "   h  o  g    12 +  e   ";\r
+        expect(begin.trim()).toBe("hog12+e");\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
+          begin.string = 1;\r
+          begin.trim();\r
+        } ).toThrow();\r
+        expect( function() {\r
+          begin.string = {};\r
+          begin.trim();\r
+        } ).toThrow();\r
+      } );\r
+    } );\r
+\r
+    describe("An offset 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
+        begin.string = " ";\r
+        expect(begin.offset(begin.trim())).toEqual(0);\r
+        begin.string = " 0 ";\r
+        expect(begin.offset(begin.trim())).toEqual(0);\r
+        begin.string = "+0ms";\r
+        expect(begin.offset(begin.trim())).toEqual(0);\r
+        begin.string = "-0ms";\r
+        expect(begin.offset(begin.trim())).toEqual(0);\r
+        begin.string = "1ms";\r
+        expect(begin.offset(begin.trim())).toEqual(1);\r
+        begin.string = "-1ms";\r
+        expect(begin.offset(begin.trim())).toEqual(-1);\r
+\r
+        expect(begin.offset("+0s")).toEqual(0);\r
+        expect(begin.offset("-0s")).toEqual(0);\r
+        expect(begin.offset("1s")).toEqual(1000);\r
+        expect(begin.offset("-1s")).toEqual(-1000);\r
+\r
+        expect(begin.offset("+0min")).toEqual(0);\r
+        expect(begin.offset("-0min")).toEqual(0);\r
+        expect(begin.offset("1min")).toEqual(60000);\r
+        expect(begin.offset("-1min")).toEqual(-60000);\r
+\r
+        expect(begin.offset("+0h")).toEqual(0);\r
+        expect(begin.offset("-0h")).toEqual(0);\r
+        expect(begin.offset("1h")).toEqual(60*60*1000);\r
+        expect(begin.offset("-1h")).toEqual(-3600000);\r
+\r
+        expect(begin.offset()).toEqual(0);\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 = " + 0 ms";\r
+        expect(begin.offset(begin.trim())).toEqual(0);\r
+        begin.string = " -1m s ";\r
+        expect(begin.offset(begin.trim())).toEqual(-1);\r
+        begin.string = "1000ms";\r
+        expect(begin.offset(begin.trim())).toEqual(1000);\r
+        begin.string = " -1212ms";\r
+        expect(begin.offset(begin.trim())).toEqual(-1212);\r
+\r
+        expect(begin.offset("+100s")).toEqual(100 * 1000);\r
+        expect(begin.offset("-121s")).toEqual(-121 * 1000);\r
+        expect(begin.offset("1.25s")).toEqual(1.25 * 1000);\r
+        expect(begin.offset("-0.20s")).toEqual(-0.20 * 1000);\r
+\r
+        expect(begin.offset("+0min")).toEqual(0);\r
+        expect(begin.offset("-0min")).toEqual(0);\r
+        expect(begin.offset("1min")).toEqual(60000);\r
+        expect(begin.offset("-1min")).toEqual(-60000);\r
+\r
+        expect(begin.offset("+0h")).toEqual(0);\r
+        expect(begin.offset("-0h")).toEqual(0);\r
+        expect(begin.offset("1h")).toEqual(60*60*1000);\r
+        expect(begin.offset("-1h")).toEqual(-3600000);\r
+      } );\r
+      /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+      it("should be this for the value (the invalid partion)", function() {\r
+        begin.string = " h  o  g     e ";\r
+        expect(begin.offset(begin.trim())).toEqual(0);\r
+        expect(begin.offset("ms")).toEqual(0);\r
+      } );\r
+    } );\r
+\r
+    describe("An event method in $begin object", function() {\r
+      /*境界条件を調べておく (limit value analysis)*/\r
+      it("should be this for the value  (limit value analysis)", function() {\r
+\r
+      } );\r
+      /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+      it("should be this for the value (the valid partion)", function() {\r
+\r
+\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