Skip to content

Commit

Permalink
Renaming method "dep" to "newDependency"
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeldff committed Sep 30, 2012
1 parent d0a9704 commit b2706d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Expand Up @@ -7,7 +7,7 @@ import org.specs2.Specification

trait CheckingForVariousArities extends CheckHelpers {self: GooseStructure with Specification =>
def check[T1: ClassTag, R](resultExpression: (T1) => R)(testDefinition: (Dependency[T1]) => When[R] => When[R]): Fragments = {
val (dep1) = (dep[T1]("1"))
val (dep1) = (newDependency[T1]("1"))
val calcResult = {state:Environment =>
(state.get(dep1)) match {
case (InitializedDouble(value1)) => Right(resultExpression(value1))
Expand All @@ -20,7 +20,7 @@ trait CheckingForVariousArities extends CheckHelpers {self: GooseStructure with
}

def check[T1: ClassTag, T2: ClassTag, R](resultExpression: (T1, T2) => R)(testDefinition: (Dependency[T1], Dependency[T2]) => When[R] => When[R]): Fragments = {
val (dep1, dep2) = (dep[T1]("1"), dep[T2]("2"))
val (dep1, dep2) = (newDependency[T1]("1"), newDependency[T2]("2"))
val calcResult = {state:Environment =>
(state.get(dep1), state.get(dep2)) match {
case (InitializedDouble(value1), InitializedDouble(value2)) => Right(resultExpression(value1, value2))
Expand All @@ -32,7 +32,7 @@ trait CheckingForVariousArities extends CheckHelpers {self: GooseStructure with
}

def check[T1: ClassTag, T2: ClassTag, T3: ClassTag, R](resultExpression: (T1, T2, T3) => R)(testDefinition: (Dependency[T1], Dependency[T2], Dependency[T3]) => When[R] => When[R]): Fragments ={
val (dep1, dep2, dep3) = (dep[T1]("1"), dep[T2]("2"), dep[T3]("3"))
val (dep1, dep2, dep3) = (newDependency[T1]("1"), newDependency[T2]("2"), newDependency[T3]("3"))
val calcResult = {state:Environment =>
(state.get(dep1), state.get(dep2), state.get(dep3)) match {
case (InitializedDouble(value1), InitializedDouble(value2), InitializedDouble(value3)) => Right(resultExpression(value1, value2, value3))
Expand Down
7 changes: 3 additions & 4 deletions src/main/scala/net/rafaelferreira/goose/Goose.scala
Expand Up @@ -58,7 +58,6 @@ trait GooseStructure {this: Specification =>
type ResultExpression[R] = Environment => Either[String,R]

class When[R](resultExpression: ResultExpression[R], environment: Environment = new Environment(), val fragments:Fragments = Fragments()) {

def when[T](assumption: Assumption[T]): When[R] = copy(newState = environment.assuming(assumption))
def and[T](assumption: Assumption[T]): When[R] = when(assumption)

Expand All @@ -79,13 +78,13 @@ trait GooseStructure {this: Specification =>

def results: Fragments = fragments ^ end

def copy(newResultExpression: ResultExpression[R] = resultExpression, newState: Environment = environment, newFragments:Fragments = fragments) =
private def copy(newResultExpression: ResultExpression[R] = resultExpression, newState: Environment = environment, newFragments:Fragments = fragments) =
new When(newResultExpression, newState, newFragments)

}

type Dependency[T] <: GeneralDependency[T]
def dep[T: ClassTag](name:String): Dependency[T]
def newDependency[T: ClassTag](name:String): Dependency[T]
}

trait Goose extends GooseStructure with CheckingForVariousArities with stubs.Stubs {self: Specification =>
Expand All @@ -95,5 +94,5 @@ trait Goose extends GooseStructure with CheckingForVariousArities with stubs.Stu

type Dependency[T] = ActualDependency[T]

def dep[T: ClassTag](name:String): ActualDependency[T] = new ActualDependency[T](name)
def newDependency[T: ClassTag](name:String): ActualDependency[T] = new ActualDependency[T](name)
}

0 comments on commit b2706d3

Please sign in to comment.