refact: rm test file
This commit is contained in:
@@ -1,102 +0,0 @@
|
||||
"""Test script for array column specifier fix."""
|
||||
|
||||
from app.services.converter import Converter
|
||||
|
||||
|
||||
def test_array_specifier_fix():
|
||||
"""Test that array column specifiers with spaces are fixed."""
|
||||
|
||||
converter = Converter()
|
||||
|
||||
# The problematic LaTeX from the error
|
||||
latex_formula = r"""\begin{array}{l} D = \left| \begin{array}{c c c c} a _ {1 1} & a _ {1 2} & \dots & a _ {1 n} \\ \vdots & \vdots & & \vdots \\ a _ {i 1} + 0 + \dots + 0 & 0 + a _ {i 2} + \dots + 0 & \dots & 0 + \dots + 0 + a _ {i n} \\ \vdots & \vdots & & \vdots \\ a _ {n 1} & a _ {n 2} & \dots & a _ {n n} \end{array} \right| \\ = \left| \begin{array}{c c c c} a _ {1 1} & a _ {1 2} & \dots & a _ {1 n} \\ \vdots & \vdots & & \vdots \\ a _ {i 1} & 0 & \dots & 0 \\ \vdots & \vdots & & \vdots \\ a _ {n 1} & a _ {n 2} & \dots & a _ {n n} \end{array} \right| + \left| \begin{array}{c c c c} a _ {1 1} & a _ {1 2} & \dots & a _ {1 n} \\ \vdots & \vdots & & \vdots \\ 0 & a _ {i 2} & \dots & 0 \\ \vdots & \vdots & & \vdots \\ a _ {n 1} & a _ {n 2} & \dots & a _ {n n} \end{array} \right| \\ + \dots + \left| \begin{array}{c c c c} a _ {1 1} & a _ {1 2} & \dots & a _ {1 n} \\ \vdots & \vdots & & \vdots \\ 0 & 0 & \dots & a _ {i n} \\ \vdots & \vdots & & \vdots \\ a _ {n 1} & a _ {n 2} & \dots & a _ {n n} \end{array} \right|, \\ \end{array}"""
|
||||
|
||||
print("Testing array column specifier fix")
|
||||
print("=" * 80)
|
||||
print(f"\nOriginal LaTeX (first 200 chars):\n{latex_formula[:200]}...")
|
||||
|
||||
# Test preprocessing
|
||||
print("\n" + "-" * 80)
|
||||
print("Step 1: Preprocessing")
|
||||
preprocessed = converter._preprocess_formula_for_omml(latex_formula)
|
||||
|
||||
# Check if spaces were removed from array specifiers
|
||||
if "{c c c c}" in preprocessed:
|
||||
print("✗ FAILED: Spaces not removed from array specifiers")
|
||||
print(f"Found: {preprocessed[preprocessed.find('{c c c c}'):preprocessed.find('{c c c c}')+10]}")
|
||||
elif "{cccc}" in preprocessed:
|
||||
print("✓ SUCCESS: Spaces removed from array specifiers")
|
||||
print(f"Changed '{{{\"c c c c\"}}}' → '{{cccc}}'")
|
||||
else:
|
||||
print("? Could not find array specifier in preprocessed output")
|
||||
|
||||
# Test OMML conversion
|
||||
print("\n" + "-" * 80)
|
||||
print("Step 2: OMML Conversion")
|
||||
try:
|
||||
omml = converter.convert_to_omml(latex_formula)
|
||||
print(f"✓ SUCCESS: OMML conversion completed")
|
||||
print(f"OMML length: {len(omml)} characters")
|
||||
print(f"OMML preview (first 300 chars):\n{omml[:300]}...")
|
||||
|
||||
# Check if it contains oMath element
|
||||
if "oMath" in omml:
|
||||
print("\n✓ Valid OMML: Contains oMath element")
|
||||
else:
|
||||
print("\n✗ WARNING: OMML might be incomplete (no oMath element found)")
|
||||
|
||||
except Exception as e:
|
||||
print(f"✗ FAILED: OMML conversion error")
|
||||
print(f"Error: {e}")
|
||||
return False
|
||||
|
||||
print("\n" + "=" * 80)
|
||||
print("✓ All tests passed!")
|
||||
return True
|
||||
|
||||
|
||||
def test_simple_array():
|
||||
"""Test with a simpler array example."""
|
||||
|
||||
converter = Converter()
|
||||
|
||||
print("\nTesting simple array")
|
||||
print("=" * 80)
|
||||
|
||||
# Simple array with spaces in column specifier
|
||||
latex_formula = r"\begin{array}{c c c} a & b & c \\ d & e & f \end{array}"
|
||||
|
||||
print(f"LaTeX: {latex_formula}")
|
||||
|
||||
try:
|
||||
omml = converter.convert_to_omml(latex_formula)
|
||||
print(f"✓ SUCCESS: Converted to OMML ({len(omml)} chars)")
|
||||
print(f"Preview: {omml[:200]}...")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"✗ FAILED: {e}")
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Array Column Specifier Fix Test Suite\n")
|
||||
|
||||
try:
|
||||
test1 = test_simple_array()
|
||||
test2 = test_array_specifier_fix()
|
||||
|
||||
if test1 and test2:
|
||||
print("\n" + "=" * 80)
|
||||
print("✓✓✓ ALL TESTS PASSED ✓✓✓")
|
||||
print("=" * 80)
|
||||
else:
|
||||
print("\n" + "=" * 80)
|
||||
print("✗✗✗ SOME TESTS FAILED ✗✗✗")
|
||||
print("=" * 80)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\n\nTests interrupted by user")
|
||||
except Exception as e:
|
||||
print(f"\n\nTest suite error: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
Reference in New Issue
Block a user