Files
personamanagmentlayer__pcl/tests/test-complex-workflow.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

38 lines
1013 B
JavaScript

#!/usr/bin/env node
import { compile } from '../dist/index.js';
const source = `
persona A { intent: "Test" }
persona B { intent: "Test" }
persona C { intent: "Test" }
workflow ComplexWorkflow {
steps: (A -> B) || (if (input.condition) then C else A)
}
`;
const result = compile(source, { source: 'test.pcl' });
console.log('Result:', {
ok: result.ok,
errors: result.ok ? result.value.analysis.errors.length : result.error.length,
warnings: result.ok ? result.value.analysis.warnings.length : 0,
});
if (result.ok) {
console.log('\nErrors:');
result.value.analysis.errors.forEach((e, i) => {
console.log(`[${i + 1}] ${e.code}: ${e.message.split('\n')[0]}`);
});
console.log('\nWarnings:');
result.value.analysis.warnings.forEach((w, i) => {
console.log(`[${i + 1}] ${w.code}: ${w.message.split('\n')[0]}`);
});
} else {
console.log('\nParse errors:');
result.error.forEach((e, i) => {
console.log(`[${i + 1}] ${e.code}: ${e.message.split('\n')[0]}`);
});
}