semantic-prompt-mcp
Version:
MCP server for semantic prompt framework - NLP-inspired adaptive reasoning engine for LLM orchestration
105 lines โข 3.22 kB
JavaScript
/**
* Simple test for parameter normalization
* Tests the core problem: handling various parameter formats
*/
import { ParameterNormalizer } from '../utils/parameterNormalizer.js';
const normalizer = new ParameterNormalizer();
// Test cases focusing on the actual problem we're solving
const testCases = [
{
name: 'XML format (the original bug)',
input: {
thought: "Test thought",
commandSelection: '<parameter name="type">command</parameter><parameter name="command">analyze</parameter>',
thoughtNumber: 2,
totalThoughts: 3,
nextThoughtNeeded: true
},
expected: {
commandSelection: { type: 'command', command: 'analyze' }
}
},
{
name: 'Already correct format',
input: {
thought: "Test thought",
commandSelection: { type: 'command', command: 'analyze' },
thoughtNumber: 2,
totalThoughts: 3,
nextThoughtNeeded: true
},
expected: {
commandSelection: { type: 'command', command: 'analyze' }
}
},
{
name: 'String numbers and booleans',
input: {
thought: "Test thought",
thoughtNumber: "2",
totalThoughts: "3",
nextThoughtNeeded: "true"
},
expected: {
thoughtNumber: 2,
totalThoughts: 3,
nextThoughtNeeded: true
}
},
{
name: 'JSON string for commandSelection',
input: {
thought: "Test thought",
commandSelection: '{"type":"command","command":"build"}',
thoughtNumber: 2,
totalThoughts: 3,
nextThoughtNeeded: false
},
expected: {
commandSelection: { type: 'command', command: 'build' }
}
}
];
let passed = 0;
let failed = 0;
console.log('๐งช Testing Parameter Normalization\n');
console.log('='.repeat(50));
for (const testCase of testCases) {
console.log(`\nTest: ${testCase.name}`);
try {
const result = normalizer.normalizeChainOfThoughtParams(testCase.input);
let success = true;
// Check each expected field
for (const [key, expectedValue] of Object.entries(testCase.expected)) {
const actualValue = result[key];
const match = JSON.stringify(actualValue) === JSON.stringify(expectedValue);
if (!match) {
console.log(` โ ${key}: expected ${JSON.stringify(expectedValue)}, got ${JSON.stringify(actualValue)}`);
success = false;
}
}
if (success) {
console.log(' โ
PASSED');
passed++;
}
else {
failed++;
}
}
catch (error) {
console.log(` โ ERROR: ${error}`);
failed++;
}
}
console.log('\n' + '='.repeat(50));
console.log(`\nResults: ${passed} passed, ${failed} failed`);
if (failed === 0) {
console.log('โจ All tests passed!');
process.exit(0);
}
else {
console.log('โ Some tests failed');
process.exit(1);
}
//# sourceMappingURL=test-normalization.js.map