Skip to content

Commit

Permalink
Minor cleanup (to begin with)
Browse files Browse the repository at this point in the history
  • Loading branch information
holograph committed Jun 10, 2015
1 parent b808e43 commit 94b53f9
Showing 1 changed file with 19 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,27 @@ package com.wix.accord.tests.dsl
import com.wix.accord._
import com.wix.accord.scalatest.ResultMatchers
import org.scalatest.{Matchers, WordSpec}

import scala.collection.mutable

object CollectionOpsTests {
import dsl._

val seqEmptyValidator = validator[ Seq[_] ] { _ is empty }
val seqNotEmptyValidator = validator[ Seq[_] ] { _ is notEmpty }
val seqSizeValidator = validator[ Seq[_] ] { _ has size > 0 }
val seqEachValidator = validator[ Seq[ String ] ] { _.each is empty }

trait ArbitraryType
object ArbitraryType { def apply() = new ArbitraryType {} }

def visit[ T ]( coll: Traversable[ T ] )( visitor: T => Result ): Result = {
val visited = new Validator[ T ] {
def apply( v: T ) = visitor( v )
}
( coll.each is visited )( coll )
}
}

class CollectionOpsTests extends WordSpec with Matchers with ResultMatchers {
import CollectionOpsTests._

Expand Down Expand Up @@ -49,33 +67,6 @@ class CollectionOpsTests extends WordSpec with Matchers with ResultMatchers {
failWith( RuleViolationMatcher( constraint = "has size 0, expected more than 0" ) )
}
}
}

object CollectionOpsTests {
import dsl._

val seqEmptyValidator = validator[ Seq[_] ] { _ is empty }
val seqNotEmptyValidator = validator[ Seq[_] ] { _ is notEmpty }
val seqSizeValidator = validator[ Seq[_] ] { _ has size > 0 }
val seqEachValidator = validator[ Seq[ String ] ] { _.each is empty }
}

object NewCollectionOpsTests {
import dsl._

trait ArbitraryType
object ArbitraryType { def apply() = new ArbitraryType {} }

def visit[ T ]( coll: Traversable[ T ] )( visitor: T => Result ): Result = {
val visited = new Validator[ T ] {
def apply( v: T ) = visitor( v )
}
( coll.each is visited )( coll )
}
}

class NewCollectionOpsTests extends WordSpec with Matchers with ResultMatchers {
import NewCollectionOpsTests._

"Calling \".each\" on a Traversable" should {
"apply subsequent validation rules to all elements" in {
Expand Down

0 comments on commit 94b53f9

Please sign in to comment.