|
Scala example source code file (DequeueTest.scala)
The DequeueTest.scala Scala example source codepackage scalaz import std.AllInstances._ import scalaz.scalacheck.ScalazProperties._ import scalaz.scalacheck.ScalazArbitrary._ import org.scalacheck.Prop.forAll object DequeueTest extends SpecLite { checkAll(monoid.laws[Dequeue[Int]]) checkAll(isEmpty.laws[Dequeue]) checkAll(foldable.laws[Dequeue]) checkAll(plusEmpty.laws[Dequeue]) checkAll(functor.laws[Dequeue]) "fromList works" ! forAll{ (l: List[Int]) ⇒ Dequeue.fromFoldable(l).toStream must_===(l.toStream) } "reverse twice is id" ! forAll{ (dq: Dequeue[Int]) ⇒ dq.reverse.reverse.toIList.must_===(dq.toIList) } "size consistent with source list" ! forAll{ (l: List[Int]) ⇒ Dequeue.fromFoldable(l).size must_===(l.size) } "reverse stream works" ! forAll{ (l: List[Int]) ⇒ Dequeue.fromFoldable(l).toBackStream must_===(l.reverse.toStream) } "toIList consistent with Ilist.fromFoldable" ! forAll{ (l: List[Int]) ⇒ Dequeue.fromFoldable(l).toIList must_===(IList.fromFoldable(l)) } "toBackIList consistent with Ilist.fromFoldable" ! forAll{ (l: List[Int]) ⇒ Dequeue.fromFoldable(l).toBackIList must_===(IList.fromFoldable(l.reverse)) } "snoc works" ! forAll{ (l: List[Int]) ⇒ (l.foldLeft[Dequeue[Int]](Dequeue.empty)((q,a) ⇒ q snoc a)).toStream must_=== l.toStream } "cons works" ! forAll{ (l: List[Int]) ⇒ (l.foldRight[Dequeue[Int]](Dequeue.empty)((a,q) ⇒ q cons a)).toStream must_=== l.toStream } } Other Scala examples (source code examples)Here is a short list of links related to this Scala DequeueTest.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.