var parse=require("../"),test=require("tape");test("parse args",function(e){e.deepEqual(parse(["--no-moo"]),{moo:!1,_:[]},"no");e.deepEqual(parse(["-v","a","-v","b","-v","c"]),{v:["a","b","c"],_:[]},"multi");e.end()});test("comprehensive",function(e){e.deepEqual(parse(["--name=meowmers","bare","-cats","woo","-h","awesome","--multi=quux","--key","value","-b","--bool","--no-meep","--multi=baz","--","--not-a-flag","eek"]),{c:!0,a:!0,t:!0,s:"woo",h:"awesome",b:!0,bool:!0,key:"value",multi:["quux","baz"],meep:!1,name:"meowmers",_:["bare","--not-a-flag","eek"]});e.end()});test("nums",function(e){var a=parse(["-x","1234","-y","5.67","-z","1e7","-w","10f","--hex","0xdeadbeef","789"]);e.deepEqual(a,{x:1234,y:5.67,z:1e7,w:"10f",hex:3735928559,_:[789]});e.deepEqual(typeof a.x,"number");e.deepEqual(typeof a.y,"number");e.deepEqual(typeof a.z,"number");e.deepEqual(typeof a.w,"string");e.deepEqual(typeof a.hex,"number");e.deepEqual(typeof a._[0],"number");e.end()});test("flag boolean",function(e){var a=parse(["-t","moo"],{"boolean":"t"});e.deepEqual(a,{t:!0,_:["moo"]});e.deepEqual(typeof a.t,"boolean");e.end()});test("flag boolean value",function(e){var a=parse(["--verbose","false","moo","-t","true"],{"boolean":["t","verbose"],"default":{verbose:!0}});e.deepEqual(a,{verbose:!1,t:!0,_:["moo"]});e.deepEqual(typeof a.verbose,"boolean");e.deepEqual(typeof a.t,"boolean");e.end()});test("flag boolean default false",function(e){var a=parse(["moo"],{"boolean":["t","verbose"],"default":{verbose:!1,t:!1}});e.deepEqual(a,{verbose:!1,t:!1,_:["moo"]});e.deepEqual(typeof a.verbose,"boolean");e.deepEqual(typeof a.t,"boolean");e.end()});test("boolean groups",function(e){var a=parse(["-x","-z","one","two","three"],{"boolean":["x","y","z"]});e.deepEqual(a,{x:!0,y:!1,z:!0,_:["one","two","three"]});e.deepEqual(typeof a.x,"boolean");e.deepEqual(typeof a.y,"boolean");e.deepEqual(typeof a.z,"boolean");e.end()});test("newlines in params",function(e){var a=parse(["-s","X\nX"]);e.deepEqual(a,{_:[],s:"X\nX"});a=parse(["--s=X\nX"]);e.deepEqual(a,{_:[],s:"X\nX"});e.end()});test("strings",function(e){var a=parse(["-s","0001234"],{string:"s"}).s;e.equal(a,"0001234");e.equal(typeof a,"string");var o=parse(["-x","56"],{string:"x"}).x;e.equal(o,"56");e.equal(typeof o,"string");e.end()});test("stringArgs",function(e){var a=parse(["  ","  "],{string:"_"})._;e.same(a.length,2);e.same(typeof a[0],"string");e.same(a[0],"  ");e.same(typeof a[1],"string");e.same(a[1],"  ");e.end()});test("empty strings",function(e){var a=parse(["-s"],{string:"s"}).s;e.equal(a,"");e.equal(typeof a,"string");var o=parse(["--str"],{string:"str"}).str;e.equal(o,"");e.equal(typeof o,"string");var t=parse(["-art"],{string:["a","t"]});e.equal(t.a,"");e.equal(t.r,!0);e.equal(t.t,"");e.end()});test("slashBreak",function(e){e.same(parse(["-I/foo/bar/baz"]),{I:"/foo/bar/baz",_:[]});e.same(parse(["-xyz/foo/bar/baz"]),{x:!0,y:!0,z:"/foo/bar/baz",_:[]});e.end()});test("alias",function(e){var a=parse(["-f","11","--zoom","55"],{alias:{z:"zoom"}});e.equal(a.zoom,55);e.equal(a.z,a.zoom);e.equal(a.f,11);e.end()});test("multiAlias",function(e){var a=parse(["-f","11","--zoom","55"],{alias:{z:["zm","zoom"]}});e.equal(a.zoom,55);e.equal(a.z,a.zoom);e.equal(a.z,a.zm);e.equal(a.f,11);e.end()});test("nested dotted objects",function(e){var a=parse(["--foo.bar","3","--foo.baz","4","--foo.quux.quibble","5","--foo.quux.o_O","--beep.boop"]);e.same(a.foo,{bar:3,baz:4,quux:{quibble:5,o_O:!0}});e.same(a.beep,{boop:!0});e.end()});test("boolean and alias with chainable api",function(e){var a=["-h","derp"],o=["--herp","derp"],t=parse(a,{"boolean":"herp",alias:{h:"herp"}}),s=parse(o,{"boolean":"herp",alias:{h:"herp"}}),r={herp:!0,h:!0,_:["derp"]};e.same(t,r);e.same(s,r);e.end()});test("boolean and alias with options hash",function(e){var a=["-h","derp"],o=["--herp","derp"],t={alias:{h:"herp"},"boolean":"herp"},s=parse(a,t),r=parse(o,t),n={herp:!0,h:!0,_:["derp"]};e.same(s,n);e.same(r,n);e.end()});test("boolean and alias using explicit true",function(e){var a=["-h","true"],o=["--herp","true"],t={alias:{h:"herp"},"boolean":"h"},s=parse(a,t),r=parse(o,t),n={herp:!0,h:!0,_:[]};e.same(s,n);e.same(r,n);e.end()});test("boolean and --x=true",function(e){var a=parse(["--boool","--other=true"],{"boolean":"boool"});e.same(a.boool,!0);e.same(a.other,"true");a=parse(["--boool","--other=false"],{"boolean":"boool"});e.same(a.boool,!0);e.same(a.other,"false");e.end()});