Created
May 28, 2012 10:51
-
-
Save kings13y/2818475 to your computer and use it in GitHub Desktop.
FizzBuzz spec using ScalaCheck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.scalabound.scatdd.scalacheck | |
import org.scalabound.scatdd.FizzBuzz | |
import org.scalacheck.ConsoleReporter.testReport | |
import org.scalacheck.Prop.forAll | |
import org.scalacheck.Prop.propBoolean | |
import org.scalacheck.ConsoleReporter | |
import org.scalacheck.Test | |
object FizzBuzzScalaCheck { | |
val propFizzBuzzCheck = forAll { n: Int =>{ | |
if(n % 15 == 0) FizzBuzz.eval(n) == "FizzBuzz" | |
else if(n % 3 ==0) FizzBuzz.eval(n) == "Fizz" | |
else if(n % 5 ==0) FizzBuzz.eval(n) == "Buzz" | |
else "" + n == FizzBuzz.eval(n) | |
} | |
} | |
def main(args : Array[String] ) = { | |
ConsoleReporter.testStatsEx("blah", testReport(Test.check(propFizzBuzzCheck))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment