/**
* Test for Enhanced Error Reporting
* Part of Phase 4b: Logic-Thinking MCP Server
*/
import { LogicManager } from './logicManager.js';
import { Loggers } from './utils/logger.js';
const logger = Loggers.server;
// Create logic manager
const logicManager = new LogicManager();
logger.info('===== TESTING ENHANCED ERROR REPORTING =====');
// Test syntax errors - invalid mathematical expression
try {
logger.info('Testing syntax error - invalid expression');
const result = logicManager.process('mathematical', 'validate', '1, 2, 3, x*', 'natural');
logger.info('Syntax error test result', { result });
} catch (error) {
logger.error('Error in syntax test', { error: error instanceof Error ? error.message : String(error) });
}
// Test division by zero error
try {
logger.info('Testing division by zero error');
// Use a more direct division by zero example
const result = logicManager.process('mathematical', 'validate', {
terms: [{
type: 'operation',
operator: '/',
operands: [
{ type: 'number', value: 10 },
{ type: 'number', value: 0 }
]
}],
constraints: [],
question: "What is 10 divided by 0?"
}, 'symbolic');
logger.info('Division by zero test result', { result });
} catch (error) {
logger.error('Error in division by zero test', { error: error instanceof Error ? error.message : String(error) });
}
// Test invalid sequence - sequence that doesn't fit a pattern
try {
logger.info('Testing invalid sequence pattern');
const result = logicManager.process('mathematical', 'validate', {
terms: [],
constraints: [{
type: 'pattern',
sequence: [
{ type: 'number', value: 1 },
{ type: 'number', value: 3 },
{ type: 'number', value: 7 },
{ type: 'number', value: 15 }
],
pattern: 'unknown'
}],
question: "What is the next number in the sequence?"
}, 'symbolic');
logger.info('Invalid sequence pattern test result', { result });
} catch (error) {
logger.error('Error in sequence pattern test', { error: error instanceof Error ? error.message : String(error) });
}
// Test unsupported operation
try {
logger.info('Testing unsupported operation');
const result = logicManager.process('mathematical', 'unknown' as any, '1, 2, 3, 4', 'natural');
logger.info('Unsupported operation test result', { result });
} catch (error) {
logger.error('Error in unsupported operation test', { error: error instanceof Error ? error.message : String(error) });
}
// Test unsupported system
try {
logger.info('Testing unsupported system');
const result = logicManager.process('unknown' as any, 'validate', '1, 2, 3, 4', 'natural');
logger.info('Unsupported system test result', { result });
} catch (error) {
logger.error('Error in unsupported system test', { error: error instanceof Error ? error.message : String(error) });
}
// Test invalid mathematical sequence format
try {
logger.info('Testing invalid sequence format');
const result = logicManager.process('mathematical', 'validate', '1, 2, 3, 4, abc', 'natural');
logger.info('Invalid sequence format test result', { result });
} catch (error) {
logger.error('Error in sequence format test', { error: error instanceof Error ? error.message : String(error) });
}
// Test unbalanced equation
try {
logger.info('Testing unbalanced equation');
const result = logicManager.process('mathematical', 'validate', 'x + 5 = ', 'natural');
logger.info('Unbalanced equation test result', { result });
} catch (error) {
logger.error('Error in unbalanced equation test', { error: error instanceof Error ? error.message : String(error) });
}
logger.info('===== ENHANCED ERROR REPORTING TEST COMPLETE =====');