[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[m8n] 50 Set
-- setup
samples=smalltalk.Array:with_with_with_with_("one",1,true,smalltalk.Point:x_y_(3,4))
test=smalltalk.Set:newContents_(samples)
hashed=smalltalk.HashedSet:newContents_(samples)
--testing contents
if (test:isEmpty()) then error("Broken - Should have contents") end
if (test:size()~=samples:size()) then error("Should have same size as samples") end
if (hashed:isEmpty()) then error("Broken - Should have contents") end
if (hashed:size()~=samples:size()) then error("Should have same size as samples") end
test:addAll_(samples)
hashed:addAll_(samples)
if (test:isEmpty()) then error("Broken - Should have contents") end
if (test:size()~=samples:size()) then error("Should have same size as samples") end
if (hashed:isEmpty()) then error("Broken - Should have contents") end
if (hashed:size()~=samples:size()) then error("Should have same size as samples") end
--equality
if (not test:_eq(test)) then error("Must return true") end
if (not test:asArray():eq_(hashed:asArray())) then error("Must have same contents") end
--handle nil key&values
test:add_(nil)
if (not test:includes_(nil)) then error("Must include nil") end
if (not test:asArray():includes_(nil)) then error("nil must be included") end
test:remove_ifAbsent_(nil,function() error("Must be present") end)
if (test:includes_(nil)) then error("nil should be absent at this point") end
hashed:add_(nil)
if (not hashed:includes_(nil)) then error("Must include nil") end
if (not hashed:asArray():includes_(nil)) then error("nil must be included") end
hashed:remove_ifAbsent_(nil,function() error("Must be present") end)
if (hashed:includes_(nil)) then error("nil should be absent at this point") end
-- cleanup
test ,hashed ,samples = nil