Test-driven development for PascalAI agents — write tests first, verify BB state, run with RunTests.exe
ppm install agent-tdd
ppm skill install-claude
The second command activates the skill in Claude Code
(copies it into .claude/skills/).
You are a TDD expert for PascalAI. Write tests first, make them fail, then implement the minimum code to pass.
PascalAI tests live in tests/examples/. The runner (RunTests.exe or run_demos.ps1) scans this directory.
A test passes when it prints a bare PASS line (no surrounding text). It fails on any other output, exception, or non-zero exit.
program test_my_feature;
begin
LLM_Connect('claude-opus-4-6', GetEnv('ANTHROPIC_API_KEY'));
var Result := MyFunction(42);
if Result = 84 then
WriteLn('PASS')
else
begin
WriteLn('FAIL: expected 84, got ' + IntToStr(Result));
Halt(1);
end;
end.
pai run test_file.pai — confirm it failsPASSSince agents run asynchronously, verify via Blackboard state:
program test_summarizer_agent;
begin
LLM_Connect('claude-opus-4-6', GetEnv('ANTHROPIC_API_KEY'));
BB.Set('input', 'PascalAI is an AI-native language.');
SummarizerAgent_Spawn;
Sleep(500); // wait for cyclic agent to process
var Summary := BB.Get('summary');
if Length(Summary) > 10 then
WriteLn('PASS')
else
WriteLn('FAIL: summary too short: ' + Summary);
end.
Pre-set BB values to simulate LLM output and test agent logic in isolation:
BB.Set('llm_response', 'mocked response');
MyAgent_ProcessResult; // test handler logic, not the LLM call
if BB.Get('status') = 'done' then
WriteLn('PASS')
else
WriteLn('FAIL');
type TResult = record Score: Double; Label: string; end;
var C: Completion<TResult>;
C := LLM_JSON<TResult>('Classify sentiment: "great product"');
if (C.Value.Score > 0.5) and (C.Value.Label = 'positive') then
WriteLn('PASS')
else
WriteLn('FAIL: score=' + FloatToStr(C.Value.Score));
cd tests
./run_demos.ps1
cd tests
./run_demos.sh
// String check
if S <> '' then WriteLn('PASS') else WriteLn('FAIL: empty string');
// Numeric range
if (N >= 1) and (N <= 100) then WriteLn('PASS') else WriteLn('FAIL: ' + IntToStr(N));
// BB state after agent runs
if BB.Get('status') = 'done' then WriteLn('PASS') else WriteLn('FAIL: status=' + BB.Get('status'));
// JSON contains key
if Pos('"name"', jsonStr) > 0 then WriteLn('PASS') else WriteLn('FAIL: missing name key');
NNN_feature_name.pai — demo/integration test (NNN = sequential number)
test_unit_name.pai — unit-level test