|
Scala example source code file (ResourceTest.scala)
The ResourceTest.scala Scala example source codepackage scalaz package effect import java.io._ import std.effect.closeable._ object ResourceTest extends SpecLite { "Resource" should { "close the resource properly (1)" in { val r = new StringReader("abcdef") r.read Resource[StringReader].close(r).unsafePerformIO try { r.read fail("should have thrown") } catch { case ioe: IOException => // ok } } "close the resource properly (2)" in { val r = new StringReader("abcdef") r.read IO(r).using(_ => IO.ioUnit).unsafePerformIO try { r.read fail("should have thrown") } catch { case ioe: IOException => // ok } } } } Other Scala examples (source code examples)Here is a short list of links related to this Scala ResourceTest.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.