mirror of
https://github.com/personamanagmentlayer/pcl.git
synced 2026-09-14 15:40:22 +08:00
fb8288d2e8
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>
38 lines
1013 B
JavaScript
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]}`);
|
|
});
|
|
}
|