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>
76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Simple test to debug workflow validation
|
|
*/
|
|
|
|
import { compile } from '../dist/index.js';
|
|
|
|
console.log('Testing workflow validation...\n');
|
|
|
|
// Test 1: Simple unreachable else branch
|
|
const source1 = `
|
|
persona A { intent: "Test" }
|
|
persona B { intent: "Test" }
|
|
|
|
workflow TestWorkflow {
|
|
steps: if (true) then A else B
|
|
}
|
|
`;
|
|
|
|
console.log('Test 1: Unreachable else branch');
|
|
console.log('Source:', source1);
|
|
|
|
const result1 = compile(source1, { source: 'test.pcl' });
|
|
console.log('\nResult:', {
|
|
ok: result1.ok,
|
|
errors: result1.ok ? result1.value.analysis.errors.length : result1.error.length,
|
|
warnings: result1.ok ? result1.value.analysis.warnings.length : 0,
|
|
});
|
|
|
|
if (result1.ok && result1.value.analysis.warnings.length > 0) {
|
|
console.log('\nWarnings:');
|
|
result1.value.analysis.warnings.forEach((w, i) => {
|
|
console.log(`[${i + 1}] ${w.message}`);
|
|
});
|
|
} else if (!result1.ok) {
|
|
console.log('\nErrors:');
|
|
result1.error.forEach((e, i) => {
|
|
console.log(`[${i + 1}] ${e.message}`);
|
|
});
|
|
}
|
|
|
|
// Test 2: Parallel branches
|
|
const source2 = `
|
|
persona P1 { intent: "Test" }
|
|
persona P2 { intent: "Test" }
|
|
persona P3 { intent: "Test" }
|
|
persona P4 { intent: "Test" }
|
|
persona P5 { intent: "Test" }
|
|
persona P6 { intent: "Test" }
|
|
persona P7 { intent: "Test" }
|
|
persona P8 { intent: "Test" }
|
|
persona P9 { intent: "Test" }
|
|
persona P10 { intent: "Test" }
|
|
persona P11 { intent: "Test" }
|
|
|
|
workflow TestWorkflow {
|
|
steps: P1 || P2 || P3 || P4 || P5 || P6 || P7 || P8 || P9 || P10 || P11
|
|
}
|
|
`;
|
|
|
|
console.log('\n\nTest 2: Too many parallel branches');
|
|
const result2 = compile(source2, { source: 'test.pcl' });
|
|
console.log('Result:', {
|
|
ok: result2.ok,
|
|
errors: result2.ok ? result2.value.analysis.errors.length : result2.error.length,
|
|
warnings: result2.ok ? result2.value.analysis.warnings.length : 0,
|
|
});
|
|
|
|
if (result2.ok && result2.value.analysis.warnings.length > 0) {
|
|
console.log('\nWarnings:');
|
|
result2.value.analysis.warnings.forEach((w, i) => {
|
|
console.log(`[${i + 1}] ${w.message}`);
|
|
});
|
|
}
|