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
import akka.actor.ActorSystem | |
import akka.testkit.{TestActorRef, EventFilter, TestKit} | |
import org.scalatest.{BeforeAndAfterAll, WordSpecLike} | |
class FailingTest | |
extends TestKit(ActorSystem("MyActorTest")) | |
with WordSpecLike | |
with BeforeAndAfterAll { | |
override def afterAll() { |
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
import akka.actor.ActorSystem | |
import akka.testkit.{TestActorRef, EventFilter, TestKit} | |
import org.scalatest.{OneInstancePerTest, BeforeAndAfterAll, WordSpecLike} | |
class PassingTest | |
extends TestKit(ActorSystem("MyActorTest")) | |
with WordSpecLike | |
with BeforeAndAfterAll | |
with OneInstancePerTest { |
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
import com.netaporter.precanned.dsl.fancy._ | |
val animalApi = httpServerMock(system).bind(8766) | |
animalApi expect | |
get and path("/animals") and query("name" -> "giraffe") and | |
respond using | |
resource("/responses/giraffe.json") end() |
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
import scala.io.Source | |
val reverseLetters = ( ('a' to 'z') zip ('a' to 'z').reverse ).toMap.withDefault(identity) | |
val words = Source.fromFile("/usr/share/dict/words").getLines.toVector | |
def isWordMatch(word: String) = { | |
val reverseLetterWord = word.toLowerCase.map(reverseLetters) | |
reverseLetterWord.reverse == word | |
} |
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
val snakes = Map( | |
16 -> 6, | |
47 -> 26, | |
49 -> 11, | |
56 -> 53, | |
62 -> 18, | |
64 -> 60, | |
87 -> 24, | |
92 -> 72, | |
95 -> 75, |
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
// GAME ENGINE | |
trait View[A] { | |
protected def update(before: A, after: A): Unit | |
def onModelChange(before: A, after: A): Unit = | |
if(before != after) { | |
update(before, after) | |
} |
OlderNewer