"""
Test GSPy return type compatibility
"""

import gspy_interface_robust

def test_return_type():
    """Test that the function always returns a tuple"""
    
    print("Testing GSPy return type compatibility...")
    print("=" * 50)
    
    # Test with valid parameters
    test_params = [0.075, 0.4, 0.35, 0.06, 8.0, 0.18, 50.0]
    
    try:
        result = gspy_interface_robust.run_modflow_step(*test_params)
        print(f"Valid params result: {result}")
        print(f"Type: {type(result)}")
        print(f"Is tuple: {isinstance(result, tuple)}")
        print(f"Length: {len(result) if isinstance(result, tuple) else 'N/A'}")
        
        if isinstance(result, tuple) and len(result) == 1:
            print(f"Return value: {result[0]} (type: {type(result[0])})")
            print("✓ Valid tuple format")
        else:
            print("✗ Invalid return format")
            
    except Exception as e:
        print(f"✗ Exception with valid params: {e}")
    
    print("\n" + "-" * 30)
    
    # Test with invalid parameters
    try:
        result = gspy_interface_robust.run_modflow_step("invalid", "params")
        print(f"Invalid params result: {result}")
        print(f"Type: {type(result)}")
        
        if isinstance(result, tuple) and len(result) == 1:
            print(f"Return value: {result[0]} (type: {type(result[0])})")
            print("✓ Graceful error handling")
        else:
            print("✗ Poor error handling")
            
    except Exception as e:
        print(f"✗ Exception with invalid params: {e}")
    
    print("\n" + "-" * 30)
    
    # Test with no parameters
    try:
        result = gspy_interface_robust.run_modflow_step()
        print(f"No params result: {result}")
        print(f"Type: {type(result)}")
        
        if isinstance(result, tuple) and len(result) == 1:
            print(f"Return value: {result[0]} (type: {type(result[0])})")
            print("✓ Handles missing parameters")
        else:
            print("✗ Poor parameter handling")
            
    except Exception as e:
        print(f"✗ Exception with no params: {e}")

if __name__ == "__main__":
    test_return_type()