This file contains hidden or 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
scala> import org.scalatest._ | |
import org.scalatest._ | |
scala> import prop._ | |
import prop._ | |
scala> import TableDrivenPropertyChecks._ | |
import TableDrivenPropertyChecks._ | |
// I thought this would give a good type error, except the Scala compiler decides that you meant you wanted a |
This file contains hidden or 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
scala> import org.scalautils._ | |
import org.scalautils._ | |
scala> import org.scalatest._ | |
import org.scalatest._ | |
scala> import Matchers._ | |
import Matchers._ | |
scala> import TypeCheckedTripleEquals._ |
This file contains hidden or 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
// This was my proof of concept sketch for doing matcher factories with an | |
// compile-time HList for type constructors instead of code-generated MatcherFactoryN's. | |
// I just stored regular types here, but I figured it would be straightforward to | |
// make those type constructors. I never tried doing the implicit recursive unrolling | |
// that would be required to actually use something like this in ScalaTest, but that | |
// would be fun to try as an intellectual exercise. For ScalaTest I decided that even | |
// if I could get that working, it would end up being too "clever" for ScalaTest, so | |
// I opted for the MatcherFactoryN's that I felt would be simpler for users to understand. | |
sealed trait MatcherFactory |
This file contains hidden or 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 org.scalatest._ | |
trait TagGroups extends SuiteMixin { this: Suite => | |
private val groups: Map[String, Set[String]] = | |
Map( | |
"NonUnit" -> Set("org.scalatest.tags.Disk", "org.scalatest.tags.Network"), | |
"Sluggish" -> Set("org.scalatest.tags.Slow", "org.scalatest.tags.Network") | |
) |
This file contains hidden or 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 org.scalatest._ | |
import Matchers._ | |
import tagobjects._ | |
class ExampleSpec extends FreeSpec { | |
override lazy val tags: Map[String, Set[String]] = | |
super.tags.transform { | |
case (testName, tagsSet) if testName startsWith "scope1" => tagsSet + "Scope1" | |
case (testName, tagsSet) if testName startsWith "scope2" => tagsSet + "Scope2" |
This file contains hidden or 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
{ | |
// do first step | |
// pure assert first side effect | |
} && { | |
// do second step | |
// pure assert second side effect | |
} && { | |
// do third step | |
// pure assert third side effect | |
} |
This file contains hidden or 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
/** | |
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com> | |
*/ | |
package akka.cluster | |
import scala.collection.immutable.SortedSet | |
import com.typesafe.config.ConfigFactory | |
import akka.remote.testkit.MultiNodeConfig | |
import akka.remote.testkit.MultiNodeSpec | |
import akka.testkit._ |
This file contains hidden or 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
// Here's code that can be pasted into an interpreter sesssion: | |
import scalaz._ | |
import Scalaz._ | |
import org.scalautils._ | |
def all[F[_]: Applicative, A](s: String, parsers: List[String => F[A]]): F[List[A]] = parsers.traverse(p => p(s)) | |
implicit class BadDog[G, B](or: Or[G, B]) { | |
def badMap[C](bToC: B => C): G Or C = or.swap.map(bToC).swap | |
} | |
def toIntE(s: String): Int Or ErrorMessage = attempt(s.toInt).badMap(_.getMessage) | |
def one: String => (Int Or List[ErrorMessage]) = s => toIntE(s).badMap(List(_)) |
This file contains hidden or 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
// Here is code that can be pasted into the REPL | |
import scalaz._ | |
import Scalaz._ | |
import org.scalautils._ | |
def all[F[_]: Applicative, A](s: String, parsers: List[String => F[A]]): F[List[A]] = parsers.traverse(p => p(s)) | |
implicit class BadDog[G, B](or: Or[G, B]) { | |
def badMap[C](bToC: B => C): G Or C = or.swap.map(bToC).swap | |
} | |
trait LowPriorityImplicit { |
This file contains hidden or 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
// Questions about \/ and Validation | |
object scalaz { | |
/* | |
Thanks for the great explanation, Tony. This explanation as well as the answers | |
that came back from Runar and Mark nudged my thinking in a different direction. | |
The feeling I get is that there's a monad inside of Validation trying to get out. | |
It looks like Validation would be monadic just from its shape, and users seem to | |
want to use them in for expressions. I now see that a Validation monad would need |
OlderNewer