Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofpackage caseBench.package·originates fromworld 0a0b119f-a…

bench

Run test cases in-process, without the engine's test runner.

byzero-proxy @ DESKTOP-DB3UJOJ·posted 11d ago
What it does

bench

Run test cases in-process, without the engine's test runner.

The engine's own runner (`Test.run`, behind `tests.run` and a suite's `:run()`) closes the open scene before
the first test and reloads it from source after the last. That is right for a regression sweep and wrong while
other people are working in the same engine client. This bench runs the SAME cases against a small framework
of its own, touching nothing but the Lua values the cases make.

A case module is a plain module that returns a function taking the framework:

  -- myKit.package/tests/cases/heat.module/init.luau
  local Heat = require("myKit.modules.heat")
  return function(Test: any)
      Test.describe("myKit.heat", function()
          Test.it("adds the points of a named offence", function()
              Test.expect(Heat.new(cfg):add("seen")).toBe(12)
          end)
      end)
  end

The package's `.testSuite/init.luau` hands the engine's framework to the same modules, so the engine runner
and this bench run identical cases:

  local Test = asset.containing(__FILE__).modules.shared
  require("~.tests.cases.heat")(Test)
  return true

From an `execute` script:

  local Bench = require("caseBench.modules.bench")
  return Bench.run({
      { name = "myKit", cases = { require("myKit.tests.cases.heat") } },
  }, { filter = "heat", clock = os.clock })
  -- { total, passed, failed, skipped, seconds,
  --   suites = { { name, total, passed, failed, skipped, seconds } },
  --   failures = { { suite, group, test, errors = { "..." } } },
  --   slowest = { { name, seconds } } }

The framework it hands to cases (the subset of the engine's `Test` the cases may use):
  describe(name, fn)   it(name, fn(t))   skip(name, fn?)   beforeEach(fn)   afterEach(fn)
  expect(value) with toBe, toBeTruthy, toBeFalsy, toBeNil, notToBeNil, toBeType, toBeGreaterThan, toBeLessThan,
  toBeCloseTo(expected, within = 0.001), toContain, toMatch, toHaveLength, toThrow, and never() to negate.
As in the engine's framework a failed expectation is recorded and the body runs on; a raise ends the body.
Cases must be synchronous (no waitFrames): they are logic tests.

The interface is documented in the header of init.luau; this file repeats it for the asset browser.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

caseBench.modules.bench — run test cases in-process, without the engine's test runner. The engine's own runner (`Test.run`, behind `tests.run` and a suite's `:run()`) closes the open scene before the first test and reloads it from source after the last. That is right for a regression sweep and wrong while other people are working in the same engine client. This bench runs the SAME cases against a small framework of its own, touching nothing but the Lua values the cases make. A case module is a plain module that returns a function taking the framework: -- myKit.package/tests/cases/heat.module/init.luau local Heat = require("myKit.modules.heat") return function(Test: any) Test.describe("myKit.heat", function() Test.it("adds the points of a named offence", function() Test.expect(Heat.new(cfg):add("seen")).toBe(12) end) end) end The package's `.testSuite/init.luau` hands the engine's framework to the same modules, so the engine runner and this bench run identical cases: local Test = asset.containing(__FILE__).modules.shared require("~.tests.cases.heat")(Test) return true From an `execute` script: local Bench = require("caseBench.modules.bench") return Bench.run({ { name = "myKit", cases = { require("myKit.tests.cases.heat") } }, }, { filter = "heat", clock = os.clock }) -- { total, passed, failed, skipped, seconds, -- suites = { { name, total, passed, failed, skipped, seconds } }, -- failures = { { suite, group, test, errors = { "..." } } }, -- slowest = { { name, seconds } } } The framework it hands to cases (the subset of the engine's `Test` the cases may use): describe(name, fn) it(name, fn(t)) skip(name, fn?) beforeEach(fn) afterEach(fn) expect(value) with toBe, toBeTruthy, toBeFalsy, toBeNil, notToBeNil, toBeType, toBeGreaterThan, toBeLessThan, toBeCloseTo(expected, within = 0.001), toContain, toMatch, toHaveLength, toThrow, and never() to negate. As in the engine's framework a failed expectation is recorded and the body runs on; a raise ends the body. Cases must be synchronous (no waitFrames): they are logic tests.

describeValue(v: any) → string

argtypedescription
vany

newFramework(state: any) → any

argtypedescription
stateany

describe(name: string, fn: () → void

argtypedescription
namestring
fn(

it(name: string, fn: (any) → void

argtypedescription
namestring
fn(any

skip(name: string, _fn: ((any) → void

argtypedescription
namestring
_fn((any

beforeEach(fn: () → void

argtypedescription
fn(

afterEach(fn: () → void

argtypedescription
fn(

where( ) → string

where the failing expectation was written: the first frame that is not this module

fail(text: string) → void

argtypedescription
textstring

expect(value: any) → any

argtypedescription
valueany

check(pass: boolean, positive: string, negative: string) → boolean

argtypedescription
passboolean
positivestring
negativestring

never( ) → void

toBe(expected: any) → void

argtypedescription
expectedany

toBeTruthy( ) → void

toBeFalsy( ) → void

toBeNil( ) → void

notToBeNil( ) → void

toBeType(name: string) → void

argtypedescription
namestring

toBeGreaterThan(n: number) → void

argtypedescription
nnumber

toBeLessThan(n: number) → void

argtypedescription
nnumber

toBeCloseTo(expected: number, within: number?) → void

argtypedescription
expectednumber
withinnumber?

toContain(part: string) → void

argtypedescription
partstring

toMatch(pattern: string) → void

argtypedescription
patternstring

toHaveLength(n: number) → void

argtypedescription
nnumber

toThrow( ) → void

run(suites: { any }, opts: any?) → any

Run suites of case modules. See the header. `opts.filter` keeps the tests whose "group :: name" contains it; `opts.clock` is the seconds source for durations (default os.clock).

argtypedescription
suites{ any }
optsany?

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.