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

obsolete[m8n] 75 inlines s8

Tests for compiled methods with inlined code (category: s8)
-- setup
test=smalltalk.Test:new()


--core inlines (if...:)
if (test:ifTrue()~=test) then error("Must return the test") end
if (test:ifFalse()~=test) then error("Must return the test") end
if (test:trueIfTrue()~=test) then error("Must return the test") end
if (test:falseIfTrue()~=nil) then error("Must return nil") end
if (test:trueIfFalse()~=nil) then error("Must return nil") end
if (test:falseIfFalse()~=test) then error("Must return the test") end
if (test:trueIf_(true)~=test) then error("Must return the test") end
if (test:trueIf_(false)~=nil) then error("Must return nil") end
if (test:falseIf_(true)~=nil) then error("Must return nil") end
if (test:falseIf_(false)~=test) then error("Must return the test") end
if (test:vIfTrue()~=test) then error("Must return the test") end
if (test:vIfFalse()~=nil) then error("Must return nil") end
if (test:rIfTrue()~=test) then error("Must return the test") end

aBlock = function() return true end
eBlock = function() return false end
if (test:if_true_false_(true,aBlock, eBlock)~=true) then error("Must return true") end
if (test:if_true_false_(false,aBlock, eBlock)~=false) then error("Must return false") end
if (test:if_false_true_(true,eBlock, aBlock)~=true) then error("Must return true") end
if (test:if_false_true_(false,eBlock, aBlock)~=false) then error("Must return false") end


--core inlines (while...)
if (test:printWhileTrue()~=0) then error("Must return 0") end
if (test:printWhileFalse()~=10) then error("Must return 10") end
--orNil test ...toDo...
if (test:printWhileTrue_(10)~=0) then error("Must return 0") end
if (test:printWhileFalse_(10)~=10) then error("Must return 10") end
if (test:printTimes_(10)~=10) then error("Must return 10") end


--core inlines (iko respondsTo)
if (test:iko_(smalltalk.Test)~=true) then error("Must return true") end
if (test:iko_(smalltalk.Object)~=true) then error("Must return true") end
if (test:iko_(smalltalk.Point)~=false) then error("Must return false") end
if (test:understand_("yourself")~=true) then error("Must return true") end
if (test:understand_("isArray")~=true) then error("Must return true") end
if (test:understand_("iko:")~=true) then error("Must return true") end
if (test:understand_("iko_")~=false) then error("Must return false") end
if (test:understand_("my self")~=false) then error("Must return false") end
if (test:understand_(12)~=false) then error("Must return false") end
if (test:understand_(nil)~=false) then error("Must return false") end


--core inlines (ifNil... ifNotNil...)
if (test:if_nil_(nil,43)~=43) then error("Must return 43") end
if (test:if_nil_(1,43)~=1) then error("Must return 1") end
if (test:if_notNil_(nil,43)~=nil) then error("Must return nil") end
if (test:if_notNil_(1,43)~=43) then error("Must return 43") end
if (test:if_nil_notNil_(nil,43,12)~=43) then error("Must return 43") end
if (test:if_nil_notNil_(1,43,12)~=12) then error("Must return 12") end
if (test:if_notNil_nil_(nil,43,12)~=12) then error("Must return 12") end
if (test:if_notNil_nil_(1,43,12)~=43) then error("Must return 43") end


-- cleanup
test   = nil
aBlock = nil
eBlock = nil