Added test for Ref initial value bug

This commit is contained in:
Peter Vlugter 2010-05-02 12:27:49 +12:00
parent 8816c7feaa
commit 0fd629e405

View file

@ -23,6 +23,23 @@ class TransactionalRefSpec extends Spec with ShouldMatchers {
value should be(3)
}
it("should keep the initial value, even if the first transaction is rolled back") {
val ref = Ref(3)
try {
atomic {
ref.swap(5)
throw new Exception
}
} catch {
case e => {}
}
val value = atomic { ref.get.get }
value should be(3)
}
it("should be settable using swap") {
val ref = Ref[Int]