diff --git a/src/core/probably-core.scala b/src/core/probably-core.scala index 88303dc..4ea1103 100644 --- a/src/core/probably-core.scala +++ b/src/core/probably-core.scala @@ -92,12 +92,12 @@ extension [TestType](test: Test[TestType]) assert[ReportType](pf.isDefinedAt(_)) -extension [ValueType](inline value: ValueType)(using inline test: TestContext) +extension [ValueType](inline value: ValueType)(using inline test: Testbed) inline def debug: ValueType = ${Probably.debug('value, 'test)} -package testContexts: - given threadLocal: TestContext = new TestContext(): - private val delegate: Option[TestContext] = Option(Runner.testContextThreadLocal.get()).map(_.nn).flatten +package testbeds: + given threadLocal: Testbed = new Testbed(): + private val delegate: Option[Testbed] = Option(Runner.testbedThreadLocal.get()).map(_.nn).flatten override def capture[ValueType: Inspectable](name: Text, value: ValueType): ValueType = delegate.map(_.capture[ValueType](name, value)).getOrElse(value) diff --git a/src/core/probably.Probably.scala b/src/core/probably.Probably.scala index 3c86411..6fb77bc 100644 --- a/src/core/probably.Probably.scala +++ b/src/core/probably.Probably.scala @@ -140,7 +140,7 @@ object Probably: inc.include(runner.report, test.id, outcome) result(run) - def debug[TestType: Type](expr: Expr[TestType], test: Expr[TestContext])(using Quotes): Expr[TestType] = + def debug[TestType: Type](expr: Expr[TestType], test: Expr[Testbed])(using Quotes): Expr[TestType] = import quotes.reflect.* val exprName: Text = expr.asTerm.pos match diff --git a/src/core/probably.Runner.scala b/src/core/probably.Runner.scala index d424fa9..a3f5517 100644 --- a/src/core/probably.Runner.scala +++ b/src/core/probably.Runner.scala @@ -20,7 +20,7 @@ import rudiments.* import vacuous.* object Runner: - private[probably] val testContextThreadLocal: ThreadLocal[Option[TestContext]] = ThreadLocal() + private[probably] val testbedThreadLocal: ThreadLocal[Option[Testbed]] = ThreadLocal() class Runner[ReportType]()(using reporter: Reporter[ReportType]): private var active: Set[TestId] = Set() @@ -31,8 +31,8 @@ class Runner[ReportType]()(using reporter: Reporter[ReportType]): def run[T, S](test: Test[T]): Trial[T] = synchronized { active += test.id } - val ctx = TestContext() - Runner.testContextThreadLocal.set(Some(ctx)) + val ctx = Testbed() + Runner.testbedThreadLocal.set(Some(ctx)) val ns0 = System.nanoTime try @@ -53,7 +53,7 @@ class Runner[ReportType]()(using reporter: Reporter[ReportType]): synchronized { active -= test.id } finally - Runner.testContextThreadLocal.set(None) + Runner.testbedThreadLocal.set(None) def suite(suite: TestSuite, block: TestSuite ?=> Unit): Unit = if !skip(suite.id) then diff --git a/src/core/probably.Test.scala b/src/core/probably.Test.scala index cab8493..09e81e3 100644 --- a/src/core/probably.Test.scala +++ b/src/core/probably.Test.scala @@ -16,4 +16,4 @@ package probably -case class Test[+ReturnType](id: TestId, action: TestContext => ReturnType) +case class Test[+ReturnType](id: TestId, action: Testbed => ReturnType) diff --git a/src/core/probably.TestId.scala b/src/core/probably.TestId.scala index a774017..f1d8268 100644 --- a/src/core/probably.TestId.scala +++ b/src/core/probably.TestId.scala @@ -33,7 +33,7 @@ case class TestId(name: Text, suite: Optional[TestSuite], codepoint: Codepoint): lazy val id: Text = (suite.hashCode ^ name.hashCode).hex.pad(6, Rtl, '0').keep(6, Rtl) lazy val ids: List[Text] = id :: suite.let(_.id.ids).or(Nil) - def apply[ResultType](ctx: TestContext ?=> ResultType): Test[ResultType] = + def apply[ResultType](ctx: Testbed ?=> ResultType): Test[ResultType] = Test[ResultType](this, ctx(using _)) def depth: Int = suite.let(_.id.depth).or(0) + 1 diff --git a/src/core/probably.TestContext.scala b/src/core/probably.Testbed.scala similarity index 97% rename from src/core/probably.TestContext.scala rename to src/core/probably.Testbed.scala index 2be220e..ab0d50f 100644 --- a/src/core/probably.TestContext.scala +++ b/src/core/probably.Testbed.scala @@ -22,7 +22,7 @@ import spectacular.* import scala.collection.mutable as scm -open class TestContext(): +open class Testbed(): private[probably] val captured: scm.ArrayBuffer[(Text, Text)] = scm.ArrayBuffer() def capture[ValueType: Inspectable](name: Text, value: ValueType): ValueType = diff --git a/src/core/soundness+probably-core.scala b/src/core/soundness+probably-core.scala index aaa2c8b..a2e1f7b 100644 --- a/src/core/soundness+probably-core.scala +++ b/src/core/soundness+probably-core.scala @@ -16,9 +16,9 @@ package soundness -export probably.{Baseline, Benchmark, Details, Inclusion, Outcome, Runner, Test, TestContext, +export probably.{Baseline, Benchmark, Details, Inclusion, Outcome, Runner, Test, Testbed, TestId, TestReport, Reporter, Trial, TestSuite, Tolerance, Min, Mean, Max, BySpeed, ByTime, Ratio, Difference, `+/-`, meets, test, suite, aspire, assert, check, matches, debug} package testContexts: - export probably.testContexts.{threadLocal} + export probably.testbeds.{threadLocal}