Skip to content

Commit

Permalink
Rename Maybe to Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Dec 8, 2023
1 parent 10030d4 commit 077aa87
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/bench/benchmark.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import scala.collection.mutable as scm
extension [TestType](test: Test[TestType])
inline def benchmark
[DurationType, ReportType]
(confidence: Maybe[Benchmark.Percentiles] = Unset, iterations: Maybe[Int] = Unset,
duration: Maybe[DurationType] = Unset, warmup: Maybe[DurationType] = Unset,
baseline: Maybe[Baseline] = Unset)
(confidence: Optional[Benchmark.Percentiles] = Unset, iterations: Optional[Int] = Unset,
duration: Optional[DurationType] = Unset, warmup: Optional[DurationType] = Unset,
baseline: Optional[Baseline] = Unset)
(using runner: Runner[ReportType], inc: Inclusion[ReportType, Benchmark],
specificDuration: SpecificDuration[DurationType] = timeApi.long,
genericDuration: GenericDuration[DurationType] = timeApi.long)
Expand Down
6 changes: 3 additions & 3 deletions src/core/probably.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ class TestContext():
object TestId:
given Ordering[TestId] = math.Ordering.Implicits.seqOrdering[List, Text].on(_.ids.reverse)

case class TestId(name: Text, suite: Maybe[TestSuite], codepoint: Codepoint):
case class TestId(name: Text, suite: Optional[TestSuite], codepoint: Codepoint):
val timestamp: Long = System.currentTimeMillis
import textWidthCalculation.uniform
lazy val id: Text = (suite.hashCode ^ name.hashCode).hex.pad(6, Rtl, '0').take(6, Rtl)
lazy val ids: List[Text] = id :: suite.let(_.id.ids).or(Nil)
def apply[T](ctx: TestContext ?=> T): Test[T] = Test[T](this, ctx(using _))
def depth: Int = suite.let(_.id.depth).or(0) + 1

class TestSuite(val name: Text, val parent: Maybe[TestSuite] = Unset)(using codepoint: Codepoint):
class TestSuite(val name: Text, val parent: Optional[TestSuite] = Unset)(using codepoint: Codepoint):
override def equals(that: Any): Boolean = that.matchable(using Unsafe) match
case that: TestSuite => name == that.name && parent == that.parent
case _ => false
Expand Down Expand Up @@ -90,7 +90,7 @@ class Runner[ReportType]()(using reporter: TestReporter[ReportType]):
def skip(id: TestId): Boolean = false
val report: ReportType = reporter.make()

def maybeRun[T, S](test: Test[T]): Maybe[TestRun[T]] =
def maybeRun[T, S](test: Test[T]): Optional[TestRun[T]] =
if skip(test.id) then Unset else run[T, S](test)

def run[T, S](test: Test[T]): TestRun[T] =
Expand Down
6 changes: 3 additions & 3 deletions src/core/report.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object Benchmark:

case class Benchmark
(total: Long, count: Int, min: Double, mean: Double, max: Double, sd: Double,
confidence: Benchmark.Percentiles, baseline: Maybe[Baseline]):
confidence: Benchmark.Percentiles, baseline: Optional[Baseline]):

def zScore(percentile: Benchmark.Percentiles): Double = percentile match
case 80 => 0.842
Expand Down Expand Up @@ -129,7 +129,7 @@ class TestReport(using Environment):
tests(testId)

enum ReportLine:
case Suite(suite: Maybe[TestSuite], tests: TestsMap = TestsMap())
case Suite(suite: Optional[TestSuite], tests: TestsMap = TestsMap())
case Test(test: TestId, outcomes: scm.ArrayBuffer[Outcome] = scm.ArrayBuffer())
case Bench(test: TestId, benchmark: Benchmark)

Expand Down Expand Up @@ -157,7 +157,7 @@ class TestReport(using Environment):

private val lines: ReportLine.Suite = ReportLine.Suite(Unset)

def resolve(suite: Maybe[TestSuite]): ReportLine.Suite =
def resolve(suite: Optional[TestSuite]): ReportLine.Suite =
suite.option.map: suite =>
(resolve(suite.parent).tests(suite.id): @unchecked) match
case suite@ReportLine.Suite(_, _) => suite
Expand Down

0 comments on commit 077aa87

Please sign in to comment.