daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Jan 20th, 2018 53 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. 1. Property testing framework inspired by quickcheck
  2. 2. Difference between unit testing vs property tests
  3. 3. Fundamental testing unit is a property. Property consists of input domain, computation, assertion
  4. 4. TDD
  5.  
  6. import org.scalacheck.Prop.forAll
  7.  
  8.  val prop1 = forAll { x: Int => println(x); x == x}
  9.  prop1.check
  10.  
  11.  
  12. def sort(xs: List[Int]) = xs.sorted
  13. forAll {xs: List[Int] =>
  14.     val xs_ = sort(xs)
  15.     val containsAll = (xs.toSet -- xs_.toSet).isEmpty
  16.     if(xs.size == 1) containsAll
  17.     else containsAll && xs_.sliding(2).forall(x => x(0) < x(1))
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top