OSDN Git Service

error checkをSpecに追加して、さらにopenメソッドを改良
authordhrname <dhrname@users.sourceforge.jp>
Tue, 17 Sep 2013 12:29:37 +0000 (21:29 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Tue, 17 Sep 2013 12:29:37 +0000 (21:29 +0900)
tool/funcproto/FuncSpecRunner.html
tool/funcproto/openfile.js

index fd975e2..143b2ec 100644 (file)
@@ -55,10 +55,27 @@ function f (file) {
       expect(file[4]).toEqual("5678");\r
       expect(file.write("30d")).toEqual("30d");\r
     });\r
+    var f;\r
+    beforeEach(function() {\r
+      f = function() {};\r
+    });\r
     it("default property", function() {\r
-      var f = function() {};\r
       expect(f.open("a")).toEqual(f);\r
     });\r
+    it("error check", function() {\r
+      expect(function() {\r
+        f.oepn();\r
+      }).toThrow();\r
+      expect(function() {\r
+        f.oepn("");\r
+      }).toThrow();\r
+      expect(function() {\r
+        f.oepn(["y"]);\r
+      }).toThrow();\r
+      expect(function() {\r
+        f.oepn({x:"x"});\r
+      }).toThrow();\r
+    });\r
   });\r
   __start_();\r
 };\r
index fe0b3a6..bc02208 100644 (file)
@@ -3,7 +3,7 @@ Copyright (c) 2013 dhrname*/
 \r
 if (!Function.prototype.open) {\r
   Function.prototype.open = function() {\r
-    if (typeof arguments[0] !== "string") {\r
+    if (!arguments[0] && (typeof arguments[0] !== "string")) {\r
       throw new Error("no arguments error");\r
     }\r
     var that = this,               // Callback Function\r