Guest User

Untitled

a guest
Jan 20th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment