test_math_processor.php 763 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. require __DIR__ . '/vendor/autoload.php';
  3. use App\Services\MathFormulaProcessor;
  4. echo "=== 测试数学公式处理器优化效果 ===\n\n";
  5. // 测试用例
  6. $testCases = [
  7. '已知函数 f(x) = x^2 - 4x + 5,求最小值',
  8. 'f(x) = x^2 - 4x + 5',
  9. '4x^2 - 25y^2',
  10. '验证:$2x^2 + 1$',
  11. '这是一段普通文本,不包含数学公式',
  12. '\frac{1}{2} + \frac{1}{3}',
  13. 'x^2 + y^2 = 1',
  14. '已知函数 g(x) = 2x + 3,求 g(5)',
  15. ];
  16. foreach ($testCases as $index => $testCase) {
  17. echo "测试用例 " . ($index + 1) . ":\n";
  18. echo "输入: " . $testCase . "\n";
  19. $result = MathFormulaProcessor::processFormulas($testCase);
  20. echo "输出: " . $result . "\n";
  21. echo "---\n\n";
  22. }
  23. echo "=== 测试完成 ===\n";