Skip to content

Commit

Permalink
scalacheck for unplaced piece placement
Browse files Browse the repository at this point in the history
  • Loading branch information
Synesso committed Mar 12, 2011
1 parent ae92cd1 commit 21591f6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/test/scala/net/badgerhunt/typedchess/PieceSpecification.scala
Expand Up @@ -2,24 +2,28 @@ package net.badgerhunt.typedchess

import org.specs2.mutable._
import org.specs2.ScalaCheck
import org.scalacheck.{Prop, Gen}

import Position._
import org.scalacheck.{Arbitrary, Gen}


class PieceSpecification extends Specification with ScalaCheck {

/*
val positionAndPieceGenerator = for {
position <- Gen.oneOf(Position.values.toSeq)
team <- Gen.oneOf(Black, White)
role <- Gen.oneOf(Pawn, Rook, Knight, Bishop, Queen, King)
} yield (position, UnplacedPiece(team, role))

"Every piece" should {
"be positionable" ! Prop.forAll(positionAndPieceGenerator) {case (position, piece) =>
(piece at position).position must_== position
"be placeable" ! checkProp {
implicit def arb = Arbitrary{positionAndPieceGenerator}
asProperty{(positionAndPiece: (Position, UnplacedPiece)) =>
val (position, unplacedPiece) = positionAndPiece
val piece = unplacedPiece at position
position.toString must haveSize(2)
piece must haveClass[PlacedPiece]
piece.position must_== position
}
}
}
*/
}

0 comments on commit 21591f6

Please sign in to comment.