OSDN Git Service

setAttributeNodeNSメソッドに関するスペックを追加
authordhrname <dhrname@users.sourceforge.jp>
Sun, 8 Dec 2013 14:28:28 +0000 (23:28 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sun, 8 Dec 2013 14:28:28 +0000 (23:28 +0900)
tool/Spec/spec/SvgDomSpec.js

index 1dbb92a..4b32b58 100644 (file)
@@ -1952,28 +1952,77 @@ describe("SVG Spec in JavaScript", function() {
       expect(s.nodeType).toEqual( /*Node.ELEMENT_NODE*/ 1);\r
       expect(s.nodeValue).toBeNull();\r
       expect(t.nodeType).toEqual( /*Node.ELEMENT_NODE*/ 1);\r
-      expect(t.nodeValue).toBeNull();   \r
+      expect(t.nodeValue).toBeNull();\r
+      expect(s.attributes.length).toEqual(0);\r
     });\r
     \r
-    /*insertBeforeメソッドの境界条件を調べておく (limit value analysis, when it calls a insertBefore method)*/\r
-    it("should be this for the value, when it calls a insertBefore method (limit value analysis)", function() {\r
-    });\r
-    /*getElementsByTagNameNSメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
-    it("should be this for the value, when it calls a getElementsByTagNameNS method (the valid partion)", function() {\r
-    });\r
-    /*getElementsByTagNameNSメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
-    it("should be this for the value, when it calls a getElementsByTagNameNS method (the invalid partion)", function() {\r
+    /*setAttributeNodeNSメソッドの境界条件を調べておく (limit value analysis, when it calls a setAttributeNodeNS method)*/\r
+    it("should be this for the value, when it calls a setAttributeNodeNS method (limit value analysis)", function() {\r
+      expect(function() {\r
+        s.setAttributeNodeNS();\r
+      }).toThrow();\r
+      var attr = s.ownerDocument.createAttributeNS(null, "h"),\r
+          sat = s.attributes;\r
+      s.setAttributeNodeNS(attr);\r
+      expect(sat.length).toEqual(1);\r
+      expect(sat.getNamedItemNS(null, "h")).toBe(attr);\r
+      /*同じことを繰り返して試行処理*/\r
+      s.setAttributeNodeNS(attr);\r
+      expect(sat.length).toEqual(1);\r
+      expect(sat.getNamedItemNS(null, "h")).toBe(attr);\r
+      attr = s.ownerDocument.createAttributeNS("urn:wo", "h");\r
+      s.setAttributeNodeNS(attr);\r
+      expect(sat.length).toEqual(2);\r
+      expect(sat.getNamedItemNS("urn:", "h")).toBeNull();\r
+    });\r
+    /*setAttributeNodeNSメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+    it("should be this for the value, when it calls a setAttributeNodeNS method (the valid partion)", function() {\r
+      for (var i=0;i<10;++i) {\r
+        var attr = s.ownerDocument.createAttributeNS(null, "h"),\r
+            sat = s.attributes;\r
+        s.setAttributeNodeNS(attr);\r
+      }\r
+      expect(sat.length).toEqual(1);\r
+      expect(sat.getNamedItemNS(null, "h")).toBe(attr);\r
+      for (var i=0;i<10;++i) {\r
+        attr = s.ownerDocument.createAttributeNS("urn:" +i+ "o", "h");\r
+        s.setAttributeNodeNS(attr);\r
+      }\r
+      expect(sat.length).toEqual(11);\r
+      expect(sat.getNamedItemNS("urn:9o", "h")).toBe(attr);\r
+      \r
+      attr = s.ownerDocument.createAttributeNS("urn:wo", "0");\r
+      s.setAttributeNodeNS(attr);\r
+      expect(sat.getNamedItemNS("urn:wo", "0")).toBe(attr);\r
+    });\r
+    /*setAttributeNodeNSメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+    it("should be this for the value, when it calls a setAttributeNodeNS method (the invalid partion)", function() {\r
+      var attr = s.ownerDocument.createAttributeNS(null, "h"),\r
+          sat = s.attributes;\r
+      s.setAttributeNodeNS(attr);\r
+      expect(function() {\r
+        /*すでに使われている属性ノードを別の要素に移した場合はエラー*/\r
+        t.setAttrributeNodeNS(attr);\r
+      }).toThrow();\r
+      \r
+      attr = s.ownerDocument.implementation\r
+              .createDocument("http://www.w3.org/svg/2000", "svg")\r
+              .createAttributeNS("urn:", "h");\r
+      expect(function() {\r
+        /*別の文書ノードに属する属性ノードを設定した場合はエラー*/\r
+        t.setAttrributeNodeNS(attr);\r
+      }).toThrow();\r
     });\r
     \r
     \r
-    /*insertBeforeメソッドの境界条件を調べておく (limit value analysis, when it calls a insertBefore method)*/\r
-    it("should be this for the value, when it calls a insertBefore method (limit value analysis)", function() {\r
+    /*hasAttributeNSメソッドの境界条件を調べておく (limit value analysis, when it calls a insertBefore method)*/\r
+    it("should be this for the value, when it calls a hasAttributeNS method (limit value analysis)", function() {\r
     });\r
-    /*getElementsByTagNameNSメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
-    it("should be this for the value, when it calls a getElementsByTagNameNS method (the valid partion)", function() {\r
+    /*hasAttributeNSメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+    it("should be this for the value, when it calls a hasAttributeNS method (the valid partion)", function() {\r
     });\r
-    /*getElementsByTagNameNSメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
-    it("should be this for the value, when it calls a getElementsByTagNameNS method (the invalid partion)", function() {\r
+    /*hasAttributeNSメソッドの同値分割をして、無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+    it("should be this for the value, when it calls a hasAttributeNS method (the invalid partion)", function() {\r
     });\r
   });\r
 });
\ No newline at end of file