OSDN Git Service

Add the Spec for the object
authordhrname <dhrname@users.sourceforge.jp>
Sun, 22 Feb 2015 12:54:56 +0000 (21:54 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sun, 22 Feb 2015 12:54:56 +0000 (21:54 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index aa9f99e..4661631 100644 (file)
@@ -446,11 +446,18 @@ base("$from").of( {
   \r
   /*呈示値の数値の部分だけを抜き出した配列を返す*/\r
   numList: function() {\r
-    return this.string.match(/a/g);\r
+    var s  = this.string.match(/[\-\+]?[\d\.]+(?:[eE][\-\+]?[\d\.]+)?/g);\r
+    if (s) {\r
+      for (var i=0;i<s.length;++i) {\r
+        s[i] = parseFloat(s[i]);\r
+      }\r
+    }\r
+    return s;\r
   },\r
   \r
   /*呈示値の文字部分だけを抜き出した配列を返す*/\r
   strList: function() {\r
+    return this.string.match(/[^\d\-\+\.eE]+/g);\r
   }\r
 } );\r
 //#endif // _SMIL_IDL_\r
index 532faaa..4b76179 100644 (file)
@@ -2811,18 +2811,98 @@ describe("SMIL Animation Spec", function() {
   describe("A $activate object", function() {\r
     var from = base("$from");\r
      beforeEach( function() {\r
+       from.string = "";\r
+       $from = from.up();\r
      } );\r
     /*境界条件を調べておく (limit value analysis)*/\r
     it("should be this for the value  (limit value analysis)", function() {\r
       expect(from.string).toBe("");\r
       expect(from.numList()).toBeNull();\r
       expect(from.strList()).toBeNull();\r
+\r
+      from.string = "0";\r
+      expect(from.numList()[0]).toEqual(0);\r
+      expect(from.strList()).toBeNull();\r
+      \r
+      from.string = " 0 ";\r
+      expect(from.numList()[0]).toEqual(0);\r
+      expect(from.strList().join("")).toBe("  ");\r
+\r
+      from.string = "a";\r
+      expect(from.numList()).toBeNull();\r
+      expect(from.strList()[0]).toBe("a");\r
+      \r
+      from.string = null;\r
+      expect( function() {\r
+        from.numList();\r
+      } ).toThrow();\r
+      expect( function() {\r
+        from.strList();\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
+      from.string = "0a";\r
+      expect(from.numList()[0]).toEqual(0);\r
+      expect(from.strList()[0]).toBe("a");\r
+\r
+      from.string = "a0";\r
+      expect(from.numList()[0]).toEqual(0);\r
+      expect(from.strList()[0]).toBe("a");\r
+\r
+      from.string = "0.1";\r
+      expect(from.numList()[0]).toEqual(0.1);\r
+      expect(from.strList()).toBeNull();\r
+\r
+      from.string = "+0.1";\r
+      expect(from.numList()[0]).toEqual(0.1);\r
+      expect(from.strList()).toBeNull();\r
+\r
+      from.string = "-0.1";\r
+      expect(from.numList()[0]).toEqual(-0.1);\r
+      expect(from.strList()).toBeNull();\r
+\r
+      from.string = "1e-1";\r
+      expect(from.numList()[0]).toEqual(1e-1);\r
+      expect(from.strList()).toBeNull();\r
+\r
+      from.string = "1E-1";\r
+      expect(from.numList()[0]).toEqual(1E-1);\r
+      expect(from.strList()).toBeNull();\r
+\r
+      from.string = "0,0";\r
+      expect(from.numList().toString()).toBe("0,0");\r
+      expect(from.strList().join("")).toBe(",");\r
+\r
+      from.string = "a00a";\r
+      expect(from.numList()[0]).toBe(0);\r
+      expect(from.strList().join("")).toBe("aa");\r
+\r
+      from.string = "a0b0a";\r
+      expect(from.numList().toString()).toBe("0,0");\r
+      expect(from.strList().join("")).toBe("aba");\r
+\r
+      from.string = "0b0a";\r
+      expect(from.numList().toString()).toBe("0,0");\r
+      expect(from.strList().join("")).toBe("ba");\r
+\r
+      from.string = "0b-1.0a";\r
+      expect(from.numList()[1]).toBe(-1);\r
+      expect(from.strList().join("")).toBe("ba");\r
     } );\r
     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
     it("should be this for the value (the invalid partion)", function() {\r
+      from.string = NaN;\r
+      expect(function(){\r
+        from.numList();\r
+      } ).toThrow();\r
+      expect(function(){\r
+        from.strList();\r
+      } ).toThrow();\r
+\r
+      from.string = "eE";\r
+      expect(from.strList()).toBeNull();\r
+      expect(from.strList()).toBeNull();\r
     } )\r
   } );\r
 } );\r