50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Script de prueba para el modo simbólico de la calculadora - ASIGNACIONES
|
|
"""
|
|
|
|
from main_evaluation import HybridEvaluationEngine
|
|
|
|
def test_assignments():
|
|
"""Prueba las asignaciones en modo simbólico"""
|
|
print("=" * 60)
|
|
print("PRUEBA DE ASIGNACIONES EN MODO SIMBÓLICO")
|
|
print("=" * 60)
|
|
|
|
# Crear motor en modo simbólico
|
|
print("\n1. MODO SIMBÓLICO ACTIVADO:")
|
|
engine_symbolic = HybridEvaluationEngine()
|
|
engine_symbolic.set_symbolic_mode(
|
|
symbolic_mode=True,
|
|
show_numeric=True,
|
|
keep_fractions=True
|
|
)
|
|
|
|
# Pruebas de asignaciones
|
|
assignment_tests = [
|
|
"a = 25/51",
|
|
"b = 4/5",
|
|
"c = 22/7",
|
|
"d = 3/4 + 1/6",
|
|
"e = sqrt(2)/2"
|
|
]
|
|
|
|
for test in assignment_tests:
|
|
result = engine_symbolic.evaluate_line(test)
|
|
print(f" {test:15} → Tipo: {result.result_type}")
|
|
print(f" {' ':15} Resultado: {result.result}")
|
|
print(f" {' ':15} Simbólico: {result.symbolic_result}")
|
|
if result.numeric_result:
|
|
print(f" {' ':15} Numérico: ≈ {result.numeric_result}")
|
|
else:
|
|
print(f" {' ':15} Numérico: None")
|
|
print()
|
|
|
|
print("\n2. VERIFICAR VALORES ASIGNADOS:")
|
|
variables = ['a', 'b', 'c', 'd', 'e']
|
|
for var in variables:
|
|
value = engine_symbolic.get_variable(var)
|
|
print(f" {var} = {value} (tipo: {type(value)})")
|
|
|
|
if __name__ == "__main__":
|
|
test_assignments() |