[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[m8n] 60 Number
--setup
test=7
--arithmethic
if (test:_star(2)~=14) then error("Must be 14") end
if (test:_plus(2)~=9) then error("Must be 9") end
if (test:_minus(2)~=5) then error("Must be 5") end
if (test:_slash(2)~=3.5) then error("Must be 3.5") end
if (test:_slash_slash(2)~=3) then error("Must be 3") end
if (test:_bk_bk(2)~=1) then error("Must be 1") end
test:arcCos():mustBeNumber()
test:arcSin():mustBeNumber()
test:arcTan():mustBeNumber()
test:atan2_(2):mustBeNumber()
test:cos():mustBeNumber()
test:sin():mustBeNumber()
test:sqrt():mustBeNumber()
test:tan():mustBeNumber()
if (test:max_(1)~=test) then error("Wrong result") end
if (test:min_(1)~=1) then error("Must be 1") end
if (test:negated()~=-7) then error("Must be -7") end
if (test:squared()~=7*7) then error("Must be 7*7") end
if (test:bitShift_(2)~=28) then error("Must be 28") end
if (test:_lt_lt(2)~=28) then error("Must be 28") end
if (test:_gt_gt(2)~=1) then error("Must be 1") end
--comparing
if (test:_lt(1)) then error("Must be false") end
if (test:_lt_eq(1)) then error("Must be false") end
if (not test:_lt_eq(7)) then error("Must be true") end
if (test:_gt(11)) then error("Must be false") end
--converting
if (test:_at(11):class():name()~="Point") then error("Must return a Point") end
if (test:abs()~=test) then error("Must be equal") end
if (test:negated():abs()~=test) then error("Must be equal") end
if (test:asCharacter():asciiValue()~=test) then error("Must be true") end
if (test:asJSONObject()~=test) then error("Must be equal") end
if (test:asJavascript()~=test:asLua()) then error("Must be equal") end
test:rounded():mustBeNumber()
test:truncated():mustBeNumber()
if (test:to_(10):size()~=4) then error("Must be of size 4") end
--enumerating
local count=0; test:timesRepeat_(function() count=count+1 end); if (count~=7) then error("Must be 7") end
--testing
if (test:between_and_(100,150)) then error("Must return false") end
if (test:between_and_(100,-150)) then error("Must return false") end
if (not test:between_and_(-100,150)) then error("Must return true") end
if (test:even()) then error("Must return false") end
if (not test:odd()) then error("Must return true") end
--cleanup
test=nil