/** * @script_test Trait — Headless Unit Testing for HoloScript * * Provides deterministic, headless unit testing for `.hs` and `.hsplus` files. * Tests run without any render target — pure logic validation. * * Usage in .hs: * ```hs * @script_test "agent creates bounty" { * setup { economy.init(500) } * assert { economy.balance == 500 } * action { economy.create_bounty("task1", 100) } * assert { economy.balance == 400 } * } * ``` * * Trait name: script_test * Category: testing * Compile targets: all (headless-native) */ export interface ScriptTestResult { name: string; status: 'passed' | 'failed' | 'skipped'; durationMs: number; error?: string; assertions: number; passedAssertions: number; } export interface ScriptTestBlock { name: string; setup?: () => void; actions: Array<() => void>; assertions: Array<{ description: string; check: () => boolean; }>; teardown?: () => void; skip?: boolean; } export interface ScriptTestRunnerOptions { debug?: boolean; timeout?: number; bail?: boolean; runtimeState?: Record; } /** * ScriptTestRunner — Executes @script_test blocks headlessly */ export declare class ScriptTestRunner { private options; private tests; constructor(options?: ScriptTestRunnerOptions); /** * Bind runtime state for live assertion resolution */ setRuntimeState(state: Record): void; /** * Register a test block */ addTest(test: ScriptTestBlock): void; /** * Run all registered tests */ runAll(): ScriptTestResult[]; /** * Run a single test block */ private runSingle; /** * Parse @script_test blocks from .hs source and run them */ runTestsFromSource(source: string, _filePath?: string): ScriptTestResult[]; /** * Extract @script_test blocks from source text */ private extractTestBlocks; /** * Evaluate a simple assertion expression from @script_test blocks * Supports: true, false, numeric comparisons, string equality, property access */ private evaluateExpression; /** * Resolve a value token to a primitive */ private resolveValue; /** * Bind a HeadlessRuntime so @script_test assertions can read live scene state. * Snapshots the runtime's state into runtimeState before each test run. * * Usage: * ```ts * import { createHeadlessRuntime } from '@holoscript/engine/runtime/HeadlessRuntime'; * const runtime = createHeadlessRuntime(ast); * runtime.setState('balance', 500); * runner.bindHeadlessRuntime(runtime); * // Now @script_test assertions like `assert { balance == 500 }` work * ``` */ bindHeadlessRuntime(runtime: { getAllState(): Record; }): void; } /** * Trait definition for the standard traits registry */ export declare const SCRIPT_TEST_TRAIT: { name: string; category: string; description: string; compileTargets: string[]; requiresRenderer: boolean; parameters: ({ name: string; type: string; required: boolean; description: string; default?: undefined; } | { name: string; type: string; required: boolean; default: number; description: string; } | { name: string; type: string; required: boolean; default: boolean; description: string; })[]; }; import type { HSPlusNode, TraitContext, TraitEvent } from '@holoscript/core'; export declare const scriptTestHandler: { readonly name: "script_test"; readonly defaultConfig: {}; readonly onAttach: (node: HSPlusNode, config: unknown, ctx: TraitContext) => void; readonly onDetach: (node: HSPlusNode, _config: unknown, ctx: TraitContext) => void; readonly onEvent: (node: HSPlusNode, _config: unknown, ctx: TraitContext, event: TraitEvent) => void; readonly onUpdate: (node: HSPlusNode, _config: unknown, ctx: TraitContext, dt: number) => void; }; //# sourceMappingURL=ScriptTestTrait.d.ts.map