Skip to content

Commit

Permalink
Revert changes to fix evidence-based tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffmay committed Apr 14, 2021
1 parent 3ff26f7 commit 0ef00df
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class CapturePSpec extends AnyWordSpec with TypeCheckedTripleEquals {
import com.rallyhealth.vapors.core.example.CaptureTimeRange._

"find a single fact from a query" in {
val q = valuesOfType(FactTypes.WeightMeasurement).exists {
_.get(_.select(_.value)) > 18
val q = factsOfType(FactTypes.WeightMeasurement).exists {
_.get(_.select(_.value.value)) > 18.0
}
val result = eval(JoeSchmoe.factTable)(q)
assert(result.param.value === TimeRange(JoeSchmoe.weight.value.timestamp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class ExprBuilderSpec extends AnyWordSpec {
"ValExprBuilder" should {

"combine lenses from chained .get() methods" in {
val q = valuesOfType(FactTypes.GenericMeasurement).exists {
_.get(_.select(_.value)) > 0.0
val q = factsOfType(FactTypes.GenericMeasurement).exists {
_.get(_.select(_.value)).get(_.select(_.value)) > 0.0
}.returnOutput
inside(q) {
case Expr.ExistsInOutput(_, condExpr, _) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class Snippets(val clock: Clock) {
this(Clock.fixed(fixedLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant, ZoneId.systemDefault()))

val ageFromDateOfBirth: Expr[FactTable, Seq[Int], Unit] = {
valuesOfType(FactTypes.DateOfBirth).map { value =>
valuesOfType(FactTypes.DateOfBirth).map { dob =>
val ageInYears = dateDiff(
value,
value.embedResult(today(clock)),
value.embedConst(ChronoUnit.YEARS),
dob,
dob.embedResult(today(clock)),
dob.embedConst(ChronoUnit.YEARS),
)
ageInYears.withOutputValue.get(_.select(_.toInt))
}
Expand All @@ -34,15 +34,15 @@ class Snippets(val clock: Clock) {

val isOver18: RootExpr[Boolean, Unit] = {
usingDefinitions(ageFromDateOfBirthDef) {
valuesOfType(FactTypes.Age).exists {
_ >= 18
factsOfType(FactTypes.Age).exists {
_.value >= 18
}
}
}

lazy val isUser: RootExpr[Boolean, Unit] = {
valuesOfType(FactTypes.Role).exists {
_ >= Role.User
factsOfType(FactTypes.Role).exists {
_.value >= Role.User
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class UsingDefinitionsExprSpec extends AnyWordSpec {
val definition = Snippets.isEligibleDef
val result = eval(facts) {
usingDefinitions(definition) {
valuesOfType(definition.factType).exists(_ === true)
factsOfType(definition.factType).exists {
_.get(_.select(_.value))
}
}
}
assert(result.output.value)
Expand Down

0 comments on commit 0ef00df

Please sign in to comment.