import sys
import os

# Add src to path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))

from src.history import HistoryManager

def verify_phase_1():
 print("Verifying Phase 1: History Core Logic...")
 hm = HistoryManager(max_capacity=10)
 
 # Test push
 hm.push({"test": 1}, "initial")
 if not hm.can_undo:
  print("Error: can_undo should be true after push")
  sys.exit(1)
 
 # Test undo
 entry = hm.undo({"test": 2}, "current")
 if entry.state != {"test": 1}:
  print(f"Error: expected state {{'test': 1}}, got {entry.state}")
  sys.exit(1)
 if entry.description != "initial":
  print(f"Error: expected description 'initial', got {entry.description}")
  sys.exit(1)
 
 # Test redo
 entry = hm.redo({"test": 1}, "back")
 if entry.state != {"test": 2}:
  print(f"Error: expected state {{'test': 2}}, got {entry.state}")
  sys.exit(1)
 if entry.description != "current":
  print(f"Error: expected description 'current', got {entry.description}")
  sys.exit(1)

 print("Phase 1 verification PASSED.")

if __name__ == "__main__":
 verify_phase_1()
