local a=require'pl.tablex'local b=require'pl.utils'local c=require'pl.pretty'local d=require'pl.path'local type,e,f=type,b.unpack,b.pack;local g=os.clock;local h=require'debug'local io=io;local function i(j)if type(j)=='table'and not(getmetatable(j)and getmetatable(j).__tostring)then return c.write(j,' ',true)elseif type(j)=='string'then return'"'..j..'"'else return tostring(j)end end;local k={}function k.error_handler(l,m,n,o,p)local q=io.stderr;q:write(d.basename(l)..':'..m..': assertion failed\n')q:write("got:\t",n,'\n')q:write("needed:\t",o,'\n')b.quit(1,p or"these values were not equal")end;local function r(j,s,p,t)local u=h.getinfo(3+(t or 0))k.error_handler(u.short_src,u.currentline,i(j),i(s),p)end;k.complain=r;function k.asserteq(j,s,v,t)local w=j==s;if not w then w=a.deepcompare(j,s,true,v)end;if not w then r(j,s,nil,t)end end;function k.assertmatch(x,y,t)if not x:match(y)then r(x,y,"these strings did not match",t)end end;function k.assertraise(z,A,t)local B,q;if type(z)=='table'then B,q=pcall(e(z))else B,q=pcall(z)end;if B or q:match(A)==nil then r(q,A,"these errors did not match",t)end end;function k.asserteq2(C,D,E,F,t)if C~=E then r(C,E,nil,t)end;if D~=F then r(D,F,nil,t)end end;local G={unpack=e}G.__index=G;function G.__tostring(self)local H={}for u=1,self.n do local I=self[u]H[u]=type(I)=='string'and('%q'):format(I)or tostring(I)end;return'tuple('..table.concat(H,', ')..')'end;function G.__eq(J,K)if J.n~=K.n then return false end;for u=1,J.n do if J[u]~=K[u]then return false end end;return true end;function G.__len(self)return self.n end;function k.tuple(...)return setmetatable(f(...),G)end;function k.timer(p,L,M,...)local N=g()for u=1,L do M(...)end;b.printf("%s: took %7.2f sec\n",p,g()-N)end;return k