OSDN Git Service

new Spec for a 'hasAttributes' method and a 'normalize' method
authordhrname <dhrname@users.sourceforge.jp>
Mon, 27 Aug 2012 14:40:02 +0000 (23:40 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Mon, 27 Aug 2012 14:40:02 +0000 (23:40 +0900)
tool/Spec/spec/SvgDomSpec.js

index 0069e22..a3b2529 100644 (file)
@@ -1470,12 +1470,40 @@ describe("SVG Spec in JavaScript", function() {
     });
     /*normalizeメソッドの境界条件を調べておく (limit value analysis, when it calls a normalize method)*/
     it("should be this for the value, when it calls a normalize method (limit value analysis)", function() {
+      var text, ttext,
+          tle = [doc.createTextNode(""), doc.createTextNode("0"), doc.createTextNode("a")];
+      s.normalize();
+      expect(s.firstChild).toBeNull();
+      expect(s.lastChild).toBeNull();
+      s.appendChild(tle[0]);
+      s.normalize();
+      expect(s.firstChild).toNotBe(null);
+      expect(s.lastChild).toNotBe(null);
+      expect(s.firstChild.nodeValue).toEqual("");
+      for (var i=0; i<tle.legnth-1; ++i) {
+        text = tle[i],
+        ttext = tle[i+1];
+        s.appendChild(text);
+        s.appendChild(ttext);
+        expect(s.firstChild).toEqual(text);
+        expect(s.lastChild).toEqual(ttext);
+        s.norbalize();
+        expect(s.firstChild.nodeValue).toEqual(text.nodeValue+ttext.nodeValue);
+        expect(s.firstChild).toNotBe(text);
+        expect(s.lastChild).toNotBe(ttext);
+      }
     });
     /*isSupportedメソッドの境界条件を調べておく (limit value analysis, when it calls a isSupported method)*/
     it("should be this for the value, when it calls a isSupported method (limit value analysis)", function() {
     });
     /*hasAttributesメソッドの境界条件を調べておく (limit value analysis, when it calls a hasAttributes method)*/
     it("should be this for the value, when it calls a hasAttributes method (limit value analysis)", function() {
+      expect(s.hasAttributes()).toEqual(false);  
+      s.setAttributeNS(null, "a", "b");
+      expect(s.hasAttributes()).toEqual(true);
+      expect(t.hasAttributes()).toEqual(false);  
+      t.setAttributeNS(null, "c", "d");
+      expect(t.hasAttributes()).toEqual(true);
     });
     
     /*insertBeforeメソッドの同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/