[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[m8n] 60 Actions
--setup
test=smalltalk.Message:receiver_selector_arguments_(smalltalk.Point:x_y_(5,5),"+",smalltalk.Array:with_(3))
test:comment_("This is a test message")
simple=smalltalk.Message:receiver_selector_arguments_("hello","yourself",smalltalk.Array:new())
simple:comment_("This is a simple message")
second=smalltalk.Message:receiver_selector_arguments_("hello",",",smalltalk.Array:with_(" world"))
second:comment_("This is a second message")
--accessing
if (simple:evaluate()~="hello") then error("Result must be hello") end
if (second:evaluate()~="hello world") then error("Result must be hello world") end
if (second:evaluateFor_("My")~="helloMy") then error("Result must be helloMy") end
if (not test:comment():includes_("test message")) then error("Must be included") end
if (test:selector()~="+") then error("Must be a send to +") end
if (not test:receiver():isKindOf_(smalltalk.Point)) then error("Receiver must be a Point") end
if (not test:evaluate():isKindOf_(smalltalk.Point)) then error("Result must be aPoint") end
if (test:evaluate():x()~=8) then error("Result x must be 8") end
--composing
test=smalltalk.Message:receiver_selector_arguments_(smalltalk.Point,"new",smalltalk.Array:new(3))
aFunction = function() print("printing") end
last = function() return 7 end
composite = test:_comma(second):_comma(aFunction):_comma(simple):_comma(last)
if (composite:evaluate()~=7) then error("Invalid result evaluating composite") end
aFunction ,composite=nil
--cleanup
test ,simple ,second = nil