with an even number of points the symmetry is not quite right. In the frequency domain, for eight points (without any fftshift), the array points correspond to frequencies
[0 1 2 3 ny -3 -2 -1]
there is the dc term, then all the other frequencies pair up, but there is one extra point, the nyquist point. Its frequency can be either +- 4 depending on how you look at it. 4 and -4 are equivalent, and transform over to the time domain as a wave oscillating at maximum possible frequency, alternating between +1 and -1 with the array elements. Furthermore, the nyquist point produces a real-valued wave, no imaginary part (the other frequecies, except for f=0, produce complex-valued waves);
Now reverse the roles of f and t. A nonzero value in f(t) at the nyquist point is going to give a real-valued oscillation between +1 and -1 in the frequency plot. In the sine case you are expecting imaginary values which you mostly get. But you also get real values due to the time-domain nyquist point, and that is what you see in the frequency plot. In the cosine case you are expecting real values which you get. You also get a real contribution from the time-domain nyquist point, but the important thing is no imaginary contribution. So cos works, sine doesn't work.
The easy way out is to go to an odd number of points. Then for example you have
[0 1 2 3 -3 -2 -1]
The frequencies pair up and there is no nyquist point. The code below uses 129 points and you should like the result. The t array is changed appropriately. Note the use of ifftshift, not fftshift. ifftshift drops the t=0 point down to the beginning of the array. fftshift takes the t=0 point back to the middle of the array. For an even number of points fftshift and ifftshift are identical.. For an odd number of points, they are inverses but not identical.
n = 129;