Skip to content

Instantly share code, notes, and snippets.

View bvenners's full-sized avatar

Bill Venners bvenners

View GitHub Profile
@bvenners
bvenners / gist:7956533
Created December 14, 2013 07:35
One way to group tags in ScalaTest 2.0
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")
)
@bvenners
bvenners / gist:7772698
Created December 3, 2013 16:49
Compile time HList for types
// 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
@bvenners
bvenners / gist:7679915
Created November 27, 2013 17:40
Typesafe equality and contains checking in ScalaTest
scala> import org.scalautils._
import org.scalautils._
scala> import org.scalatest._
import org.scalatest._
scala> import Matchers._
import Matchers._
scala> import TypeCheckedTripleEquals._
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