Files
personamanagmentlayer__pcl/tests/test-ast-debug.mjs
ANGX fb8288d2e8 feat: implement Phase 1.0D workflow validation tests
Created comprehensive test suite for workflow validation features:

- 10/10 tests passing for implemented workflow validations
- Tests for unreachable code detection in conditionals
- Tests for parallel branch count limits
- Tests for complex workflow structures

Key additions:
- Fixed ParenthesizedExpression handling in evaluateConstantCondition()
- Created workflow-validation-core.test.mjs with 10 passing tests
- Tests verify rich error messages include suggestions

Test coverage:
✓ Unreachable else branch detection (condition always true)
✓ Unreachable then branch detection (condition always false)
✓ Dynamic conditions allowed without warnings
✓ Boolean expression constant evaluation
✓ Negation operator constant evaluation
✓ Parallel branch count warnings (>10 branches)
✓ No warnings for reasonable parallel branches (≤10)
✓ Nested grouped workflow validation
✓ Sequential then parallel workflow validation
✓ Choice workflow validation

Note: Loop validation tests deferred (awaiting parser implementation)

All workflow validation tests pass with proper error messages and suggestions.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-17 05:35:38 +01:00

58 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
/**
* Debug test to see what AST is generated for workflow conditionals
*/
import { parse } from '../dist/index.js';
const source = `
persona A { intent: "Test" }
workflow TestWorkflow {
steps: if (true) then A else A
}
`;
console.log('Parsing PCL source...\n');
const result = parse(source, { source: 'test.pcl' });
if (!result.ok) {
console.log('Parse errors:');
result.error.forEach((e) => console.log(' -', e.message));
process.exit(1);
}
console.log('Parse successful!');
console.log('Errors:', result.value.errors.length);
console.log('Warnings:', result.value.warnings.length);
// Find the workflow declaration
const workflow = result.value.program.statements.find(
(s) => s.kind === 'WorkflowDeclaration'
);
if (!workflow) {
console.log('\nNo workflow found!');
process.exit(1);
}
console.log('\nWorkflow found:', workflow.id.name);
// Get the steps
const stepsDecl = workflow.body.members.find((m) => m.kind === 'WorkflowStepsDeclaration');
if (!stepsDecl) {
console.log('No steps declaration found!');
process.exit(1);
}
console.log('\nSteps expression kind:', stepsDecl.steps.kind);
if (stepsDecl.steps.kind === 'WorkflowConditionalExpr') {
const cond = stepsDecl.steps;
console.log('Condition kind:', cond.condition.kind);
console.log('Condition value:', JSON.stringify(cond.condition, null, 2));
}