[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[m8n] 50 SequenceableCollection
-- setup
test=smalltalk:become_a_({1,2,3,4,5},smalltalk.SequenceableCollection)
--testing implementation
if (test:detect_ifNone_(function(x) return x == 1 end,function() return "none" end)~=1) then error("Must return 1") end
if (test:detect_ifNone_(function(x) return x == nil end,function() return "none" end)~="none") then error("Must return none") end
if (test:indexOf_ifAbsent_(1,function() return "none" end)~=1) then error("Must return 1") end
if (test:indexOf_ifAbsent_("ouch",function() return "none" end)~="none") then error("Must return none") end
test:do_(function(x) print(x) end)
test:reverseDo_(function(x) print(x) end)
test:reversed():do_(function(x) print(x) end)
table.insert(test,1)
table.insert(test,1)
table.insert(test,1)
if (test:occurrencesOf_(1)==1) then error("Must be > 1") end
if (not test:includes_(1)) then error("Missing value 1") end
if (test:includes_("nothing")) then error("Must return false") end
-- cleanup
test = nil