import pytest
from atomic_agents.core import TDLNCompressor


class TestTDLNCompressor:
    def test_basic_compression(self):
        compressor = TDLNCompressor()
        text = "Please help me. The goal is to summarize this text."
        result = compressor.compress(text)
        assert "→" in result or "⊢" in result
        assert len(result) < len(text)

    def test_grammar_rules(self):
        compressor = TDLNCompressor()
        test_cases = [
            ("Please help me", "→"),
            ("The goal is to", "⊢"),
            ("For example", "eg:"),
            ("Therefore", "∴"),
        ]
        for original, symbol in test_cases:
            result = compressor.compress(original)
            assert symbol in result

    def test_deduplication(self):
        compressor = TDLNCompressor()
        text = "Please Please help me"
        result = compressor.compress(text)
        # Should remove duplicate "Please"
        assert result.count("Please") <= 1

    def test_step_compression(self):
        compressor = TDLNCompressor()
        text = "Step 1: Do this. Step 2: Do that."
        result = compressor.compress(text)
        assert "1." in result
        assert "2." in result

    def test_empty_string(self):
        compressor = TDLNCompressor()
        result = compressor.compress("")
        assert result == ""

    def test_case_insensitive(self):
        compressor = TDLNCompressor()
        text = "PLEASE HELP ME"
        result = compressor.compress(text)
        assert "→" in result or len(result) < len(text)


