Created
May 23, 2012 02:34
-
-
Save MasseGuillaume/2772931 to your computer and use it in GitHub Desktop.
Scala Kata: Test & Implementation
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
// source: http://aperiodic.net/phil/scala/s-99/ | |
def isPalindrome[A](in: List[A]):Boolean = in == in.reverse | |
// source: https://github.com/dadrox/scala.katas (adapted for spec2) | |
import org.junit._ | |
import org.specs2.matcher._ | |
class NinetyNineScalaProblems extends JUnitMustMatchers { | |
@test def P06 | |
{ | |
isPalindrome Nil must beTrue | |
isPalindrome List(1) must beTrue | |
isPalindrome List(1, 1) must beTrue | |
isPalindrome List(1, 2, 1) must beTrue | |
isPalindrome List("Madam, I'm Adam") must beTrue | |
isPalindrome List("foo", "bar", "foo") must beTrue | |
isPalindrome List(1, 2) must beFalse | |
isPalindrome List("foo", "bar", "baz") must beFalse | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment