Skip to content

Commit

Permalink
add test for IO
Browse files Browse the repository at this point in the history
  • Loading branch information
mwotton committed Dec 7, 2009
1 parent f24ee5d commit 6f1096c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/hubris_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,29 @@ class ConcTest
threads.each { |t| t.join }
}.should_not raise_error
end

end

describe "IO" do
it "can write a variable" do
class IOTest
hubris :inline =><<EOF
import Data.IORef
import System.IO.Unsafe
ref :: IORef Int
ref = unsafePerformIO $ newIORef 10
readRef :: Value -> IO Int
readRef _ = readIORef ref
modify :: Int -> IO ()
modify n = writeIORef ref n
EOF

end
i = IOTest.new
i.readRef(nil).should == 10
i.modify(20)
i.readRef(nil).should == 20

end
end

0 comments on commit 6f1096c

Please sign in to comment.