OSDN Git Service

Fix: CmdOpt default value & Template
authormzp <mzpppp@gmail.com>
Sun, 11 Oct 2009 05:47:27 +0000 (14:47 +0900)
committermzp <mzpppp@gmail.com>
Sun, 11 Oct 2009 05:47:27 +0000 (14:47 +0900)
link/cmdOpt.ml
link/cmdOptTest.ml
link/template.ml

index 288b6f3..69585c6 100644 (file)
@@ -35,7 +35,7 @@ let width =
 
 let height =
   int_option
-    ~default:600
+    ~default:(20 * 600)
     ~metavar:"<height>"
     ~short_name:'H'
     ~long_name:"height"
@@ -43,7 +43,7 @@ let height =
 
 let main_class =
   str_option
-    ~default:"Main"
+    ~default:"boot.Boot"
     ~metavar:"<main_class>"
     ~short_name:'m'
     ~long_name:"main"
@@ -80,7 +80,7 @@ let blue =
 
 let parse argv =
   let inputs =
-    OptParser.parse opt_parser argv in
+    OptParser.parse ~first:1 opt_parser argv in
     inputs,{|
       color      = (Opt.get red, Opt.get green, Opt.get blue);
       main_class = Opt.get main_class;
index 7f028ca..52525d5 100644 (file)
@@ -4,12 +4,14 @@ open CmdOpt
 open ExtString
 
 let ok x f y =
-  assert_equal ~printer:Std.dump x @@ f @@ snd @@ parse @@ Array.of_list @@ String.nsplit y " "
+  let argv =
+    Array.of_list @@ String.nsplit ("./foo " ^ y) " " in
+    assert_equal ~printer:Std.dump x @@ f @@ snd @@ parse argv
 
 let _ = begin "cmdOpt.ml" >::: [
   "filename" >:: begin fun () ->
-    assert_equal ["foo"]        @@ fst @@ parse [| "foo" |];
-    assert_equal ["foo"; "bar"] @@ fst @@ parse [| "foo"; "bar" |]
+    assert_equal ["foo"]        @@ fst @@ parse [| "./foo"; "foo" |];
+    assert_equal ["foo"; "bar"] @@ fst @@ parse [| "./foo"; "foo"; "bar" |]
   end;
   "size" >:: begin fun () ->
     ok (100,200) (fun t -> t#size) "-W 100 -H 200";
@@ -19,12 +21,12 @@ let _ = begin "cmdOpt.ml" >::: [
     ok (1,2,3) (fun t -> t#color) "--red=1 --green=2 --blue=3"
   end;
   "main class" >:: begin fun () ->
-    ok "Main" (fun t -> t#main_class) "";
-    ok "foo" (fun t -> t#main_class) "-m foo";
-    ok "foo" (fun t -> t#main_class) "--main=foo"
+    ok "boot.Boot" (fun t -> t#main_class) "";
+    ok "foo"  (fun t -> t#main_class) "-m foo";
+    ok "foo"  (fun t -> t#main_class) "--main=foo"
   end;
   "out" >:: begin fun () ->
-    ok "a.swf" (fun t -> t#output) "";
+    ok "a.swf"   (fun t -> t#output) "";
     ok "foo.swf" (fun t -> t#output) "-o foo.swf";
     ok "foo.swf" (fun t -> t#output) "--output=foo.swf"
   end;
index 8bdb30b..901ab0d 100644 (file)
@@ -13,11 +13,12 @@ let make t abc : TagOut.t SwfType.t = {
     bottom = snd t#size;
   };
   tags = [
-    `FileAttributes { TagOut.is_as3=true;  is_metadata=false; use_network=true };
+    `FileAttributes { TagOut.is_as3=true;  is_metadata=true; use_network=true };
     `SetBackgroundColor t#color;
     `FrameLabel (t#main_class,false);
     `DoABC(true,"frame",abc);
-    `SymbolClass [(0, t#main_class)]
+    `SymbolClass [(0, t#main_class)];
+    `ShowFrame;
+    `End
   ]
 }
-