[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[m8n] 60 StringStream
--setup
test=("hello world"):readStream()
--peek
if (test:position()~=0) then error("Should be at 0") end
if (test:peek():isNil()) then error("Should be something readable") end
if (test:next_(5)~="hello") then error("Should be hello") end
if (test:position()~=5) then error("Must return 5") end
if (not test:next():isSeparator()) then error("Must be a separator") end
if (test:atEnd()) then error("Must be more to read") end
if (test:peek()~="w") then error("Must be w") end
test:position_(0)
if (test:position()~=0) then error("Should be at 0") end
if (test:upTo_(" ")~="hello") then error("Wrong contents") end
if (test:upToEnd()~="world") then error("Must be world") end
if (test:position_(0):upTo_(" ")~="hello") then error("Must be hello") end
if (test:peek()~="w") then error("Must be positioned at world") end
if (not test:peekForAll_("world")) then error("Invalid peek result") end
if (not test:atEnd()) then error("Must be at end") end
--peekAll
if (("hello"):stream():peekForAll_("he")~=true) then error("Must be true") end
--cleanup
stream = nil