[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[m8n] 45 Boolean


--setup
test=true


--comparing
if (not test:_eq(true)) then error("Must be true") end
if (test:_eq(false)) then error("Must be false") end
if (test:_eq(nil)) then error("Must be false") end
if (test:_eq(12)) then error("Must be false") end
if (test:_eq({})) then error("Must be false") end
if (test:_eq({true})) then error("Must be false") end


--control
if (not test:and_(function() return true end)) then error("Must be true") end
if (12~=test:ifTrue_(function() return 12 end)) then error("Must return 12") end
if (12~=test:ifTrue_ifFalse_(function() return 12 end,nil)) then error("Must return 12") end


--converting
if (not test==test:asJSONObject()) then error("Must be true") end


--copying
if (not test==test:shallowCopy()) then error("Must be true") end
if (not test==test:deepCopy()) then error("Must be true") end


--printing
if ("true"~=test:printString()) then error("Invalid result") end


--query & testing
if (true~=test:isBoolean()) then error("Invalid result") end
if (true~=test:mustBeBoolean()) then error("Must be boolean") end


--boolean macros
test=true;if (smalltalk:booleanNot_(test)) then error("Must return true") end
test=false;if (not smalltalk:booleanNot_(test)) then error("Must return false") end
test=nil;if (not smalltalk:booleanNot_(test)) then error("Must return false for nil") end
test=1;if (smalltalk:booleanNot_(test)) then error("Must return true for 1") end


--cleanup
test=nil