'Regression test for https://github.com/spacetelescope/PyFITS/issues/49
Ensure that numeric values can be upcast/downcast between int, float,
and complex by assigning values that compare equal to the existing
value but are a different type.'

def test_update_numeric(self):

    h = fits.Header()
    h['TEST'] = 1
    h['TEST'] = 1.0
    assert isinstance(h['TEST'], float)
    assert str(h).startswith('TEST                =                                                                        1.0')
    h['TEST'] = 1
    assert isinstance(h['TEST'], int)
    assert str(h).startswith('TEST                =                                                                                1')
    h['TEST'] = (1.0 + 0j)
    assert isinstance(h['TEST'], complex)
    assert str(h).startswith('TEST                =                                            (1.0,    0.0)')
    h['TEST'] = 1.0
    assert isinstance(h['TEST'], float)
    assert str(h).startswith('TEST                =                                                                        1.0')
    h['TEST'] = (1.0 + 0j)
    assert isinstance(h['TEST'], complex)
    assert str(h).startswith('TEST                =                                            (1.0,    0.0)')
    h['TEST'] = 1
    assert isinstance(h['TEST'], int)
    assert str(h).startswith('TEST                =                                                                                1')
    h['TEST'] = 0
    h['TEST'] = 0.0
    assert isinstance(h['TEST'], float)
    assert str(h).startswith('TEST                =                                                                        0.0')
    h['TEST'] = 0
    assert isinstance(h['TEST'], int)
    assert str(h).startswith('TEST                =                                                                                0')
    h['TEST'] = (0.0 + 0j)
    assert isinstance(h['TEST'], complex)
    assert str(h).startswith('TEST                =                                            (0.0,    0.0)')
    h['TEST'] = 0.0
    assert isinstance(h['TEST'], float)
    assert str(h).startswith('TEST                =                                                                        0.0')
    h['TEST'] = (0.0 + 0j)
    assert isinstance(h['TEST'], complex)
    assert str(h).startswith('TEST                =                                            (0.0,    0.0)')
    h['TEST'] = 0
    assert isinstance(h['TEST'], int)
    assert str(h).startswith('TEST                =                                                                                0')
